Skip to content

Commit

Permalink
rxrpc: Fix local endpoint replacement
Browse files Browse the repository at this point in the history
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: 730c5fd ("rxrpc: Fix local endpoint refcounting")
Reported-by: syzbot+193e29e9387ea5837f1d@syzkaller.appspotmail.com
Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
dhowells committed Aug 14, 2019
1 parent 125b7e0 commit b00df84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/rxrpc/local_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ struct rxrpc_local *rxrpc_lookup_local(struct net *net,
goto sock_error;

if (cursor != &rxnet->local_endpoints)
list_replace(cursor, &local->link);
list_replace_init(cursor, &local->link);
else
list_add_tail(&local->link, cursor);
age = "new";
Expand Down

0 comments on commit b00df84

Please sign in to comment.