]> git.ipfire.org Git - thirdparty/linux.git/commit
rxrpc: Fix local endpoint refcounting
authorDavid Howells <dhowells@redhat.com>
Fri, 9 Aug 2019 14:20:41 +0000 (15:20 +0100)
committerDavid Howells <dhowells@redhat.com>
Fri, 9 Aug 2019 14:21:19 +0000 (15:21 +0100)
commit730c5fd42c1e3652a065448fd235cb9fafb2bd10
tree60585660be245d94c51a42f4bfa25e488299aca0
parent8c25d0887a8bd0e1ca2074ac0c6dff173787a83b
rxrpc: Fix local endpoint refcounting

The object lifetime management on the rxrpc_local struct is broken in that
the rxrpc_local_processor() function is expected to clean up and remove an
object - but it may get requeued by packets coming in on the backing UDP
socket once it starts running.

This may result in the assertion in rxrpc_local_rcu() firing because the
memory has been scheduled for RCU destruction whilst still queued:

rxrpc: Assertion failed
------------[ cut here ]------------
kernel BUG at net/rxrpc/local_object.c:468!

Note that if the processor comes around before the RCU free function, it
will just do nothing because ->dead is true.

Fix this by adding a separate refcount to count active users of the
endpoint that causes the endpoint to be destroyed when it reaches 0.

The original refcount can then be used to refcount objects through the work
processor and cause the memory to be rcu freed when that reaches 0.

Fixes: 4f95dd78a77e ("rxrpc: Rework local endpoint management")
Reported-by: syzbot+1e0edc4b8b7494c28450@syzkaller.appspotmail.com
Signed-off-by: David Howells <dhowells@redhat.com>
net/rxrpc/af_rxrpc.c
net/rxrpc/ar-internal.h
net/rxrpc/input.c
net/rxrpc/local_object.c