Commit 2dd6fc3
packet: Do not call fanout_release from atomic contexts
[ Upstream commit 2bd624b4611ffee36422782d16e1c944d1351e98 ]
Commit 6664498280cf ("packet: call fanout_release, while UNREGISTERING a
netdev"), unfortunately, introduced the following issues.
1. calling mutex_lock(&fanout_mutex) (fanout_release()) from inside
rcu_read-side critical section. rcu_read_lock disables preemption, most often,
which prohibits calling sleeping functions.
[ ] include/linux/rcupdate.h:560 Illegal context switch in RCU read-side critical section!
[ ]
[ ] rcu_scheduler_active = 1, debug_locks = 0
[ ] 4 locks held by ovs-vswitchd/1969:
[ ] #0: (cb_lock){++++++}, at: [<ffffffff8158a6c9>] genl_rcv+0x19/0x40
[ ] #1: (ovs_mutex){+.+.+.}, at: [<ffffffffa04878ca>] ovs_vport_cmd_del+0x4a/0x100 [openvswitch]
[ ] AOSP-JF-MM#2: (rtnl_mutex){+.+.+.}, at: [<ffffffff81564157>] rtnl_lock+0x17/0x20
[ ] CyanogenMod#3: (rcu_read_lock){......}, at: [<ffffffff81614165>] packet_notifier+0x5/0x3f0
[ ]
[ ] Call Trace:
[ ] [<ffffffff813770c1>] dump_stack+0x85/0xc4
[ ] [<ffffffff810c9077>] lockdep_rcu_suspicious+0x107/0x110
[ ] [<ffffffff810a2da7>] ___might_sleep+0x57/0x210
[ ] [<ffffffff810a2fd0>] __might_sleep+0x70/0x90
[ ] [<ffffffff8162e80c>] mutex_lock_nested+0x3c/0x3a0
[ ] [<ffffffff810de93f>] ? vprintk_default+0x1f/0x30
[ ] [<ffffffff81186e88>] ? printk+0x4d/0x4f
[ ] [<ffffffff816106dd>] fanout_release+0x1d/0xe0
[ ] [<ffffffff81614459>] packet_notifier+0x2f9/0x3f0
2. calling mutex_lock(&fanout_mutex) inside spin_lock(&po->bind_lock).
"sleeping function called from invalid context"
[ ] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:620
[ ] in_atomic(): 1, irqs_disabled(): 0, pid: 1969, name: ovs-vswitchd
[ ] INFO: lockdep is turned off.
[ ] Call Trace:
[ ] [<ffffffff813770c1>] dump_stack+0x85/0xc4
[ ] [<ffffffff810a2f52>] ___might_sleep+0x202/0x210
[ ] [<ffffffff810a2fd0>] __might_sleep+0x70/0x90
[ ] [<ffffffff8162e80c>] mutex_lock_nested+0x3c/0x3a0
[ ] [<ffffffff816106dd>] fanout_release+0x1d/0xe0
[ ] [<ffffffff81614459>] packet_notifier+0x2f9/0x3f0
3. calling dev_remove_pack(&fanout->prot_hook), from inside
spin_lock(&po->bind_lock) or rcu_read-side critical-section. dev_remove_pack()
-> synchronize_net(), which might sleep.
[ ] BUG: scheduling while atomic: ovs-vswitchd/1969/0x00000002
[ ] INFO: lockdep is turned off.
[ ] Call Trace:
[ ] [<ffffffff813770c1>] dump_stack+0x85/0xc4
[ ] [<ffffffff81186274>] __schedule_bug+0x64/0x73
[ ] [<ffffffff8162b8cb>] __schedule+0x6b/0xd10
[ ] [<ffffffff8162c5db>] schedule+0x6b/0x80
[ ] [<ffffffff81630b1d>] schedule_timeout+0x38d/0x410
[ ] [<ffffffff810ea3fd>] synchronize_sched_expedited+0x53d/0x810
[ ] [<ffffffff810ea6de>] synchronize_rcu_expedited+0xe/0x10
[ ] [<ffffffff8154eab5>] synchronize_net+0x35/0x50
[ ] [<ffffffff8154eae3>] dev_remove_pack+0x13/0x20
[ ] [<ffffffff8161077e>] fanout_release+0xbe/0xe0
[ ] [<ffffffff81614459>] packet_notifier+0x2f9/0x3f0
4. fanout_release() races with calls from different CPU.
To fix the above problems, remove the call to fanout_release() under
rcu_read_lock(). Instead, call __dev_remove_pack(&fanout->prot_hook) and
netdev_run_todo will be happy that &dev->ptype_specific list is empty. In order
to achieve this, I moved dev_{add,remove}_pack() out of fanout_{add,release} to
__fanout_{link,unlink}. So, call to {,__}unregister_prot_hook() will make sure
fanout->prot_hook is removed as well
Fixes: 6664498280cf ("packet: call fanout_release, while UNREGISTERING a netdev")
Reported-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Anoob Soman <anoob.soman@citrix.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: fe41cfb
Git-repo: https://source.codeaurora.org/quic/la/kernel/msm-4.4/commit/
Change-Id: If5c94fcd9ee7fb15fadd50fa05f3a73688be61e8
Signed-off-by: Tejaswi Tanikella <tejaswit@qti.qualcomm.com>1 parent 4c99ac1 commit 2dd6fc3
1 file changed
Lines changed: 24 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1380 | 1380 | | |
1381 | 1381 | | |
1382 | 1382 | | |
| 1383 | + | |
| 1384 | + | |
1383 | 1385 | | |
1384 | 1386 | | |
1385 | 1387 | | |
| |||
1396 | 1398 | | |
1397 | 1399 | | |
1398 | 1400 | | |
| 1401 | + | |
| 1402 | + | |
1399 | 1403 | | |
1400 | 1404 | | |
1401 | 1405 | | |
| |||
1468 | 1472 | | |
1469 | 1473 | | |
1470 | 1474 | | |
1471 | | - | |
1472 | 1475 | | |
1473 | 1476 | | |
1474 | 1477 | | |
| |||
1489 | 1492 | | |
1490 | 1493 | | |
1491 | 1494 | | |
1492 | | - | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
1493 | 1503 | | |
1494 | 1504 | | |
1495 | 1505 | | |
| |||
1499 | 1509 | | |
1500 | 1510 | | |
1501 | 1511 | | |
1502 | | - | |
| 1512 | + | |
1503 | 1513 | | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
1507 | 1517 | | |
1508 | 1518 | | |
| 1519 | + | |
| 1520 | + | |
1509 | 1521 | | |
1510 | 1522 | | |
1511 | 1523 | | |
| |||
2587 | 2599 | | |
2588 | 2600 | | |
2589 | 2601 | | |
| 2602 | + | |
2590 | 2603 | | |
2591 | 2604 | | |
2592 | 2605 | | |
| |||
2626 | 2639 | | |
2627 | 2640 | | |
2628 | 2641 | | |
2629 | | - | |
| 2642 | + | |
2630 | 2643 | | |
2631 | 2644 | | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
2632 | 2649 | | |
2633 | 2650 | | |
2634 | 2651 | | |
| |||
3567 | 3584 | | |
3568 | 3585 | | |
3569 | 3586 | | |
3570 | | - | |
3571 | 3587 | | |
3572 | 3588 | | |
3573 | 3589 | | |
| |||
0 commit comments