Skip to contentSkip to conversation

+ procfs-do-not-list-tid-0-in-proc-pid-task.patch added to -mm tree

PATCH In review [email protected] 2 participants 5 messages Sep 29, 2021 – Oct 7, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author tree notice
#0 lore raw

The patch titled
Subject: procfs: do not list TID 0 in /proc/<pid>/task
has been added to the -mm tree. Its filename is
procfs-do-not-list-tid-0-in-proc-pid-task.patch

This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/procfs-do-not-list-tid-0-in-proc-pid-task.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/procfs-do-not-list-tid-0-in-proc-pid-task.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Florian Weimer <[email protected]>
Subject: procfs: do not list TID 0 in /proc/<pid>/task

If a task exits concurrently, task_pid_nr_ns may return 0.

---

 fs/proc/base.c |    3 +++
 1 file changed, 3 insertions(+)
fs/proc/base.c renamed from fs/proc/base.c~procfs-do-not-list-tid-0-in-proc-pid-task +3 -0
@@ -3800,6 +3800,9 @@ static int proc_task_readdir(struct file
 		char name[10 + 1];
 		unsigned int len;
 		tid = task_pid_nr_ns(task, ns);
+		if (!tid)
+			/* The task has just exited. */
+			continue;
 		len = snprintf(name, sizeof(name), "%u", tid);
 		if (!proc_fill_cache(file, ctx, name, len,
 				proc_task_instantiate, task, NULL)) {

_

Patches currently in -mm which might be from [email protected] are

procfs-do-not-list-tid-0-in-proc-pid-task.patch

#1 lore raw

PATCH 1/1 proc: test that /proc/*/task doesn't contain "0"

---

 tools/testing/selftests/proc/.gitignore  |    1 
 tools/testing/selftests/proc/Makefile    |    2 
 tools/testing/selftests/proc/proc-tid0.c |   81 +++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+)
tools/testing/selftests/proc/.gitignore +1 -0
@@ -11,6 +11,7 @@
 /proc-self-syscall
 /proc-self-wchan
 /proc-subset-pid
+/proc-tid0
 /proc-uptime-001
 /proc-uptime-002
 /read
tools/testing/selftests/proc/Makefile +2 -0
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 CFLAGS += -Wall -O2 -Wno-unused-function
 CFLAGS += -D_GNU_SOURCE
+LDFLAGS += -pthread
 
 TEST_GEN_PROGS :=
 TEST_GEN_PROGS += fd-001-lookup
@@ -13,6 +14,7 @@ TEST_GEN_PROGS += proc-self-map-files-002
 TEST_GEN_PROGS += proc-self-syscall
 TEST_GEN_PROGS += proc-self-wchan
 TEST_GEN_PROGS += proc-subset-pid
+TEST_GEN_PROGS += proc-tid0
 TEST_GEN_PROGS += proc-uptime-001
 TEST_GEN_PROGS += proc-uptime-002
 TEST_GEN_PROGS += read

new file mode 100644

tools/testing/selftests/proc/proc-tid0.c new file +81 -0

81 lines not on this page · raw message

#2 lore raw

Re: [PATCH] proc: test that /proc/*/task doesn't contain "0"

On Thu, 7 Oct 2021 21:27:14 +0300 Alexey Dobriyan <[email protected]> wrote:

Could we please have a changelog :(

Why are we doing this?

#3 lore raw

Re: [PATCH] proc: test that /proc/*/task doesn't contain "0"

Quoted 5 lines · Andrew Morton

On Thu, 7 Oct 2021 21:27:14 +0300 Alexey Dobriyan <[email protected]> wrote:

Could we please have a changelog :(

Why are we doing this?

This can be folded into

procfs-do-not-list-tid-0-in-proc-pid-task.patch