lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <oqr6utatstghtjivwscnrrwyyzq7xwnqqw6ylkeyvvv6a4pp3j@ffobmvyqlndm>
Date: Mon, 15 Sep 2025 15:08:02 +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 27/33] nsfs: add current_in_namespace()

On Fri 12-09-25 13:52:50, Christian Brauner wrote:
> Add a helper to easily check whether a given namespace is the caller's
> current namespace. This is currently open-coded in a lot of places.
> Simply switch on the type and compare the results.
> 
> Reviewed-by: Aleksa Sarai <cyphar@...har.com>
> Signed-off-by: Christian Brauner <brauner@...nel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza
> ---
>  include/linux/nsfs.h | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/nsfs.h b/include/linux/nsfs.h
> index fb84aa538091..e5a5fa83d36b 100644
> --- a/include/linux/nsfs.h
> +++ b/include/linux/nsfs.h
> @@ -5,6 +5,8 @@
>  #define _LINUX_NSFS_H
>  
>  #include <linux/ns_common.h>
> +#include <linux/cred.h>
> +#include <linux/pid_namespace.h>
>  
>  struct path;
>  struct task_struct;
> @@ -22,5 +24,17 @@ int ns_get_name(char *buf, size_t size, struct task_struct *task,
>  			const struct proc_ns_operations *ns_ops);
>  void nsfs_init(void);
>  
> -#endif /* _LINUX_NSFS_H */
> +#define __current_namespace_from_type(__ns)				\
> +	_Generic((__ns),						\
> +		struct cgroup_namespace *: current->nsproxy->cgroup_ns,	\
> +		struct ipc_namespace *:    current->nsproxy->ipc_ns,	\
> +		struct net *:              current->nsproxy->net_ns,	\
> +		struct pid_namespace *:    task_active_pid_ns(current),	\
> +		struct mnt_namespace *:    current->nsproxy->mnt_ns,	\
> +		struct time_namespace *:   current->nsproxy->time_ns,	\
> +		struct user_namespace *:   current_user_ns(),		\
> +		struct uts_namespace *:    current->nsproxy->uts_ns)
> +
> +#define current_in_namespace(__ns) (__current_namespace_from_type(__ns) == __ns)
>  
> +#endif /* _LINUX_NSFS_H */
> 
> -- 
> 2.47.3
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ