OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] Don't attach callback to a going-away netlink socket
Re: [PATCH] Don't attach callback to a going-away netlink socket [message #12046 is a reply to message #12044] Mon, 16 April 2007 11:53 Go to previous messageGo to previous message
xemul is currently offline  xemul
Messages: 248
Registered: November 2005
Senior Member
Patrick McHardy wrote:
> Pavel Emelianov wrote:
>> From: Denis Lunev <den@openvz.org>
>>
>> There is a race between netlink_dump_start() and netlink_release()
>> that can lead to the situation when a netlink socket with non-zero
>> callback is freed.
>
>
> Can you describe the race in more detail please?
>
>

Here it is:

CPU1: CPU2
netlink_release(): netlink_dump_start():

sk = netlink_lookup(); /* OK */

netlink_remove();

spin_lock(&nlk->cb_lock);
if (nlk->cb) { /* false */
...
}
spin_unlock(&nlk->cb_lock);

spin_lock(&nlk->cb_lock);
if (nlk->cb) { /* false */
...
}
nlk->cb = cb;
spin_unlock(&nlk->cb_lock);
...
sock_orphan(sk);
/*
* proceed with releasing
* the socket
*/

The proposal it to make sock_orphan before detaching the callback
in netlink_release() and to check for the sock to be SOCK_DEAD in
netlink_dump_start() before setting a new callback.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to query mount propagation state?
Next Topic: [PATCH] Report that kernel is tainted if there were an OOPS before
Goto Forum:
  


Current Time: Fri Oct 18 22:13:17 GMT 2024

Total time taken to generate the page: 0.04962 seconds