Skip to contentSkip to conversation

netpoll: fix a rtnl lock assertion failure

PATCH Superseded Cong Wang 4 participants 6 messages Jan 14, 2013 – Jan 15, 2013

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH v3 1/1 netpoll: fix a rtnl lock assertion failure

From: Cong Wang <[email protected]>

This patch fixes the following warning:

[   72.013864] RTNL: assertion failed at net/core/dev.c (4955)
[   72.017758] Pid: 668, comm: netpoll-prep-v6 Not tainted 3.8.0-rc1+ #474
[   72.019582] Call Trace:
[   72.020295]  [<ffffffff8176653d>] netdev_master_upper_dev_get+0x35/0x58
[   72.022545]  [<ffffffff81784edd>] netpoll_setup+0x61/0x340
[   72.024846]  [<ffffffff815d837e>] store_enabled+0x82/0xc3
[   72.027466]  [<ffffffff815d7e51>] netconsole_target_attr_store+0x35/0x37
[   72.029348]  [<ffffffff811c3479>] configfs_write_file+0xe2/0x10c
[   72.030959]  [<ffffffff8115d239>] vfs_write+0xaf/0xf6
[   72.032359]  [<ffffffff81978a05>] ? sysret_check+0x22/0x5d
[   72.033824]  [<ffffffff8115d453>] sys_write+0x5c/0x84
[   72.035328]  [<ffffffff819789d9>] system_call_fastpath+0x16/0x1b

Just hold RCU read lock and call netdev_master_upper_dev_get_rcu(), as suggested by Jiri.

Cc Jiri Pirko <[email protected]>
Cc David S. Miller <[email protected]>

---

net/core/netpoll.c +4 -1
index 9f05067..5d1f856 100644
@@ -1055,11 +1055,14 @@ int netpoll_setup(struct netpoll *np)
 		return -ENODEV;
 	}
 
-	if (netdev_master_upper_dev_get(ndev)) {
+	rcu_read_lock();
+	if (netdev_master_upper_dev_get_rcu(ndev)) {
+		rcu_read_unlock();
 		np_err(np, "%s is a slave device, aborting\n", np->dev_name);
 		err = -EBUSY;
 		goto put;
 	}
+	rcu_read_unlock();
 
 	if (!netif_running(ndev)) {
 		unsigned long atmost, atleast;
Reviewed-by on v3 1/1
#1 lore raw
Quoted 17 lines · Mon, Jan 14, 2013 at 11:43:54AM CET, [email protected] wrote:

From: Cong Wang <[email protected]>

This patch fixes the following warning:

[   72.013864] RTNL: assertion failed at net/core/dev.c (4955)
[   72.017758] Pid: 668, comm: netpoll-prep-v6 Not tainted 3.8.0-rc1+ #474
[   72.019582] Call Trace:
[   72.020295]  [<ffffffff8176653d>] netdev_master_upper_dev_get+0x35/0x58
[   72.022545]  [<ffffffff81784edd>] netpoll_setup+0x61/0x340
[   72.024846]  [<ffffffff815d837e>] store_enabled+0x82/0xc3
[   72.027466]  [<ffffffff815d7e51>] netconsole_target_attr_store+0x35/0x37
[   72.029348]  [<ffffffff811c3479>] configfs_write_file+0xe2/0x10c
[   72.030959]  [<ffffffff8115d239>] vfs_write+0xaf/0xf6
[   72.032359]  [<ffffffff81978a05>] ? sysret_check+0x22/0x5d
[   72.033824]  [<ffffffff8115d453>] sys_write+0x5c/0x84
[   72.035328]  [<ffffffff819789d9>] system_call_fastpath+0x16/0x1b
Quoted 6 lines

Just hold RCU read lock and call netdev_master_upper_dev_get_rcu(), as suggested by Jiri.

Cc Jiri Pirko <[email protected]>
Cc David S. Miller <[email protected]>
Quoted 12 lines

---

net/core/netpoll.c +1 -1
index 9f05067..5d1f856 100644
@@ -1055,11 +1055,14 @@ int netpoll_setup(struct netpoll *np)
 		return -ENODEV;
 	}
 
-	if (netdev_master_upper_dev_get(ndev)) {
+	rcu_read_lock();

net/core/netpoll.c int netpoll_setup(struct netpoll *np) · line 1068

Quoted 10 lines
net/core/netpoll.c +3 -0
+	if (netdev_master_upper_dev_get_rcu(ndev)) {
+		rcu_read_unlock();
 		np_err(np, "%s is a slave device, aborting\n", np->dev_name);
 		err = -EBUSY;
 		goto put;
 	}
+	rcu_read_unlock();
 
 	if (!netif_running(ndev)) {
 		unsigned long atmost, atleast;

Thanks Amerigo.

#2 lore raw
In reply to Cong Wang
Quoted 36 lines · Cong Wang

From: Cong Wang <[email protected]>

This patch fixes the following warning:

[   72.013864] RTNL: assertion failed at net/core/dev.c (4955)
[   72.017758] Pid: 668, comm: netpoll-prep-v6 Not tainted 3.8.0-rc1+ #474
[   72.019582] Call Trace:
[   72.020295]  [<ffffffff8176653d>] netdev_master_upper_dev_get+0x35/0x58
[   72.022545]  [<ffffffff81784edd>] netpoll_setup+0x61/0x340
[   72.024846]  [<ffffffff815d837e>] store_enabled+0x82/0xc3
[   72.027466]  [<ffffffff815d7e51>] netconsole_target_attr_store+0x35/0x37
[   72.029348]  [<ffffffff811c3479>] configfs_write_file+0xe2/0x10c
[   72.030959]  [<ffffffff8115d239>] vfs_write+0xaf/0xf6
[   72.032359]  [<ffffffff81978a05>] ? sysret_check+0x22/0x5d
[   72.033824]  [<ffffffff8115d453>] sys_write+0x5c/0x84
[   72.035328]  [<ffffffff819789d9>] system_call_fastpath+0x16/0x1b

Just hold RCU read lock and call netdev_master_upper_dev_get_rcu(), as suggested by Jiri.

Cc Jiri Pirko <[email protected]>
Cc David S. Miller <[email protected]>

---

net/core/netpoll.c +2 -1
index 9f05067..5d1f856 100644
@@ -1055,11 +1055,14 @@ int netpoll_setup(struct netpoll *np)
 		return -ENODEV;
 	}
 
-	if (netdev_master_upper_dev_get(ndev)) {
+	rcu_read_lock();
+	if (netdev_master_upper_dev_get_rcu(ndev)) {

net/core/netpoll.c int netpoll_setup(struct netpoll *np)

Quoted 10 lines
net/core/netpoll.c +2 -1
+		rcu_read_unlock();
 		np_err(np, "%s is a slave device, aborting\n", np->dev_name);
 		err = -EBUSY;
 		goto put;
 	}
+	rcu_read_unlock();
 
 	if (!netif_running(ndev)) {
 		unsigned long atmost, atleast;
--

Strange, why dont we call netdev_master_upper_dev_get() instead ?

#3 lore raw
Quoted 3 lines · Eric Dumazet

Strange, why dont we call netdev_master_upper_dev_get() instead ?

What I meant is : the result of this check might be of little use, if we don't hold any lock preventing another thread to change things behind us.

maintainer
#4 lore raw

From: Eric Dumazet <[email protected]>
Date: Mon, 14 Jan 2013 09:09:56 -0800

Quoted 9 lines · Eric Dumazet
Quoted 4 lines

Strange, why dont we call netdev_master_upper_dev_get() instead ?

What I meant is : the result of this check might be of little use, if we don't hold any lock preventing another thread to change things behind us.

Agreed, this test is going to be racey.

author
#5 lore raw
In reply to Eric Dumazet
Quoted 11 lines · Eric Dumazet
Quoted 3 lines · Eric Dumazet

Strange, why dont we call netdev_master_upper_dev_get() instead ?

What I meant is : the result of this check might be of little use, if we don't hold any lock preventing another thread to change things behind us.

Even if so, enslaving this device can still happen after we release the rtnl lock, unless we take this lock for the whole netpoll_setup().

Am I missing anything?