Skip to contentSkip to conversation

xen-netback: fix a BUG() during initialization

PATCH Applied Imre Palik 3 participants 5 messages Jun 19, 2015 – Jun 23, 2015

Subsystems (3)
lore
Share & tools
lore

Imre Palik

author
#0 lore raw

PATCH 1/1 xen-netback: fix a BUG() during initialization

From: "Palik, Imre" <[email protected]>

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.

---
 drivers/net/xen-netback/xenbus.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/net/xen-netback/xenbus.c +4 -0
index 968787a..ec383b0 100644
@@ -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);
 
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Imre Palik

From: "Palik, Imre" <[email protected]>

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.

Quoted 6 lines

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.

Quoted 28 lines
---
 drivers/net/xen-netback/xenbus.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/net/xen-netback/xenbus.c +4 -0
index 968787a..ec383b0 100644
@@ -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);
 
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#2 lore raw
In reply to Imre Palik
Quoted 11 lines · Imre Palik

From: "Palik, Imre" <[email protected]>

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.

Quoted 6 lines

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.

Quoted 28 lines
---
 drivers/net/xen-netback/xenbus.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/net/xen-netback/xenbus.c +4 -0
index 968787a..ec383b0 100644
@@ -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);
 
Signature · 1 line
1.7.9.5
maintainer Applied
#3 lore raw
In reply to Imre Palik

From: Imre Palik <[email protected]>
Date: Fri, 19 Jun 2015 14:21:51 +0200

Quoted 11 lines

From: "Palik, Imre" <[email protected]>

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.

Quoted 6 lines

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.

Applied, thank you.

maintainer Applied
#4 lore raw
In reply to Imre Palik

From: Imre Palik <[email protected]>
Date: Fri, 19 Jun 2015 14:21:51 +0200

Quoted 11 lines

From: "Palik, Imre" <[email protected]>

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.

Quoted 6 lines

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.

Applied, thank you.