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: <ZYPh4T21-6DAbxq5@archie.me>
Date: Thu, 21 Dec 2023 13:57:37 +0700
From: Bagas Sanjaya <bagasdotme@...il.com>
To: Max Kellermann <max.kellermann@...os.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
	Johannes Weiner <hannes@...xchg.org>, linux-kernel@...r.kernel.org,
	cgroups@...r.kernel.org
Subject: Re: [PATCH v2 2/2] fs/kernfs/dir: obey S_ISGID

On Fri, Dec 08, 2023 at 10:33:10AM +0100, Max Kellermann wrote:
> Handling of S_ISGID is usually done by inode_init_owner() in all other
> filesystems, but kernfs doesn't use that function.  In kernfs, struct
> kernfs_node is the primary data structure, and struct inode is only
> created from it on demand.  Therefore, inode_init_owner() can't be
> used and we need to imitate its behavior.
> 
> S_ISGID support is useful for the cgroup filesystem; it allows
> subtrees managed by an unprivileged process to retain a certain owner
> gid, which then enables sharing access to the subtree with another
> unprivileged process.
> 
> Signed-off-by: Max Kellermann <max.kellermann@...os.com>
> Acked-by: Tejun Heo <tj@...nel.org>
> --
> v1 -> v2: minor coding style fix (comment)
> ---
>  fs/kernfs/dir.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 8b2bd65d70e7..62d39ecf0a46 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -676,6 +676,18 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent,
>  {
>  	struct kernfs_node *kn;
>  
> +	if (parent->mode & S_ISGID) {
> +		/* this code block imitates inode_init_owner() for
> +		 * kernfs
> +		 */
> +
> +		if (parent->iattr)
> +			gid = parent->iattr->ia_gid;
> +
> +		if (flags & KERNFS_DIR)
> +			mode |= S_ISGID;
> +	}
> +
>  	kn = __kernfs_new_node(kernfs_root(parent), parent,
>  			       name, mode, uid, gid, flags);
>  	if (kn) {

No noticeable regressions with this patch applied.

Tested-by: Bagas Sanjaya <bagasdotme@...il.com>

-- 
An old man doll... just what I always wanted! - Clara

Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ