From: Alexander Mikhalitsyn <alex@amutable.com>
To: Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org
Cc: linux-security-module@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jan Kara <jack@suse.cz>,
bpf@vger.kernel.org, Zhiqi Zhang <zhiqizhangg@gmail.com>
Subject: Re: [PATCH 1/2] mount: pass flags to alloc_mnt_ns()
Date: Fri, 20 Nov 2026 15:02:37 +0100 [thread overview]
Message-ID: <a999a6a9f593638228c93f90aec7425a0c6a8215.camel@amutable.com> (raw)
In-Reply-To: <20261120-work-ns-mount_subtree-v1-1-06337377f94a@kernel.org>
On Fri, 2026-11-20 at 13:29 +0100, Christian Brauner wrote:
> Turn the anon argument of alloc_mnt_ns() into a flags argument. The
> next patch needs to pass another property of the new mount namespace
> and two booleans in a row would make the callers unreadable.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Reviewed-by: Alexander Mikhalitsyn <alex@amutable.com>
> ---
> fs/namespace.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index aecd05ac01705..756f9011cbf1d 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2353,7 +2353,12 @@ void drop_collected_paths(const struct path
> *paths, const struct path *prealloc)
> kfree(paths);
> }
>
> -static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *,
> bool);
> +enum mnt_ns_flags_t {
> + MNT_NS_ANON = (1 << 0),
> +};
> +
> +static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *,
> + enum mnt_ns_flags_t);
>
> /* Consumes the caller's reference to @mnt. */
> void dissolve_on_fput(struct vfsmount *mnt)
> @@ -3149,7 +3154,7 @@ static struct mnt_namespace
> *get_detached_copy(const struct path *path, unsigned
> struct user_namespace *user_ns = mnt_ns->user_ns;
> struct mount *mnt, *p;
>
> - ns = alloc_mnt_ns(user_ns, true);
> + ns = alloc_mnt_ns(user_ns, MNT_NS_ANON);
> if (IS_ERR(ns))
> return ns;
>
> @@ -3230,7 +3235,7 @@ static struct mnt_namespace
> *create_new_namespace(struct path *path,
> if (foreign)
> copy_flags |= CL_SLAVE | CL_COPY_UNBINDABLE;
>
> - new_ns = alloc_mnt_ns(user_ns, false);
> + new_ns = alloc_mnt_ns(user_ns, 0);
> if (IS_ERR(new_ns))
> return ERR_CAST(new_ns);
>
> @@ -4369,7 +4374,8 @@ static void free_mnt_ns(struct mnt_namespace
> *ns)
> mnt_ns_tree_remove(ns);
> }
>
> -static struct mnt_namespace *alloc_mnt_ns(struct user_namespace
> *user_ns, bool anon)
> +static struct mnt_namespace *alloc_mnt_ns(struct user_namespace
> *user_ns,
> + enum mnt_ns_flags_t flags)
> {
> struct mnt_namespace *new_ns;
> struct ucounts *ucounts;
> @@ -4385,7 +4391,7 @@ static struct mnt_namespace
> *alloc_mnt_ns(struct user_namespace *user_ns, bool a
> return ERR_PTR(-ENOMEM);
> }
>
> - if (anon)
> + if (flags & MNT_NS_ANON)
> ret = ns_common_init_inum(new_ns, MNT_NS_ANON_INO);
> else
> ret = ns_common_init(new_ns);
> @@ -4394,7 +4400,7 @@ static struct mnt_namespace
> *alloc_mnt_ns(struct user_namespace *user_ns, bool a
> dec_mnt_namespaces(ucounts);
> return ERR_PTR(ret);
> }
> - new_ns->is_anon = anon;
> + new_ns->is_anon = flags & MNT_NS_ANON;
> refcount_set(&new_ns->passive, 1);
> new_ns->mounts = RB_ROOT;
> init_waitqueue_head(&new_ns->poll);
> @@ -4422,7 +4428,7 @@ struct mnt_namespace *copy_mnt_ns(u64 flags,
> struct mnt_namespace *ns,
>
> old = ns->root;
>
> - new_ns = alloc_mnt_ns(user_ns, false);
> + new_ns = alloc_mnt_ns(user_ns, 0);
> if (IS_ERR(new_ns))
> return new_ns;
>
> @@ -4509,7 +4515,7 @@ struct dentry *mount_subtree(struct vfsmount
> *m, const char *name)
> struct path path;
> int err;
>
> - ns = alloc_mnt_ns(&init_user_ns, true);
> + ns = alloc_mnt_ns(&init_user_ns, MNT_NS_ANON);
> if (IS_ERR(ns)) {
> mntput(m);
> return ERR_CAST(ns);
> @@ -4699,7 +4705,7 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned
> int, flags,
> return FD_ADD((flags & FSMOUNT_CLOEXEC) ? O_CLOEXEC
> : 0,
> open_new_namespace(&new_path,
> MOUNT_COPY_NEW));
>
> - ns = alloc_mnt_ns(current->nsproxy->mnt_ns->user_ns, true);
> + ns = alloc_mnt_ns(current->nsproxy->mnt_ns->user_ns,
> MNT_NS_ANON);
> if (IS_ERR(ns))
> return PTR_ERR(ns);
> mnt = real_mount(new_path.mnt);
next prev parent reply other threads:[~2026-11-20 14:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:29 [PATCH 0/2] ns: don't call the namespace LSM hooks for kernel-internal namespaces Christian Brauner
2026-11-20 12:29 ` [PATCH 1/2] mount: pass flags to alloc_mnt_ns() Christian Brauner
2026-11-20 12:32 ` sashiko-bot
2026-11-20 14:02 ` Alexander Mikhalitsyn [this message]
2026-11-20 12:29 ` [PATCH 2/2] ns: don't call the namespace LSM hooks for kernel-internal namespaces Christian Brauner
2026-11-20 12:33 ` sashiko-bot
2026-11-20 14:03 ` Alexander Mikhalitsyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a999a6a9f593638228c93f90aec7425a0c6a8215.camel@amutable.com \
--to=alex@amutable.com \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zhiqizhangg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox