• Patrick McHardy's avatar
    netlink: genl: fix circular locking · 6d1a3fb5
    Patrick McHardy authored
    genetlink has a circular locking dependency when dumping the registered
    families:
    
    - dump start:
    genl_rcv()            : take genl_mutex
    genl_rcv_msg()        : call netlink_dump_start() while holding genl_mutex
    netlink_dump_start(),
    netlink_dump()        : take nlk->cb_mutex
    ctrl_dumpfamily()     : try to detect this case and not take genl_mutex a
                            second time
    
    - dump continuance:
    netlink_rcv()         : call netlink_dump
    netlink_dump          : take nlk->cb_mutex
    ctrl_dumpfamily()     : take genl_mutex
    
    Register genl_lock as callback mutex with netlink to fix this. This slightly
    widens an already existing module unload race, the genl ops used during the
    dump might go away when the module is unloaded. Thomas Graf is working on a
    seperate fix for this.
    Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    6d1a3fb5
genetlink.c 17.6 KB