[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210803103445.GB607784@www>
Date: Tue, 3 Aug 2021 03:34:45 -0700
From: CGEL <cgel.zte@...il.com>
To: Davidlohr Bueso <dbueso@...e.de>
Cc: keescook@...omium.org, christian.brauner@...ntu.com,
ktkhai@...tuozzo.com, jamorris@...ux.microsoft.com,
varad.gautam@...e.com, legion@...nel.org,
linux-kernel@...r.kernel.org, Ran Xiaokai <ran.xiaokai@....com.cn>
Subject: Re: [PATCH] ipc: add set_ownership() and permissions() callbacks for
posix mqueue sysctl
O Fri, Jul 30, 2021 at 08:09:32AM -0700, Davidlohr Bueso wrote:
> On 2021-07-28 20:06, cgel.zte@...il.com wrote:
> > This patch adds a ctl_table_set per ipc namespace, and also the
> > set_ownership() and permissions() callbacks for the new ctl_table_root
> > for ipc mqueue syscgtls.
> ^^ sysctls
>
> This makes sense to me, just some nits below.
>
> Acked-by: Davidlohr Bueso <dbueso@...e.de>
>
> >
> > Signed-off-by: Ran Xiaokai <ran.xiaokai@....com.cn>
> > ---
> ...
> > +static int set_permissions(struct ctl_table_header *head,
> > + struct ctl_table *table)
> > +{
>
> Please use curly braces for the else.
>
> > + return (mode << 6) | (mode << 3) | mode;
> > +}
> > +
> > +static void set_ownership(struct ctl_table_header *head,
> > + struct ctl_table *table,
> > + kuid_t *uid, kgid_t *gid)
> > +{
> > + struct ipc_namespace *ipc_ns =
> > + container_of(head->set, struct ipc_namespace, mq_set);
> > + struct user_namespace *user_ns = ipc_ns->user_ns;
> > + kuid_t ns_root_uid;
> > + kgid_t ns_root_gid;
> > +
> > + ns_root_uid = make_kuid(user_ns, 0);
> > + if (uid_valid(ns_root_uid))
> > + *uid = ns_root_uid;
> > +
> > + ns_root_gid = make_kgid(user_ns, 0);
> > + if (gid_valid(ns_root_gid))
> > + *gid = ns_root_gid;
> > +}
>
> Could set_permissions() and set_ownership() be factored such that we can
> avoid duplicated code between ipc and net ns? Something like:
>
> void set_permissions(struct ctl_table_header *head, struct ctl_table *table)
> {
> struct ipc_namespace *ipc_ns = container_of(head->set, struct
> ipc_namespace, mq_set);
> set_permissions_common(ipc_ns->user_ns);
> }
>
> Thanks,
> Davidlohr
Hi Davidlohr
Thanks for your comments.
I will sent a v2 patch together with Christian's comments.
Powered by blists - more mailing lists