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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240319130716.vne4nhb3mbwtabfb@joelS2.panther.com>
Date: Tue, 19 Mar 2024 14:07:16 +0100
From: Joel Granados <j.granados@...sung.com>
To: Thomas Weißschuh <linux@...ssschuh.net>
CC: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
	<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
	<pabeni@...hat.com>, Dmitry Torokhov <dmitry.torokhov@...il.com>, "Eric W.
 Biederman" <ebiederm@...ssion.com>, <netdev@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, Luis Chamberlain <mcgrof@...nel.org>
Subject: Re: [PATCH] net: always initialize sysctl ownership

On Fri, Mar 15, 2024 at 05:20:31PM +0100, Thomas Weißschuh wrote:
> The sysctl core does not initialize these fields when the set_ownership
> callback is present.
This is a bit ambiguous as these values get set in the new_inode(sb)
call. What is really happening is that the GLOBAL_ROOT_[U|G]ID is not
getting the correct default.

> So always do it in the callback.
> 
> Fixes: e79c6a4fc923 ("net: make net namespace sysctls belong to container's owner")
I think this is incorrect and here is why:
1. At the point of committing this code, the default behavior was
   dictated by the new_inode call. Which calculated the value from
   super_block *sb. This was Aug 10 2016 (approx).
2. The issue comes when a new default behavior is added by setting
   GLOBAL_ROOT_[U|G]ID in 5ec27ec735ba0 ("fs/proc/proc_sysctl.c: fix the
   default values of i_uid/i_gid on /proc/sys inodes"). This commit was
   in 2019 and missed adjusting net_ctl_set_ownership.

> Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
> ---
>  net/sysctl_net.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/net/sysctl_net.c b/net/sysctl_net.c
> index 051ed5f6fc93..03e320ddacc9 100644
> --- a/net/sysctl_net.c
> +++ b/net/sysctl_net.c
> @@ -62,12 +62,10 @@ static void net_ctl_set_ownership(struct ctl_table_header *head,
>  	kgid_t ns_root_gid;
>  
>  	ns_root_uid = make_kuid(net->user_ns, 0);
> -	if (uid_valid(ns_root_uid))
> -		*uid = ns_root_uid;
> +	*uid = uid_valid(ns_root_uid) ? ns_root_uid : GLOBAL_ROOT_UID;
>  
>  	ns_root_gid = make_kgid(net->user_ns, 0);
> -	if (gid_valid(ns_root_gid))
> -		*gid = ns_root_gid;
> +	*gid = gid_valid(ns_root_gid) ? ns_root_gid : GLOBAL_ROOT_GID;
>  }
>  
>  static struct ctl_table_root net_sysctl_root = {
> 
> ---
> base-commit: e5eb28f6d1afebed4bb7d740a797d0390bd3a357
> change-id: 20240315-sysctl-net-ownership-bc4e17eaeea6
> 
> Best regards,
> -- 
> Thomas Weißschuh <linux@...ssschuh.net>
> 

-- 

Joel Granados

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ