From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796095589; b=Lu+A1Y/ZcFZn6COCpjm9TuIOoEXroaqMARqPWs813XiekkAbLfGZ54WAtw6TfcKl72o1 jmLga4G45znLeozqIdSJQQnrq/8v7PCHOFROE3/2S4OPXbHOTABHozc2LYHY3aOond3EU iBJ/AWZkIZE1ARprpTWN9ZLlshDwwe9xlJO7orMinuBPnRH5yK8Qipew1RRx8z3kj6VBs q3D/QJdrkx2gzCAvqOZULuHFuevV14LFQOF7wnsNQS/4EmnpoSVXZe47W92SfdaGCELq0 nkLz618CzIraK7Y/Zn3D2XgNEZQQ/Cda1/jkZfO0qDACto2Qy3JyIQd4PSVai0fiSew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796095589; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=E0scMMTFf3cEAJCLXJ2LDAtU+DW460lJlZpIsPvZfDs=; b=A+9Gt9Rl5zlC0OZL5C/J0L2f53vExkcHTF/Erlx/frzRkzEgTyET0v4Jkw8mYZSczn4G gGgnJRrpRSxCSoieXlJ7X+F9tl0HxJgJq/gdvd+RDqEUfQnXDoKDKLRkAuX7MI+gj1FDU 4XR3Ios8jur8bEeyJrELuisA4RFOAG44+aRNpQkt8Tj3mVy+n0H3Uoflb2ixg0pZHu42k yyIUeE5f4DCJ+8a5RoxRNJ3/am81ypKaHsXzA5oofnhFdYnx2Qoou/4HYfz1DGICeBe4I mobg/D+NrgJgSvtnscpRqniSUWkgbae4G3AZzycbONKoIi9sf8bZqA2T6C0cvT0AHYw== 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=fcfHjjyy; 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 00A25606A33B; Tue, 1 Dec 2026 03:26:28 +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=fcfHjjyy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51B861F000C1; Tue, 1 Dec 2026 03:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796095588; bh=E0scMMTFf3cEAJCLXJ2LDAtU+DW460lJlZpIsPvZfDs=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=fcfHjjyyHIAIoCzdROcnsbNssv7+zLnmaZt+94KXfW608HRc9ozSlh8mS3ffnTl2C 3AvHdPk1kVUyUoPSwOaBi+K/Dd3g1CELTEsIZrYQt0WzL0D7boLI45lZyRpzNikOdn /SfGWuIRwiN93z+Hb/PSs6AV8iS2vyA3/ENRBVbXMPuFtXbuVoWhftjodAyxHbKqX1 gGpcvzoPStCiQc3gviPa0WU2nxFZ87a4sWMz0ya7Hej+7y+6zDIAKi9afVuoAt0S70 3EYi+F2JZ4zMD0V276Y0/Jm8djqFEnUWubvi3W+E8IVjx9VnLJUVz81Aq6qqTh/sxi +gGZIb25zXuYw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v9 22/29] ipc/mqueue: Implement ->set_nsexec() fs_context operation 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: <20261201031002.593830-23-jarkko@kernel.org> References: <20261201031002.593830-1-jarkko@kernel.org> <20261201031002.593830-23-jarkko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 03:26:24 +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 1 potential issue to consider: - [Critical] ipc/mqueue: unlocked s_fs_info access in mqueue_init_fs_context() -- commit 067998e02a49b9e15984753bd84467279b66c72f Author: Jarkko Sakkinen ipc/mqueue: Implement ->set_nsexec() fs_context operation This commit implements the ->set_nsexec() fs_context operation for mqueue so that FSCONFIG_SET_NSEXEC binds the mount context to the target nsexec's IPC and user namespaces, and marks mqueue with FS_NSEXEC_MOUNT. > diff --git a/ipc/mqueue.c b/ipc/mqueue.c > index 322c3dd98c447..026462d9b40f9 100644 > --- a/ipc/mqueue.c > +++ b/ipc/mqueue.c [ ... ] > @@ -453,9 +468,13 @@ static int mqueue_init_fs_context(struct fs_context = *fc) > if (!ctx) > return -ENOMEM; > =20 > - ctx->ipc_ns =3D get_ipc_ns(current->nsproxy->ipc_ns); > - put_user_ns(fc->user_ns); > - fc->user_ns =3D get_user_ns(ctx->ipc_ns->user_ns); > + if (fc->purpose =3D=3D FS_CONTEXT_FOR_RECONFIGURE) { > + ctx->ipc_ns =3D get_ipc_ns(fc->root->d_sb->s_fs_info); [Severity: Critical] Can this race with put_ipc_ns() and cause a use-after-free on struct ipc_namespace? An mqueue superblock does not hold a reference to the ipc_namespace in sb->s_fs_info; instead, put_ipc_ns() drops the last reference and clears sb->s_fs_info under mq_lock (which is why get_ns_from_inode() takes mq_lock around get_ipc_ns(inode->i_sb->s_fs_info)). Without mq_lock, a reconfiguration context created via fspick() can read s_fs_info as the last reference is dropped: CPU0 CPU1 mqueue_init_fs_context() put_ipc_ns(ns) ns =3D fc->root->d_sb->s_fs_info ns_ref_put_and_lock(ns, &mq_lock) mq_clear_sbinfo(ns) spin_unlock(&mq_lock) schedule_work(&free_ipc_work) get_ipc_ns(ns) <-- refcount inc on 0 free_ipc() free_ipc_ns(ns) <-- frees ns mqueue_fs_context_free() put_ipc_ns(ctx->ipc_ns) <-- use-after-free Acquiring ctx->ipc_ns under spin_lock(&mq_lock) (or leaving ctx->ipc_ns as NULL for FS_CONTEXT_FOR_RECONFIGURE, since mqueue does not use it during reconfiguration) would avoid this race. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201031002.5938= 30-1-jarkko@kernel.org?part=3D22