Re: [PATCH v10 5/7] proc: prevent reconfiguring subset=pid

Aleksa Sarai <[email protected]> Tue, 28 Apr 2026 08:31:05 +1000
Newsgroups dev.linux.lists.containers,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
--jwa63nlcnrw6nfdy
Content-Type: text/plain; protected-headers=v1; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [PATCH v10 5/7] proc: prevent reconfiguring subset=pid
MIME-Version: 1.0

On 2026-04-27, Alexey Gladkov <[email protected]> wrote:
> Changing subset=3Dpid on an existing procfs instance is not safe. If a
> full procfs mount has entries hidden by overmounts, switching it to
> subset=3Dpid would hide the top-level procfs entries from lookup and
> readdir while leaving the existing overmounts reachable.
>=20
> Reject attempts to change the subset=3Dpid state during reconfigure before
> applying any other procfs mount options, so a failed reconfigure cannot
> partially update the instance.
>=20
> Signed-off-by: Alexey Gladkov <[email protected]>
> ---
>  fs/proc/root.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>=20
> diff --git a/fs/proc/root.c b/fs/proc/root.c
> index 89e5678129e4..1bf75a4ee146 100644
> --- a/fs/proc/root.c
> +++ b/fs/proc/root.c
> @@ -223,12 +223,17 @@ static int proc_parse_param(struct fs_context *fc, =
struct 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)
>  {
>  	struct proc_fs_context *ctx =3D fc->fs_private;
> =20
> +	if ((ctx->mask & (1 << Opt_subset)) &&
> +	    fc->purpose =3D=3D FS_CONTEXT_FOR_RECONFIGURE &&
> +	    ctx->pidonly !=3D fs_info->pidonly)
> +		return invalf(fc, "proc: subset=3Dpid cannot be changed\n");

Minor nit: Unless I'm missing something, you can just use invalfc here
to auto-add the "proc" prefix (which is what most things do). Also, the
newline is unnecessary and will look odd in mount(8) as nobody else adds
newlines (the fs_context log is not newline-separated).

--=20
Aleksa Sarai
https://www.cyphar.com/

--jwa63nlcnrw6nfdy
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iJEEABYKADkWIQS2TklVsp+j1GPyqQYol/rSt+lEbwUCae/jpRsUgAAAAAAEAA5t
YW51MiwyLjUrMS4xMiwyLDIACgkQKJf60rfpRG9ueQD/c8OctfQuVD97bcrY79DT
iYkB9W/ijHGajiSxTnKsVbkA/2o7sRcN8CH+HnVSgKorJZ0crnAVli/Sndvw4IZr
0jIL
=Ree0
-----END PGP SIGNATURE-----

--jwa63nlcnrw6nfdy--