Re: [PATCH] net: always initialize sysctl ownership
From: Paolo Abeni
Date: Tue Mar 19 2024 - 10:48:28 EST
On Fri, 2024-03-15 at 17:39 -0700, Kuniyuki Iwashima wrote:
> on Fri, 15 Mar 2024 17:20:31 +0100 Thomas Weißschuh <linux@xxxxxxxxxxxxxx wrote:
>
> > 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;
> > }
>
> How about setting the default in proc_sys_make_inode() instead ?
> because the default value configured by new_inode() is not
I also think that could be a better option, as the caller is already
providing default values in some cases.
Cheers,
Paolo