Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796442592; b=LrPvB/F4LCyUMzMj9QcgKq3oELONhYFcxZHA3jgH1u0WnLVXG/plrPdEBRtTbMjdrUb8 bnh/gpE44OytnBsI/06UpzNV0jDgwtj02TrOY+F1YthuR1lZrh7eDRI8FyYGcvmjT6RMy b3owFm/T+SGuxdIYGUVdE46G3LiNryF8g9w02HeO4yXrUKgzsvdi1Y9K6R60fZrKvzwn0 hExUkdXEa7X0UHmiauqKzPhf6m+DU+sFXKg4qMJoXy5W13LqJoMybruzLMHQRoZmpAdUe n+KPK13BFpmNb8J//uRZSsrxpV99ETC3IML6cP/epbb1rPDklaXvM7UlEIDhRFnqOdQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796442592; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=vqtZMdmCW34Yr4ETwgRie8U25niroxDo598eKLuPSo8=; b=XcgEm8q6QxBr/dfxpVvH62qnWP5xXYFhdsQfLMHQdmxOgvTW3srgw1KyjXAbRNaxAZoK PMArIVc9CsOsrElqJj3PT/rcPcNAmbH64gz58KoiV03UuCwpUJJCb1a7C8XcjywQZP61V /q4/VNy4BOk4m9I0Wv7Lh5HD9nSRZxMZh9vryJ0XLaptCZ0xGCjrdm7O0/TbVDo5nWe4H XHDzoK8rzie10wj514ZjqWdVfLq6HVk+zMS/iUKzRuJhkRSf5v+Ls4c3gPKQBYXo56Woz rbjcxbfwKoQEX7q93FQRNYoJXDwN61ayMA7S35D0vOV7ukA/RtzI6OMautRItKo7fkg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hu5vJWJf; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FCB4606A322; Sat, 5 Dec 2026 03:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hu5vJWJf Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDC5B1F0092B; Sat, 5 Dec 2026 03:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796442591; bh=vqtZMdmCW34Yr4ETwgRie8U25niroxDo598eKLuPSo8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Hu5vJWJfA0f4NEHhu25pwfvWJeUotYh6R5kehYet8qy5BEJgkztI6D8Bxc3lbNyci AW/C1OVi8hJWX7exv2IP/WfxnveRmC6OLH/uW/X5g5p1VI2aYO73Ye3fTyf/H0mmDI me1gEJikUa/g71vrblLQ/wWrq93v4S6+d0dHe5wfRDYOnnZinC9gqy2Xg0OTf6OllE ECeFayGcpZzMeSkwKzaF+0L/VyMmJsuZN4OXyIMNKYmz9LdfI3l6ZcCXzahcrEYGlO 8NncBMWgQe2+AG5/WP7V9DrFd8Pl68+YQ4//AbYcFWty0n7xxHFKKE/b5hNvk65Tps zXHxc8Fl6/D0A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v10 16/28] exit: Support P_RUNFD in waitid() Reply-To: sashiko-reviews@lists.linux.dev To: "Jarkko Sakkinen" Cc: bpf@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, "Aleksa Sarai" , "Alexander Mikhalitsyn" , "Alexander Viro" , "Alexei Starovoitov" , "Andrew Morton" , "Andrii Nakryiko" , "Andy Lutomirski" , "Arnd Bergmann" , "Baolin Wang" , "Ben Segall" , "Christian Brauner" , "Daniel Borkmann" , "David Hildenbrand" , "David Howells" , "David Woodhouse" , "Davidlohr Bueso" , "Dietmar Eggemann" , "Eduard Zingerman" , "Emil Tsalapatis" , "Eric Biggers" , "Georgia Garcia" , "Giuseppe Scrivano" , =?utf-8?b?R8O8bnRoZXIgTm9hY2s=?= , "Hugh Dickins" , "Ihor Solodrai" , "Ingo Molnar" , "James Morris" , "Jan Kara" , "Jason Gunthorpe" , "Jeff Layton" , "Jiri Olsa" , "John Johansen" , "Jonathan Corbet" , "Josef Bacik" , "Juri Lelli" , "Kees Cook" , "K Prateek Nayak" , "KP Singh" , "Kumar Kartikeya Dwivedi" , "Lennart Poettering" , "Liam R. Howlett" , "Manfred Spraul" , "Martin KaFai Lau" , "Matt Bobrowski" , "Mel Gorman" , "Michal Hocko" , =?utf-8?b?TWlja2HDq2wgU2FsYcO8bg==?= , "Mike Rapoport" , "Neal Gompa" , "Oleg Nesterov" , "Paul Moore" , "Pavel Tikhomirov" , "Peter Zijlstra" , "Randy Dunlap" , "Serge E. Hallyn" , "Serge Hallyn" , "Shuah Khan" , "Song Liu" , "Stephen Smalley" , "Steven Rostedt" , "Valentin Schneider" , "Vincent Guittot" , "Yonghong Song" , "Zygmunt Krynicki" In-Reply-To: <20261205032633.1702772-17-jarkko@kernel.org> References: <20261205032633.1702772-1-jarkko@kernel.org> <20261205032633.1702772-17-jarkko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 03:49:48 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] runfd: holding fd across sleep in runfd_waitid() deadlocks RUNFD_AUTOKILL - [Medium] runfd: runfd_waitid() reports init exit before exit_notify() marks EXIT_ZOMBIE - [Medium] exit: P_RUNFD overloads waitid() with incompatible non-reaping semantics -- commit 15632c2dfe3c410c65fda9accd679b46cb9430e0 Author: Jarkko Sakkinen exit: Support P_RUNFD in waitid() This commit adds a P_RUNFD idtype to waitid() and routes it from kernel_waitid() to runfd_waitid(), which waits until a run reaches RUNFD_DEAD and reports init's PID, UID, and exit status without consuming it. > diff --git a/include/uapi/linux/wait.h b/include/uapi/linux/wait.h > index 85b809fc9f118..fc36f4e12d6e9 100644 > --- a/include/uapi/linux/wait.h > +++ b/include/uapi/linux/wait.h > @@ -18,6 +18,7 @@ > #define P_PID 1 > #define P_PGID 2 > #define P_PIDFD 3 > +#define P_RUNFD 4 [Severity: Medium] Does exposing P_RUNFD as a waitid() idtype lock in semantics that conflict with the rest of waitid()? Every other P_* idtype reaps the zombie and consumes its exit status when WEXITED is passed without WNOWAIT. runfd_waitid() accepts WNOWAIT in the option mask but never checks it, so WEXITED silently behaves as WNOWAIT and leaves init unreaped for its parent. Because kernel_waitid() short-circuits P_RUNFD before kernel_waitid_prepare(), IORING_OP_WAITID in io_uring/waitid.c fails with -EINVAL for P_RUNFD. runfd_waitid() also rejects non-NULL rusage and standard options (WSTOPPED, WCONTINUED, __WALL, __WCLONE, __WNOTHREAD). An extensible RUNFD_GET_INFO ioctl paired with the existing runfd_poll() EPOLLHUP notification (matching PIDFD_GET_INFO with PIDFD_INFO_EXIT) would provide repeatable, non-reaping exit status without adding a non-conforming idtype to waitid(). > diff --git a/kernel/runfd.c b/kernel/runfd.c > index 45e5709dbc0e3..52a07a1087051 100644 > --- a/kernel/runfd.c > +++ b/kernel/runfd.c [ ... ] > + CLASS(fd, f)(upid); > + if (fd_empty(f) || !runfd_is_file(fd_file(f))) > + return -EBADF; > + > + f_flags =3D READ_ONCE(fd_file(f)->f_flags); > + nonblock =3D (options & WNOHANG) || (f_flags & O_NONBLOCK); > + run =3D fd_file(f)->private_data; [Severity: Medium] Can holding CLASS(fd, f) across wait_event_freezable() deadlock RUNFD_AUTOKILL in a multi-threaded process? When files->count > 1, fdget() increments file->f_ref and CLASS(fd, f) keeps that reference pinned until runfd_waitid() returns, even though f is unused after reading f_flags and private_data. If another thread closes the last userspace run_fd while this thread is blocked in wait_event_freezable(), file->f_ref stays non-zero, runfd_release() never runs, RUNFD_AUTOKILL never sends SIGKILL to init, and runfd_waitid() blocks indefinitely. Taking a reference on struct run (refcount_inc(&run->usage) paired with runfd_put(run)) and dropping CLASS(fd, f) before the wait loop, as pidfd_get_pid() does for P_PIDFD, avoids pinning the file across sleep. [ ... ] > + if (state =3D=3D RUNFD_DEAD) { > + ret =3D pid_nr_ns(run->init_pid, pid_ns); > + if (ret <=3D 0) > + return -ECHILD; > + status =3D run->exit_code; > + uid =3D run->init_uid; > + } [Severity: Medium] Can runfd_waitid() report init as exited before exit_notify() marks it EXIT_ZOMBIE? zap_pid_ns_processes() calls runfd_exit() while find_child_reaper() has dropped tasklist_lock and before exit_notify() sets tsk->exit_state =3D EXIT_ZOMBIE: CPU0 CPU1 exit_notify() forget_original_parent() find_child_reaper() write_unlock_irq(&tasklist_lock) zap_pid_ns_processes() runfd_exit() run->state =3D RUNFD_DEAD __wake_up(&c->waitq, ...) runfd_waitid() return init pid & status waitpid(si_pid, ..., WNOHANG) exit_state =3D=3D 0 <-- returns 0 write_lock_irq(&tasklist_lock) tsk->exit_state =3D EXIT_ZOMBIE Because waitid(P_RUNFD) does not reap init, a parent that immediately calls waitpid(si_pid, ..., WNOHANG) after waitid(P_RUNFD) returns can race with this window, observe exit_state =3D=3D 0, and get 0 instead of reaping the child. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205032633.1702= 772-1-jarkko@kernel.org?part=3D16