Skip to contentSkip to conversation

procfs: Do not list TID 0 in /proc/<pid>/task

PATCH Applied Florian Weimer 2 participants 2 messages Sep 29, 2021 – Sep 30, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 +3 -0
index 533d5836eb9a..54f29399088f 100644
@@ -3800,6 +3800,9 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx)
 		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)) {
Signature · 1 line
2.31.1