LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Christian Brauner <christian.brauner@ubuntu.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 1/2 v3] uevent: add alloc_uevent_skb() helper
Date: Fri, 27 Apr 2018 11:39:44 -0500	[thread overview]
Message-ID: <878t987gdr.fsf@xmission.com> (raw)
In-Reply-To: <20180427102306.8617-2-christian.brauner@ubuntu.com> (Christian Brauner's message of "Fri, 27 Apr 2018 12:23:05 +0200")

Christian Brauner <christian.brauner@ubuntu.com> writes:

> This patch adds alloc_uevent_skb() in preparation for follow up patches.
>
> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> ---
>  lib/kobject_uevent.c | 39 ++++++++++++++++++++++++++-------------
>  1 file changed, 26 insertions(+), 13 deletions(-)
>
> diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
> index 15ea216a67ce..c3cb110f663b 100644
> --- a/lib/kobject_uevent.c
> +++ b/lib/kobject_uevent.c
> @@ -296,6 +296,31 @@ static void cleanup_uevent_env(struct subprocess_info *info)
>  }
>  #endif
>  
> +static struct sk_buff *alloc_uevent_skb(struct kobj_uevent_env *env,
> +					const char *action_string,
> +					const char *devpath)
> +{
> +	struct sk_buff *skb = NULL;
> +	char *scratch;
> +	size_t len;
> +
> +	/* allocate message with maximum possible size */
> +	len = strlen(action_string) + strlen(devpath) + 2;
> +	skb = alloc_skb(len + env->buflen, GFP_KERNEL);
> +	if (!skb)
> +		return NULL;
> +
> +	/* add header */
> +	scratch = skb_put(skb, len);
> +	sprintf(scratch, "%s@%s", action_string, devpath);
> +
> +	skb_put_data(skb, env->buf, env->buflen);
> +
> +	NETLINK_CB(skb).dst_group = 1;

nit:
     We might want to explicitly set NETLINK_CB(skb).portid to 0 and
     NETLINK_CB(skb).creds.uid to GLOBAL_ROOT_UID and
     NETLINK_CB(skb).creds.gid to GLOBAL_ROOT_GID here
     just to make it clear this is happening.

     It is not a problem because they __alloc_skb memsets to 0 the
     fields of struct sk_buff that it does not initialize.  And these
     are the zero values.

     Still it would be nice to be able to look at the code and quickly
     see these are the values being set.

Eric

  reply	other threads:[~2018-04-27 16:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-27 10:23 [PATCH net-next 0/2] netns: uevent filtering Christian Brauner
2018-04-27 10:23 ` [PATCH net-next 1/2 v3] uevent: add alloc_uevent_skb() helper Christian Brauner
2018-04-27 16:39   ` Eric W. Biederman [this message]
2018-04-28 19:09     ` Christian Brauner
2018-04-27 10:23 ` [PATCH net-next 2/2 v3] netns: restrict uevents Christian Brauner
2018-04-27 16:30   ` Eric W. Biederman
2018-04-28 19:13     ` Christian Brauner
2018-04-27 16:27 ` [PATCH net-next 0/2] 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=878t987gdr.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=avagin@virtuozzo.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=davem@davemloft.net \
    --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 1/2 v3] uevent: add alloc_uevent_skb() helper' \
    /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).