xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: Bastian Blank <waldi@debian.org>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
	James Harper <james.harper@bendigoit.com.au>,
	xen-devel@lists.xensource.com
Subject: Re: [PATCH] xen/netback: Fix null-pointer access in netback_uevent
Date: Mon, 31 May 2010 08:37:43 +0100	[thread overview]
Message-ID: <4C0383670200007800004B63@vpn.id2.novell.com> (raw)
In-Reply-To: <20100529184452.GA18365@wavehammer.waldi.eu.org>

>>> On 29.05.10 at 20:44, Bastian Blank <waldi@debian.org> wrote:
> The uevent method of Xen netback does not check if the the network
> device is already setup and tries to dereference a null-pointer it not.
> 
> Signed-off-by: Bastian Blank <waldi@debian.org>
> ---
>  drivers/xen/netback/xenbus.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/xen/netback/xenbus.c b/drivers/xen/netback/xenbus.c
> index 70636d0..88262bb 100644
> --- a/drivers/xen/netback/xenbus.c
> +++ b/drivers/xen/netback/xenbus.c
> @@ -163,7 +163,6 @@ fail:
>  static int netback_uevent(struct xenbus_device *xdev, struct 
> kobj_uevent_env *env)
>  {
>  	struct backend_info *be = dev_get_drvdata(&xdev->dev);
> -	struct xen_netif *netif = be->netif;
>  	char *val;
>  
>  	DPRINTK("netback_uevent");
> @@ -182,7 +181,7 @@ static int netback_uevent(struct xenbus_device *xdev, 
> struct kobj_uevent_env *en
>  		kfree(val);
>  	}
>  
> -	if (add_uevent_var(env, "vif=%s", netif->dev->name))
> +	if (be && be->netif && add_uevent_var(env, "vif=%s", be->netif->dev->name))
>  		return -ENOMEM;
>  
>  	return 0;

Unfortunately this still seems incomplete: Just checking be->netif to
be non-NULL isn't sufficient, as the sysfs access may race backend
teardown afaics. Hence proper serialization is going to be needed for
that case.

Furthermore, the backend creation patch also needs adjustment,
as it currently stores a non-NULL non-pointer value in be->netif if
netif_alloc() fails. To require the sysfs path to use IS_ERR() on
be->netif, I think netif_alloc()'s result should be stored to a local 
variable first and only written to be->netif when valid.

Jan

  reply	other threads:[~2010-05-31  7:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 16:55 Null-pointer access in netback_uevent Bastian Blank
2010-05-27 21:03 ` Jeremy Fitzhardinge
2010-05-27 22:27   ` Bastian Blank
2010-05-27 22:39     ` Jeremy Fitzhardinge
2010-05-27 23:02       ` Bastian Blank
2010-05-28  0:04 ` James Harper
2010-05-28  0:33   ` James Harper
2010-05-28  0:47     ` James Harper
2010-05-28  9:03       ` Bastian Blank
2010-05-28 17:28         ` Jeremy Fitzhardinge
2010-05-28 22:42           ` James Harper
2010-05-28 23:30             ` Jeremy Fitzhardinge
2010-05-28 23:59               ` James Harper
2010-05-29  6:44                 ` Bastian Blank
2010-05-29 18:44                   ` [PATCH] xen/netback: Fix null-pointer " Bastian Blank
2010-05-31  7:37                     ` Jan Beulich [this message]
2010-05-31  8:07                       ` Jan Beulich
2010-07-28 16:20                         ` Bastian Blank
2010-07-29 11:47                           ` Ian Campbell
2010-07-29 12:42                             ` Bastian Blank
2010-07-29 13:44                               ` Ian Campbell
2010-07-29 13:48                                 ` Ian Campbell
2010-07-29 15:30                                 ` Bastian Blank
2010-07-29 15:40                                   ` Jeremy Fitzhardinge
2010-07-29 17:08                                     ` Bastian Blank

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=4C0383670200007800004B63@vpn.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=james.harper@bendigoit.com.au \
    --cc=jeremy@goop.org \
    --cc=waldi@debian.org \
    --cc=xen-devel@lists.xensource.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).