]> git.baikalelectronics.ru Git - kernel.git/commit
rtnetlink: avoid RCU read lock when holding RTNL
authorCong Wang <cong.wang@bytedance.com>
Sat, 8 May 2021 18:00:33 +0000 (11:00 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 May 2021 21:33:10 +0000 (14:33 -0700)
commit62fbb9b7a2ae0d97090686b869115648cb2fc817
tree5c614edec5ccc729eae58fb83e8ef43026f9e9ad
parent572fc85be98433be073fa5612eb19fa257239f97
rtnetlink: avoid RCU read lock when holding RTNL

When we call af_ops->set_link_af() we hold a RCU read lock
as we retrieve af_ops from the RCU protected list, but this
is unnecessary because we already hold RTNL lock, which is
the writer lock for protecting rtnl_af_ops, so it is safer
than RCU read lock. Similar for af_ops->validate_link_af().

This was not a problem until we begin to take mutex lock
down the path of ->set_link_af() in __ipv6_dev_mc_dec()
recently. We can just drop the RCU read lock there and
assert RTNL lock.

Reported-and-tested-by: syzbot+7d941e89dd48bcf42573@syzkaller.appspotmail.com
Fixes: b10e8c4ec928 ("mld: add mc_lock for protecting per-interface mld data")
Tested-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c
net/ipv4/devinet.c