Patchwork BUG: NULL pointer dereference in netif_carrier_off

login
register
mail settings
Submitter Eric Dumazet
Date Jan. 10, 2013, 6:32 p.m.
Message ID <1357842765.27446.2396.camel@edumazet-glaptop>
Download mbox | patch
Permalink /patch/211110/
State Accepted
Delegated to: David Miller
Headers show

Comments

Eric Dumazet - Jan. 10, 2013, 6:32 p.m.
From: Eric Dumazet <edumazet@google.com>

On Thu, 2013-01-10 at 09:56 -0800, Eric Dumazet wrote:

> 
> Hi Tom, thanks for the report, I'll take a look.

Oh well, fix seems straightforward...

Thanks !

[PATCH net-next] veth: fix a NULL deref in netif_carrier_off

In commit d0e2c55e7c94 (veth: avoid a NULL deref in veth_stats_one)
we now clear the peer pointers in veth_dellink()

veth_close() must therefore make sure the peer pointer is set.

Reported-by: Tom Parkin <tom.parkin@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 drivers/net/veth.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 10, 2013, 10:37 p.m.
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 10 Jan 2013 10:32:45 -0800

> [PATCH net-next] veth: fix a NULL deref in netif_carrier_off
> 
> In commit d0e2c55e7c94 (veth: avoid a NULL deref in veth_stats_one)
> we now clear the peer pointers in veth_dellink()
> 
> veth_close() must therefore make sure the peer pointer is set.
> 
> Reported-by: Tom Parkin <tom.parkin@gmail.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 0f71a4f..e1da42a 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -206,9 +206,11 @@  static int veth_open(struct net_device *dev)
 static int veth_close(struct net_device *dev)
 {
 	struct veth_priv *priv = netdev_priv(dev);
+	struct net_device *peer = rtnl_dereference(priv->peer);
 
 	netif_carrier_off(dev);
-	netif_carrier_off(rtnl_dereference(priv->peer));
+	if (peer)
+		netif_carrier_off(peer);
 
 	return 0;
 }