All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen-netback: fix a BUG() during initialization
@ 2015-06-19 12:21 Imre Palik
  0 siblings, 0 replies; 8+ messages in thread
From: Imre Palik @ 2015-06-19 12:21 UTC (permalink / raw
  To: xen-devel, Ian Campbell, Wei Liu
  Cc: netdev, Palik, Imre, linux-kernel, Matt Wilson

From: "Palik, Imre" <imrep@amazon.de>

Commit edafc132baac ("xen-netback: making the bandwidth limiter runtime settable")
introduced the capability to change the bandwidth rate limit at runtime.
But it also introduced a possible crashing bug.

If netback receives two XenbusStateConnected without getting the
hotplug-status watch firing in between, then it will try to register the
watches for the rate limiter again.  But this triggers a BUG() in the watch
registration code.

The fix modifies connect() to remove the possibly existing packet-rate
watches before trying to install those watches.  This behaviour is in line
with how connect() deals with the hotplug-status watch.

Signed-off-by: Imre Palik <imrep@amazon.de>
Cc: Matt Wilson <msw@amazon.com>
---
 drivers/net/xen-netback/xenbus.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 968787a..ec383b0 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -681,6 +681,9 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
 	char *node;
 	unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
 
+	if (vif->credit_watch.node)
+		return -EADDRINUSE;
+
 	node = kmalloc(maxlen, GFP_KERNEL);
 	if (!node)
 		return -ENOMEM;
@@ -770,6 +773,7 @@ static void connect(struct backend_info *be)
 	}
 
 	xen_net_read_rate(dev, &credit_bytes, &credit_usec);
+	xen_unregister_watchers(be->vif);
 	xen_register_watchers(dev, be->vif);
 	read_xenbus_vif_flags(be);
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] xen-netback: fix a BUG() during initialization
@ 2015-06-19 12:21 ` Imre Palik
  0 siblings, 0 replies; 8+ messages in thread
From: Imre Palik @ 2015-06-19 12:21 UTC (permalink / raw
  To: xen-devel, Ian Campbell, Wei Liu
  Cc: netdev, linux-kernel, Palik, Imre, Matt Wilson

From: "Palik, Imre" <imrep@amazon.de>

Commit edafc132baac ("xen-netback: making the bandwidth limiter runtime settable")
introduced the capability to change the bandwidth rate limit at runtime.
But it also introduced a possible crashing bug.

If netback receives two XenbusStateConnected without getting the
hotplug-status watch firing in between, then it will try to register the
watches for the rate limiter again.  But this triggers a BUG() in the watch
registration code.

The fix modifies connect() to remove the possibly existing packet-rate
watches before trying to install those watches.  This behaviour is in line
with how connect() deals with the hotplug-status watch.

Signed-off-by: Imre Palik <imrep@amazon.de>
Cc: Matt Wilson <msw@amazon.com>
---
 drivers/net/xen-netback/xenbus.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 968787a..ec383b0 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -681,6 +681,9 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
 	char *node;
 	unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
 
+	if (vif->credit_watch.node)
+		return -EADDRINUSE;
+
 	node = kmalloc(maxlen, GFP_KERNEL);
 	if (!node)
 		return -ENOMEM;
@@ -770,6 +773,7 @@ static void connect(struct backend_info *be)
 	}
 
 	xen_net_read_rate(dev, &credit_bytes, &credit_usec);
+	xen_unregister_watchers(be->vif);
 	xen_register_watchers(dev, be->vif);
 	read_xenbus_vif_flags(be);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] xen-netback: fix a BUG() during initialization
@ 2015-06-19 12:21 ` Imre Palik
  0 siblings, 0 replies; 8+ messages in thread
From: Imre Palik @ 2015-06-19 12:21 UTC (permalink / raw
  To: xen-devel, Ian Campbell, Wei Liu
  Cc: netdev, linux-kernel, Palik, Imre, Matt Wilson

From: "Palik, Imre" <imrep@amazon.de>

Commit edafc132baac ("xen-netback: making the bandwidth limiter runtime settable")
introduced the capability to change the bandwidth rate limit at runtime.
But it also introduced a possible crashing bug.

If netback receives two XenbusStateConnected without getting the
hotplug-status watch firing in between, then it will try to register the
watches for the rate limiter again.  But this triggers a BUG() in the watch
registration code.

The fix modifies connect() to remove the possibly existing packet-rate
watches before trying to install those watches.  This behaviour is in line
with how connect() deals with the hotplug-status watch.

Signed-off-by: Imre Palik <imrep@amazon.de>
Cc: Matt Wilson <msw@amazon.com>
---
 drivers/net/xen-netback/xenbus.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 968787a..ec383b0 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -681,6 +681,9 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
 	char *node;
 	unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
 
+	if (vif->credit_watch.node)
+		return -EADDRINUSE;
+
 	node = kmalloc(maxlen, GFP_KERNEL);
 	if (!node)
 		return -ENOMEM;
@@ -770,6 +773,7 @@ static void connect(struct backend_info *be)
 	}
 
 	xen_net_read_rate(dev, &credit_bytes, &credit_usec);
+	xen_unregister_watchers(be->vif);
 	xen_register_watchers(dev, be->vif);
 	read_xenbus_vif_flags(be);
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] xen-netback: fix a BUG() during initialization
  2015-06-19 12:21 ` Imre Palik
@ 2015-06-19 15:37   ` Wei Liu
  -1 siblings, 0 replies; 8+ messages in thread
From: Wei Liu @ 2015-06-19 15:37 UTC (permalink / raw
  To: Imre Palik
  Cc: xen-devel, Ian Campbell, Wei Liu, netdev, linux-kernel,
	Palik, Imre, Matt Wilson

On Fri, Jun 19, 2015 at 02:21:51PM +0200, Imre Palik wrote:
> From: "Palik, Imre" <imrep@amazon.de>
> 
> Commit edafc132baac ("xen-netback: making the bandwidth limiter runtime settable")
> introduced the capability to change the bandwidth rate limit at runtime.
> But it also introduced a possible crashing bug.
> 
> If netback receives two XenbusStateConnected without getting the
> hotplug-status watch firing in between, then it will try to register the
> watches for the rate limiter again.  But this triggers a BUG() in the watch
> registration code.
> 
> The fix modifies connect() to remove the possibly existing packet-rate
> watches before trying to install those watches.  This behaviour is in line
> with how connect() deals with the hotplug-status watch.
> 
> Signed-off-by: Imre Palik <imrep@amazon.de>
> Cc: Matt Wilson <msw@amazon.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

> ---
>  drivers/net/xen-netback/xenbus.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
> index 968787a..ec383b0 100644
> --- a/drivers/net/xen-netback/xenbus.c
> +++ b/drivers/net/xen-netback/xenbus.c
> @@ -681,6 +681,9 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
>  	char *node;
>  	unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
>  
> +	if (vif->credit_watch.node)
> +		return -EADDRINUSE;
> +
>  	node = kmalloc(maxlen, GFP_KERNEL);
>  	if (!node)
>  		return -ENOMEM;
> @@ -770,6 +773,7 @@ static void connect(struct backend_info *be)
>  	}
>  
>  	xen_net_read_rate(dev, &credit_bytes, &credit_usec);
> +	xen_unregister_watchers(be->vif);
>  	xen_register_watchers(dev, be->vif);
>  	read_xenbus_vif_flags(be);
>  
> -- 
> 1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] xen-netback: fix a BUG() during initialization
@ 2015-06-19 15:37   ` Wei Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Wei Liu @ 2015-06-19 15:37 UTC (permalink / raw
  To: Imre Palik
  Cc: xen-devel, Ian Campbell, Wei Liu, netdev, linux-kernel,
	Palik, Imre, Matt Wilson

On Fri, Jun 19, 2015 at 02:21:51PM +0200, Imre Palik wrote:
> From: "Palik, Imre" <imrep@amazon.de>
> 
> Commit edafc132baac ("xen-netback: making the bandwidth limiter runtime settable")
> introduced the capability to change the bandwidth rate limit at runtime.
> But it also introduced a possible crashing bug.
> 
> If netback receives two XenbusStateConnected without getting the
> hotplug-status watch firing in between, then it will try to register the
> watches for the rate limiter again.  But this triggers a BUG() in the watch
> registration code.
> 
> The fix modifies connect() to remove the possibly existing packet-rate
> watches before trying to install those watches.  This behaviour is in line
> with how connect() deals with the hotplug-status watch.
> 
> Signed-off-by: Imre Palik <imrep@amazon.de>
> Cc: Matt Wilson <msw@amazon.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

> ---
>  drivers/net/xen-netback/xenbus.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
> index 968787a..ec383b0 100644
> --- a/drivers/net/xen-netback/xenbus.c
> +++ b/drivers/net/xen-netback/xenbus.c
> @@ -681,6 +681,9 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
>  	char *node;
>  	unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
>  
> +	if (vif->credit_watch.node)
> +		return -EADDRINUSE;
> +
>  	node = kmalloc(maxlen, GFP_KERNEL);
>  	if (!node)
>  		return -ENOMEM;
> @@ -770,6 +773,7 @@ static void connect(struct backend_info *be)
>  	}
>  
>  	xen_net_read_rate(dev, &credit_bytes, &credit_usec);
> +	xen_unregister_watchers(be->vif);
>  	xen_register_watchers(dev, be->vif);
>  	read_xenbus_vif_flags(be);
>  
> -- 
> 1.7.9.5

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] xen-netback: fix a BUG() during initialization
  2015-06-19 12:21 ` Imre Palik
  (?)
  (?)
@ 2015-06-19 15:37 ` Wei Liu
  -1 siblings, 0 replies; 8+ messages in thread
From: Wei Liu @ 2015-06-19 15:37 UTC (permalink / raw
  To: Imre Palik
  Cc: Palik, Imre, Wei Liu, Ian Campbell, netdev, linux-kernel,
	Matt Wilson, xen-devel

On Fri, Jun 19, 2015 at 02:21:51PM +0200, Imre Palik wrote:
> From: "Palik, Imre" <imrep@amazon.de>
> 
> Commit edafc132baac ("xen-netback: making the bandwidth limiter runtime settable")
> introduced the capability to change the bandwidth rate limit at runtime.
> But it also introduced a possible crashing bug.
> 
> If netback receives two XenbusStateConnected without getting the
> hotplug-status watch firing in between, then it will try to register the
> watches for the rate limiter again.  But this triggers a BUG() in the watch
> registration code.
> 
> The fix modifies connect() to remove the possibly existing packet-rate
> watches before trying to install those watches.  This behaviour is in line
> with how connect() deals with the hotplug-status watch.
> 
> Signed-off-by: Imre Palik <imrep@amazon.de>
> Cc: Matt Wilson <msw@amazon.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

> ---
>  drivers/net/xen-netback/xenbus.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
> index 968787a..ec383b0 100644
> --- a/drivers/net/xen-netback/xenbus.c
> +++ b/drivers/net/xen-netback/xenbus.c
> @@ -681,6 +681,9 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
>  	char *node;
>  	unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
>  
> +	if (vif->credit_watch.node)
> +		return -EADDRINUSE;
> +
>  	node = kmalloc(maxlen, GFP_KERNEL);
>  	if (!node)
>  		return -ENOMEM;
> @@ -770,6 +773,7 @@ static void connect(struct backend_info *be)
>  	}
>  
>  	xen_net_read_rate(dev, &credit_bytes, &credit_usec);
> +	xen_unregister_watchers(be->vif);
>  	xen_register_watchers(dev, be->vif);
>  	read_xenbus_vif_flags(be);
>  
> -- 
> 1.7.9.5

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] xen-netback: fix a BUG() during initialization
  2015-06-19 12:21 ` Imre Palik
                   ` (2 preceding siblings ...)
  (?)
@ 2015-06-23 10:34 ` David Miller
  -1 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-06-23 10:34 UTC (permalink / raw
  To: imrep.amz
  Cc: xen-devel, ian.campbell, wei.liu2, netdev, linux-kernel, imrep,
	msw

From: Imre Palik <imrep.amz@gmail.com>
Date: Fri, 19 Jun 2015 14:21:51 +0200

> From: "Palik, Imre" <imrep@amazon.de>
> 
> Commit edafc132baac ("xen-netback: making the bandwidth limiter runtime settable")
> introduced the capability to change the bandwidth rate limit at runtime.
> But it also introduced a possible crashing bug.
> 
> If netback receives two XenbusStateConnected without getting the
> hotplug-status watch firing in between, then it will try to register the
> watches for the rate limiter again.  But this triggers a BUG() in the watch
> registration code.
> 
> The fix modifies connect() to remove the possibly existing packet-rate
> watches before trying to install those watches.  This behaviour is in line
> with how connect() deals with the hotplug-status watch.
> 
> Signed-off-by: Imre Palik <imrep@amazon.de>
> Cc: Matt Wilson <msw@amazon.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] xen-netback: fix a BUG() during initialization
  2015-06-19 12:21 ` Imre Palik
                   ` (3 preceding siblings ...)
  (?)
@ 2015-06-23 10:34 ` David Miller
  -1 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-06-23 10:34 UTC (permalink / raw
  To: imrep.amz
  Cc: imrep, wei.liu2, ian.campbell, netdev, linux-kernel, msw,
	xen-devel

From: Imre Palik <imrep.amz@gmail.com>
Date: Fri, 19 Jun 2015 14:21:51 +0200

> From: "Palik, Imre" <imrep@amazon.de>
> 
> Commit edafc132baac ("xen-netback: making the bandwidth limiter runtime settable")
> introduced the capability to change the bandwidth rate limit at runtime.
> But it also introduced a possible crashing bug.
> 
> If netback receives two XenbusStateConnected without getting the
> hotplug-status watch firing in between, then it will try to register the
> watches for the rate limiter again.  But this triggers a BUG() in the watch
> registration code.
> 
> The fix modifies connect() to remove the possibly existing packet-rate
> watches before trying to install those watches.  This behaviour is in line
> with how connect() deals with the hotplug-status watch.
> 
> Signed-off-by: Imre Palik <imrep@amazon.de>
> Cc: Matt Wilson <msw@amazon.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-06-23 10:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-19 12:21 [PATCH] xen-netback: fix a BUG() during initialization Imre Palik
  -- strict thread matches above, loose matches on Subject: below --
2015-06-19 12:21 Imre Palik
2015-06-19 12:21 ` Imre Palik
2015-06-19 15:37 ` Wei Liu
2015-06-19 15:37   ` Wei Liu
2015-06-19 15:37 ` Wei Liu
2015-06-23 10:34 ` David Miller
2015-06-23 10:34 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.