Skip to content

Commit 1e870a9

Browse files
fweimer-rhsfrothwell
authored andcommitted
procfs: do not list TID 0 in /proc/<pid>/task
If a task exits concurrently, task_pid_nr_ns may return 0. Link: https://lkml.kernel.org/r/8735pn5dx7.fsf@oldenburg.str.redhat.com Signed-off-by: Florian Weimer <fweimer@redhat.com> Acked-by: Christian Brauner <christian.brauner@ubuntu.com> Cc: Kees Cook <keescook@chromium.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
1 parent b7f8bb3 commit 1e870a9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/proc/base.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3800,6 +3800,9 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx)
38003800
char name[10 + 1];
38013801
unsigned int len;
38023802
tid = task_pid_nr_ns(task, ns);
3803+
if (!tid)
3804+
/* The task has just exited. */
3805+
continue;
38033806
len = snprintf(name, sizeof(name), "%u", tid);
38043807
if (!proc_fill_cache(file, ctx, name, len,
38053808
proc_task_instantiate, task, NULL)) {

0 commit comments

Comments
 (0)