LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Christian Brauner <christian.brauner@canonical.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, avagin@virtuozzo.com,
	ktkhai@virtuozzo.com, serge@hallyn.com,
	gregkh@linuxfoundation.org
Subject: Re: [PATCH net-next 2/2 v4] netns: restrict uevents
Date: Sun, 29 Apr 2018 11:59:58 +0200	[thread overview]
Message-ID: <20180429095957.GA27296@gmail.com> (raw)
In-Reply-To: <87in8ad4ip.fsf@xmission.com>

On Sat, Apr 28, 2018 at 11:23:58PM -0500, Eric W. Biederman wrote:
> 
> > +	/* fix credentials */
> > +	if (owning_user_ns != &init_user_ns) {
> > +		struct netlink_skb_parms *parms = &NETLINK_CB(skb);
> > +		kuid_t root_uid;
> > +		kgid_t root_gid;
> > +
> > +		/* fix uid */
> > +		root_uid = make_kuid(owning_user_ns, 0);
> > +		if (!uid_valid(root_uid))
> > +			root_uid = GLOBAL_ROOT_UID;
> > +		parms->creds.uid = root_uid;
> > +
> > +		/* fix gid */
> > +		root_gid = make_kgid(owning_user_ns, 0);
> > +		if (!gid_valid(root_gid))
> > +			root_gid = GLOBAL_ROOT_GID;
> > +		parms->creds.gid = root_gid;
> 
> One last nit:

Will add non-functional change and make it a v5 in a few.

Thanks!
Christian

> 
> 	You can only make the assignment if the uid is valid.
>         Leaving it GLBOAL_ROOT_UID if the composed uid is invalid.
>         AKA
> 
> 		/* fix uid */
> 		root_uid = make_kuid(owning_user_ns, 0);
> 		if (uid_valid(root_uid))
>                 	parms->creds.uid = root_uid;
> 
>                 /* fix gid */
> 		root_gid = make_kgid(owning_user_ns, 0);
>                 if (gid_valid(root_gid))
>                 	params->creds.gid = root_gid;
> 
> 
> One line shorter and I think a little clearer.  I suspect
> it even results in better code.
> 
> Eric

  reply	other threads:[~2018-04-29  9:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-28 19:20 [PATCH net-next 0/2 v4] netns: uevent filtering Christian Brauner
2018-04-28 19:20 ` [PATCH net-next 1/2 v4] uevent: add alloc_uevent_skb() helper Christian Brauner
2018-04-28 19:20 ` [PATCH net-next 2/2 v4] netns: restrict uevents Christian Brauner
2018-04-29  4:23   ` Eric W. Biederman
2018-04-29  9:59     ` Christian Brauner [this message]
2018-04-29  4:25 ` [PATCH net-next 0/2 v4] netns: uevent filtering Eric W. Biederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180429095957.GA27296@gmail.com \
    --to=christian.brauner@canonical.com \
    --cc=avagin@virtuozzo.com \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ktkhai@virtuozzo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=serge@hallyn.com \
    --subject='Re: [PATCH net-next 2/2 v4] netns: restrict uevents' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).