]> git.baikalelectronics.ru Git - kernel.git/commit
rxrpc: Fix local endpoint replacement
authorDavid Howells <dhowells@redhat.com>
Mon, 12 Aug 2019 22:30:06 +0000 (23:30 +0100)
committerDavid Howells <dhowells@redhat.com>
Wed, 14 Aug 2019 10:37:51 +0000 (11:37 +0100)
commit53ffeba405585603ccae6e021d720340fa5d8043
treeb87b4b71c31483551e546dff3ebca8fc1c172dc2
parentfa203343563b9a8dd2daaefddcaa8ed08e6ddd2a
rxrpc: Fix local endpoint replacement

When a local endpoint (struct rxrpc_local) ceases to be in use by any
AF_RXRPC sockets, it starts the process of being destroyed, but this
doesn't cause it to be removed from the namespace endpoint list immediately
as tearing it down isn't trivial and can't be done in softirq context, so
it gets deferred.

If a new socket comes along that wants to bind to the same endpoint, a new
rxrpc_local object will be allocated and rxrpc_lookup_local() will use
list_replace() to substitute the new one for the old.

Then, when the dying object gets to rxrpc_local_destroyer(), it is removed
unconditionally from whatever list it is on by calling list_del_init().

However, list_replace() doesn't reset the pointers in the replaced
list_head and so the list_del_init() will likely corrupt the local
endpoints list.

Fix this by using list_replace_init() instead.

Fixes: b7f68f43ce07 ("rxrpc: Fix local endpoint refcounting")
Reported-by: syzbot+193e29e9387ea5837f1d@syzkaller.appspotmail.com
Signed-off-by: David Howells <dhowells@redhat.com>
net/rxrpc/local_object.c