Commit d8d85ef
af_packet: move notifier's packet_dev_mc out of rcu critical section
Syzkaller reports the following issue:
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:578
__mutex_lock+0x106/0xe80 kernel/locking/mutex.c:746
team_change_rx_flags+0x38/0x220 drivers/net/team/team_core.c:1781
dev_change_rx_flags net/core/dev.c:9145 [inline]
__dev_set_promiscuity+0x3f8/0x590 net/core/dev.c:9189
netif_set_promiscuity+0x50/0xe0 net/core/dev.c:9201
dev_set_promiscuity+0x126/0x260 net/core/dev_api.c:286 packet_dev_mc net/packet/af_packet.c:3698 [inline]
packet_dev_mclist_delete net/packet/af_packet.c:3722 [inline]
packet_notifier+0x292/0xa60 net/packet/af_packet.c:4247
notifier_call_chain+0x1b3/0x3e0 kernel/notifier.c:85
call_netdevice_notifiers_extack net/core/dev.c:2214 [inline]
call_netdevice_notifiers net/core/dev.c:2228 [inline]
unregister_netdevice_many_notify+0x15d8/0x2330 net/core/dev.c:11972
rtnl_delete_link net/core/rtnetlink.c:3522 [inline]
rtnl_dellink+0x488/0x710 net/core/rtnetlink.c:3564
rtnetlink_rcv_msg+0x7cf/0xb70 net/core/rtnetlink.c:6955
netlink_rcv_skb+0x219/0x490 net/netlink/af_netlink.c:2534
Calling `PACKET_ADD_MEMBERSHIP` on an ops-locked device can trigger
the `NETDEV_UNREGISTER` notifier, which may require disabling promiscuous
and/or allmulti mode. Both of these operations require acquiring
the netdev instance lock.
Move the call to `packet_dev_mc` outside of the RCU critical section.
The `mclist` modifications (add, del, flush, unregister) are protected by
the RTNL, not the RCU. The RCU only protects the `sklist` and its
associated `sks`. The delayed operation on the `mclist` entry remains
within the RTNL.
Reported-by: syzbot+b191b5ccad8d7a986286@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b191b5ccad8d7a986286
Fixes: ad7c7b2 ("net: hold netdev instance lock during sysfs operations")
Signed-off-by: Stanislav Fomichev <stfomichev@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250522031129.3247266-1-stfomichev@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>1 parent 3237423 commit d8d85ef
2 files changed
Lines changed: 17 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3713 | 3713 | | |
3714 | 3714 | | |
3715 | 3715 | | |
3716 | | - | |
| 3716 | + | |
| 3717 | + | |
3717 | 3718 | | |
3718 | 3719 | | |
3719 | 3720 | | |
3720 | 3721 | | |
3721 | 3722 | | |
3722 | | - | |
| 3723 | + | |
3723 | 3724 | | |
3724 | | - | |
3725 | 3725 | | |
3726 | 3726 | | |
3727 | 3727 | | |
| |||
3769 | 3769 | | |
3770 | 3770 | | |
3771 | 3771 | | |
| 3772 | + | |
3772 | 3773 | | |
3773 | 3774 | | |
3774 | 3775 | | |
| |||
4233 | 4234 | | |
4234 | 4235 | | |
4235 | 4236 | | |
4236 | | - | |
4237 | 4237 | | |
4238 | 4238 | | |
| 4239 | + | |
| 4240 | + | |
| 4241 | + | |
4239 | 4242 | | |
4240 | 4243 | | |
4241 | 4244 | | |
| |||
4244 | 4247 | | |
4245 | 4248 | | |
4246 | 4249 | | |
4247 | | - | |
| 4250 | + | |
| 4251 | + | |
4248 | 4252 | | |
4249 | 4253 | | |
4250 | 4254 | | |
| |||
4277 | 4281 | | |
4278 | 4282 | | |
4279 | 4283 | | |
| 4284 | + | |
| 4285 | + | |
| 4286 | + | |
| 4287 | + | |
| 4288 | + | |
| 4289 | + | |
| 4290 | + | |
4280 | 4291 | | |
4281 | 4292 | | |
4282 | 4293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
0 commit comments