-
Notifications
You must be signed in to change notification settings - Fork 269
userdel: fix user busy detection for threads #1623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ | |
|
|
||
|
|
||
| #ifdef __linux__ | ||
| static int check_status (const char *name, const char *sname, uid_t uid); | ||
| static int check_status (const char *name, uid_t uid, pid_t pid, pid_t tid); | ||
| static int user_busy_processes (const char *name, uid_t uid); | ||
| #else /* !__linux__ */ | ||
| static int user_busy_utmp (const char *name); | ||
|
|
@@ -94,13 +94,13 @@ user_busy_utmp(const char *name) | |
| #ifdef __linux__ | ||
| #ifdef ENABLE_SUBIDS | ||
| #define in_parentuid_range(uid) ((uid) >= parentuid && (uid) < parentuid + range) | ||
| static int different_namespace (const char *sname) | ||
| static int different_namespace (pid_t pid, pid_t tid) | ||
| { | ||
| /* 41: /proc/xxxxxxxxxx/task/xxxxxxxxxx/ns/user + \0 */ | ||
| char path[41]; | ||
| char buf[512], buf2[512]; | ||
|
|
||
| stprintf_a(path, "/proc/%s/ns/user", sname); | ||
| stprintf_a(path, "/proc/%d/task/%d/ns/user", pid, tid); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I know,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is true for POSIX, but we're now inside for all platforms (see uapi/asm-generic/posix_types.h). Further, the existing code also uses However the existing code does it inconsistently. If you tell what's your preference I could add a commit that aligns pid_t formatting for the whole user_busy.c file.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like using Consider the possibility that we paste that code somewhere else that is not wrapped in |
||
|
|
||
| if (readlinknul_a(path, buf) == -1) | ||
| return 0; | ||
|
|
@@ -116,14 +116,14 @@ static int different_namespace (const char *sname) | |
| #endif /* ENABLE_SUBIDS */ | ||
|
|
||
|
|
||
| static int check_status (const char *name, const char *sname, uid_t uid) | ||
| static int check_status (const char *name, uid_t uid, pid_t pid, pid_t tid) | ||
| { | ||
| /* 40: /proc/xxxxxxxxxx/task/xxxxxxxxxx/status + \0 */ | ||
| char status[40]; | ||
| char line[1024]; | ||
| FILE *sfile; | ||
|
|
||
| stprintf_a(status, "/proc/%s/status", sname); | ||
| stprintf_a(status, "/proc/%d/task/%d/status", pid, tid); | ||
|
|
||
| sfile = fopen (status, "r"); | ||
| if (NULL == sfile) { | ||
|
|
@@ -144,7 +144,7 @@ static int check_status (const char *name, const char *sname, uid_t uid) | |
| return 1; | ||
| } | ||
| #ifdef ENABLE_SUBIDS | ||
| if ( different_namespace (sname) | ||
| if ( different_namespace (pid, tid) | ||
| && ( have_sub_uids(name, ruid, 1) | ||
| || have_sub_uids(name, euid, 1) | ||
| || have_sub_uids(name, suid, 1)) | ||
|
|
@@ -225,7 +225,7 @@ static int user_busy_processes (const char *name, uid_t uid) | |
| continue; | ||
| } | ||
|
|
||
| if (check_status (name, tmp_d_name, uid) != 0) { | ||
| if (check_status (name, uid, pid, pid) != 0) { | ||
| (void) closedir (proc); | ||
| #ifdef ENABLE_SUBIDS | ||
| sub_uid_close(true); | ||
|
|
@@ -247,7 +247,7 @@ static int user_busy_processes (const char *name, uid_t uid) | |
| if (tid == pid) { | ||
| continue; | ||
| } | ||
| if (check_status (name, task_path+6, uid) != 0) { | ||
| if (check_status (name, uid, pid, tid) != 0) { | ||
| (void) closedir (proc); | ||
| (void) closedir (task_dir); | ||
| #ifdef ENABLE_SUBIDS | ||
|
|
@@ -272,4 +272,3 @@ static int user_busy_processes (const char *name, uid_t uid) | |
| return 0; | ||
| } | ||
| #endif /* __linux__ */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.