Re: [PATCH v4 2/4] pidfd: add CLONE_PIDFD_AUTOKILL
From: Oleg Nesterov
Date: Mon Feb 23 2026 - 10:50:05 EST
On 02/23, Christian Brauner wrote:
>
> @@ -2259,13 +2268,20 @@ __latent_entropy struct task_struct *copy_process(
> * if the fd table isn't shared).
> */
> if (clone_flags & CLONE_PIDFD) {
> - int flags = (clone_flags & CLONE_THREAD) ? PIDFD_THREAD : 0;
> + unsigned flags = PIDFD_STALE;
> +
> + if (clone_flags & CLONE_THREAD)
> + flags |= PIDFD_THREAD;
> + if (clone_flags & CLONE_PIDFD_AUTOKILL) {
> + task_set_no_new_privs(p);
> + flags |= PIDFD_AUTOKILL;
> + }
>
> /*
> * Note that no task has been attached to @pid yet indicate
> * that via CLONE_PIDFD.
> */
> - retval = pidfd_prepare(pid, flags | PIDFD_STALE, &pidfile);
> + retval = pidfd_prepare(pid, flags, &pidfile);
Confused... I think you also need to change pidfs_alloc_file() to restore
O_TRUNC after do_dentry_open() clears this flag? Just like it curently does
pidfd_file->f_flags |= (flags & PIDFD_THREAD);
?
Oleg.