• Cong Wang's avatar
    rtnetlink: avoid RCU read lock when holding RTNL · a100243d
    Cong Wang authored
    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: 63ed8de4 ("mld: add mc_lock for protecting per-interface mld data")
    Tested-by: default avatarTaehee Yoo <ap420073@gmail.com>
    Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    a100243d
devinet.c 68.6 KB