[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bmkl6ii7y7fbkzndiukfuxpgsysli6552zzg2fsax4xqhgms73@wk7sfbp6hqyl>
Date: Mon, 15 Sep 2025 15:28:31 +0200
From: Jan Kara <jack@...e.cz>
To: Christian Brauner <brauner@...nel.org>
Cc: Jan Kara <jack@...e.cz>, Amir Goldstein <amir73il@...il.com>,
linux-fsdevel@...r.kernel.org, Josef Bacik <josef@...icpanda.com>,
Jeff Layton <jlayton@...nel.org>, Mike Yuan <me@...dnzj.com>,
Zbigniew Jędrzejewski-Szmek <zbyszek@...waw.pl>, Lennart Poettering <mzxreary@...inter.de>,
Daan De Meyer <daan.j.demeyer@...il.com>, Aleksa Sarai <cyphar@...har.com>,
Alexander Viro <viro@...iv.linux.org.uk>, Jens Axboe <axboe@...nel.dk>, Tejun Heo <tj@...nel.org>,
Johannes Weiner <hannes@...xchg.org>, Michal Koutný <mkoutny@...e.com>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Chuck Lever <chuck.lever@...cle.com>, linux-nfs@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org, cgroups@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH v2 30/33] nsfs: add missing id retrieval support
On Fri 12-09-25 13:52:53, Christian Brauner wrote:
> The mount namespace has supported id retrieval for a while already.
> Add support for the other types as well.
>
> Signed-off-by: Christian Brauner <brauner@...nel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
Honza
> ---
> fs/nsfs.c | 25 +++++++++++++------------
> include/uapi/linux/nsfs.h | 6 ++++--
> 2 files changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/fs/nsfs.c b/fs/nsfs.c
> index 22765fcab18e..8484bc4dd3de 100644
> --- a/fs/nsfs.c
> +++ b/fs/nsfs.c
> @@ -177,6 +177,7 @@ static bool nsfs_ioctl_valid(unsigned int cmd)
> case NS_GET_TGID_FROM_PIDNS:
> case NS_GET_PID_IN_PIDNS:
> case NS_GET_TGID_IN_PIDNS:
> + case NS_GET_ID:
> return true;
> }
>
> @@ -226,18 +227,6 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
> argp = (uid_t __user *) arg;
> uid = from_kuid_munged(current_user_ns(), user_ns->owner);
> return put_user(uid, argp);
> - case NS_GET_MNTNS_ID: {
> - __u64 __user *idp;
> - __u64 id;
> -
> - if (ns->ops->type != CLONE_NEWNS)
> - return -EINVAL;
> -
> - mnt_ns = container_of(ns, struct mnt_namespace, ns);
> - idp = (__u64 __user *)arg;
> - id = mnt_ns->ns.ns_id;
> - return put_user(id, idp);
> - }
> case NS_GET_PID_FROM_PIDNS:
> fallthrough;
> case NS_GET_TGID_FROM_PIDNS:
> @@ -283,6 +272,18 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
> ret = -ESRCH;
> return ret;
> }
> + case NS_GET_MNTNS_ID:
> + if (ns->ops->type != CLONE_NEWNS)
> + return -EINVAL;
> + fallthrough;
> + case NS_GET_ID: {
> + __u64 __user *idp;
> + __u64 id;
> +
> + idp = (__u64 __user *)arg;
> + id = ns->ns_id;
> + return put_user(id, idp);
> + }
> }
>
> /* extensible ioctls */
> diff --git a/include/uapi/linux/nsfs.h b/include/uapi/linux/nsfs.h
> index fa86fe3c8bd3..5d5bf22464c9 100644
> --- a/include/uapi/linux/nsfs.h
> +++ b/include/uapi/linux/nsfs.h
> @@ -16,8 +16,6 @@
> #define NS_GET_NSTYPE _IO(NSIO, 0x3)
> /* Get owner UID (in the caller's user namespace) for a user namespace */
> #define NS_GET_OWNER_UID _IO(NSIO, 0x4)
> -/* Get the id for a mount namespace */
> -#define NS_GET_MNTNS_ID _IOR(NSIO, 0x5, __u64)
> /* Translate pid from target pid namespace into the caller's pid namespace. */
> #define NS_GET_PID_FROM_PIDNS _IOR(NSIO, 0x6, int)
> /* Return thread-group leader id of pid in the callers pid namespace. */
> @@ -42,6 +40,10 @@ struct mnt_ns_info {
> /* Get previous namespace. */
> #define NS_MNT_GET_PREV _IOR(NSIO, 12, struct mnt_ns_info)
>
> +/* Retrieve namespace identifiers. */
> +#define NS_GET_MNTNS_ID _IOR(NSIO, 5, __u64)
> +#define NS_GET_ID _IOR(NSIO, 13, __u64)
> +
> enum init_ns_ino {
> IPC_NS_INIT_INO = 0xEFFFFFFFU,
> UTS_NS_INIT_INO = 0xEFFFFFFEU,
>
> --
> 2.47.3
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists