netlink: genl: fix circular locking
authorPatrick McHardy <kaber@trash.net>
Wed, 18 Jun 2008 09:07:07 +0000 (02:07 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Jun 2008 09:07:07 +0000 (02:07 -0700)
commit6d1a3fb567a728d31474636e167c324702a0c38b
tree02ffcef1520345d44f080b821aa32f4a596b7e1f
parent3a5be7d4b079f3a9ce1e8ce4a93ba15ae6d00111
netlink: genl: fix circular locking

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: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/genetlink.c