From nobody Thu Apr 2 22:06:52 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEEA4354AC7; Fri, 13 Feb 2026 10:44:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770979492; cv=none; b=qQBrxC2mxoEQVcj3aRoIWZHrYQNayrKi31ndNhhH5WFKt+UVuDN0ZoFbCWQXzFx7rah0JCLSdaLfvB2B9d7gRQSm8s2JGIgEaAhO03387ITkuDg2HvFYUIcpaGm04JjuU8+N2fmMU8s7s8xVC55m8LtJRf6wS71QjlYjqRuvTN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770979492; c=relaxed/simple; bh=mwQQgljy62m4eK+PIfpSlj2KKV74LnDLIugSpu0zBCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tMXv1W9Y2B1iq4Dj/9uEYsfcL3kwCc1gVuWSCE6SqWSAHckTwM9hJkADHcNAlYKqySNw1I2NBI474h1LRizrtXTYx/jjqJldhqmxn7CV0FHWkStynDTZBNQCeRx6qbqMA+JcUwYSrYJE6usFCVSDr25YVcm63BfuXwmDT+Hcboo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lJXX14Jp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lJXX14Jp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2834C116C6; Fri, 13 Feb 2026 10:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770979492; bh=mwQQgljy62m4eK+PIfpSlj2KKV74LnDLIugSpu0zBCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJXX14JpR2+HCi4NfMunPJR3uZsaaWcbWnb3XCOYGVyW5Y9XhA8fH1GyeoM1TQMqO Z1imj/2oJjlA4wqxRniPMX335Vi79Neh8WCh7v9yk3ceM5OU5d25uQdEArMdBcGT/E DLkg98UFuLqVXZvJRioKUa09CxBBJNzZH7u2+uA+Zl9WtrKzQmZi65F5I4/i3NNff/ dnotyaNDtjRFqmULVR2sWHwRfUJ/t4eRWkT5Kz7XcbBX+P5PHVVnp4JRzwSk4g07CK fEWs7kkGppVKfCVTebaNV2qzzbVtkRZWGtAcZtiA5jKfZLt9Jn9v/Uj5/wtF0pUvVv jJYDlzjvMiCCg== From: Alexey Gladkov To: Christian Brauner , Dan Klishch Cc: Al Viro , "Eric W . Biederman" , Kees Cook , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 3/5] proc: Disable cancellation of subset=pid option Date: Fri, 13 Feb 2026 11:44:28 +0100 Message-ID: <774be6da2605e432d08009a75db292067d6f0030.1770979341.git.legion@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When procfs is mounted with subset=3Dpid option, where is no way to remount it with this option removed. This is done in order not to make visible what ever was hidden since some checks occur during mount. This patch makes the limitation explicit and prints an error message. Signed-off-by: Alexey Gladkov --- fs/proc/root.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/proc/root.c b/fs/proc/root.c index c4af3a9b1a44..535a168046e3 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -223,7 +223,7 @@ static int proc_parse_param(struct fs_context *fc, stru= ct fs_parameter *param) return 0; } =20 -static void proc_apply_options(struct proc_fs_info *fs_info, +static int proc_apply_options(struct proc_fs_info *fs_info, struct fs_context *fc, struct user_namespace *user_ns) { @@ -233,13 +233,17 @@ static void proc_apply_options(struct proc_fs_info *f= s_info, fs_info->pid_gid =3D make_kgid(user_ns, ctx->gid); if (ctx->mask & (1 << Opt_hidepid)) fs_info->hide_pid =3D ctx->hidepid; - if (ctx->mask & (1 << Opt_subset)) + if (ctx->mask & (1 << Opt_subset)) { + if (ctx->pidonly !=3D PROC_PIDONLY_ON && fs_info->pidonly =3D=3D PROC_PI= DONLY_ON) + return invalf(fc, "proc: subset=3Dpid cannot be unset\n"); fs_info->pidonly =3D ctx->pidonly; + } if (ctx->mask & (1 << Opt_pidns) && !WARN_ON_ONCE(fc->purpose =3D=3D FS_CONTEXT_FOR_RECONFIGURE)) { put_pid_ns(fs_info->pid_ns); fs_info->pid_ns =3D get_pid_ns(ctx->pid_ns); } + return 0; } =20 static int proc_fill_super(struct super_block *s, struct fs_context *fc) @@ -255,7 +259,9 @@ static int proc_fill_super(struct super_block *s, struc= t fs_context *fc) =20 fs_info->pid_ns =3D get_pid_ns(ctx->pid_ns); fs_info->mounter_cred =3D get_cred(fc->cred); - proc_apply_options(fs_info, fc, current_user_ns()); + ret =3D proc_apply_options(fs_info, fc, current_user_ns()); + if (ret) + return ret; =20 /* User space would break if executables or devices appear on proc */ s->s_iflags |=3D SB_I_USERNS_VISIBLE | SB_I_NOEXEC | SB_I_NODEV; @@ -304,8 +310,7 @@ static int proc_reconfigure(struct fs_context *fc) =20 sync_filesystem(sb); =20 - proc_apply_options(fs_info, fc, current_user_ns()); - return 0; + return proc_apply_options(fs_info, fc, current_user_ns()); } =20 static int proc_get_tree(struct fs_context *fc) --=20 2.53.0