Skip to content

pidfd: implement PIDFD_THREAD flag for pidfd_open()

Oleg Nesterov linux-mm lkml llvm oe-kbuild-all oe-lkp 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest1 patch 17 repliesIn review
  2. v21 patch 3 repliesSuperseded
  3. v1 RFC1 patch 13 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1pidfd: implement PIDFD_THREAD flag for pidfd_open()fs/exec.c include/linux/pid.h include/uapi/linux/pidfd.h +4 more+54 -2313 replies

Reviews trailers per patch

The patch has a Reviewed-by or Acked-by.

PatchTycho Andersen
1/1R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/1] pidfd: implement PIDFD_THREAD flag for pidfd_open()

Please see the interdiff below.

Also, I updated the changelog to document that the behaviour of pidfd_poll(PIDFD_THREAD, pid-of-group-leader) is not well defined if a sub-thread execs.

Do you agree with this semantics?

Oleg.
---

fs/exec.c +5 -1
index 73e4045df271..0fd7e668c477 100644
@@ -1143,7 +1143,11 @@ static int de_thread(struct task_struct *tsk)
 
 		BUG_ON(leader->exit_state != EXIT_ZOMBIE);
 		leader->exit_state = EXIT_DEAD;
-
+		/*
+		 * leader and tsk exhanged their pids, the old pid dies,
+		 * wake up the PIDFD_THREAD waiters.
+		 */
+		do_notify_pidfd(leader);
 		/*
 		 * We are going to release_task()->ptrace_unlink() silently,
 		 * the tracer can sleep in do_wait(). EXIT_DEAD guarantees
include/linux/pid.h +2 -1
index e6a041cb8bac..8124d57752b9 100644
@@ -70,10 +70,11 @@ extern const struct file_operations pidfd_fops;
 
 struct file;
 
-extern struct pid *pidfd_pid(const struct file *file);
+struct pid *pidfd_pid(const struct file *file);
 struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags);
 struct task_struct *pidfd_get_task(int pidfd, unsigned int *flags);
 int pidfd_prepare(struct pid *pid, unsigned int flags, struct file **ret);
+void do_notify_pidfd(struct task_struct *task);
 
 static inline struct pid *get_pid(struct pid *pid)
 {
kernel/signal.c +1 -1
index 5f48d2c4b409..9b40109f0c56 100644
@@ -2019,7 +2019,7 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
 	return ret;
 }
 
-static void do_notify_pidfd(struct task_struct *task)
+void do_notify_pidfd(struct task_struct *task)
 {
 	struct pid *pid;