From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 170DC606A322 for ; Sat, 5 Dec 2026 03:49:57 +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 kanga.kvack.org (Postfix) id 152436B05BA; Fri, 4 Dec 2026 22:49:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 102216B05BC; Fri, 4 Dec 2026 22:49:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F334B6B05BD; Fri, 4 Dec 2026 22:49:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B5CFD6B05BA for ; Fri, 4 Dec 2026 22:49:54 -0500 (EST) Received: from smtpin05.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 645A5A818E for ; Sat, 5 Dec 2026 03:49:54 +0000 (UTC) X-FDA: 85508550708.05.88E9491 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf17.hostedemail.com (Postfix) with ESMTP id B9C6040007 for ; Sat, 5 Dec 2026 03:49:52 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Hu5vJWJf; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796442592; b=IX2No0GnisWUpiiwjd/Ogz71ynGXF/J6zgHL60oWSgJXEXhGmwm88p3L3p6cRd5AifneE8 78ko2fXK+JoCAeJ6B/xPJMlBZIsAHFKsr7rnkXHwooJlEldvLD6CvkiEKYKaRdVJeeQC4h BLBPr7UwYdIRIXA36Ooh3fED+rZw20s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796442592; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vqtZMdmCW34Yr4ETwgRie8U25niroxDo598eKLuPSo8=; b=dViAimW9+gjkhVuJIkfkcQL+eRDN02y3mnhQ1W/K8WBqaya/E0IZSVO2WbVS19bHrmW77N 31OocJ6VciyFqHrKm8xOy6RFscXf13xNw0sX5lLuUqRHnALxaW/9cQ5HK7AyGAswOE1cHT q9qv7jVVj3m6zhpuV2HJBqtjTMJagS8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Hu5vJWJf; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B1BB845AA3; Sat, 5 Dec 2026 03:49:51 +0000 (UTC) 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-Stat-Signature: ghziyb7fuczwgm7czcft8pqpwagdmt3d X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: B9C6040007 X-HE-Tag: 1796442592-95267 X-HE-Meta: U2FsdGVkX1/J0uFEazXYPtLIso57Fn0J4X5db/dCebw2nNvYaUzPcNntmZnHUrwtU8O2BoTRJ/t5U9lBXa6s67OxK/qZQEggycZqW0fOhylnZrPRswZ0J9teW2zh6FNGIJ8Kf73Pj/E5J4YkZWEyrAmX27L5j6ubagoNX9q65wa6xeh7FfBIevtsMNqourUf+UYqKnbOnyPB2Dr2LnW4LDYbhouapGpSJk/tuIcc5q2af0WeFqG6V1+Bq9hlncLXfcCe+Q9XkxXWe2Tmoe5G0V5m/uCHVDb+w9WIK0IjjpwAW8aXwXWfBJX5kFS/uiLmW8k42GlRpfM6nrSPeiK5SScSo6O0eh6FfyQEJZFPArBFNlUXXQUZpHgGEKVmfou4ooTHL/ahfbyAlUo42KMxNSZI4bcdF4/g/Phg2DdJoqh1OxH0+Z/SZ4TREYXEhMvQRBRfAibI+Y22znjYtJmNLC5i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6CGVMm5yYNMsHmAn55u9L9bfqpCX4YxakRJQpuqRTLrdJL9X5eFJiPHiRY6lcJJuCdKASyeoGMXwWgrC8xvWbjGvDrSVyxc+BiGGf3AXuWEEmYFs+TwAsL6pRXR5x/HqZEn3an+BUaTM5sxGLQxZnaCeqnN2DUR/InP53rlBOeUohuFtt1L27KxUh9Iw5+5jrK9mrQxqVbkaN8sQ0ZvLEvdmf9xPINWLw0HnmWHH1ULlbj1Q4MNjn082KuZGYjnuRn3zmixK+MfbJNPiEVRke8APBaWNr1ImwqRbcVQQVZ4gpVP7T5eFSY9kazBJqoceQEcAjb2oJLoai/Yw2tTlS62GBuEJD7Y+mjx7SMaxtmVyqs2pcKWfZ26gArYVkrmvQZQ== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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