Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-08-09 22:47:47 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-29 08:30:28 +0200
commit85a55331d9aeb1f91ef71620be92ab52c72e8acd (patch)
tree05a13e321a29e5ddd7889d1b86f7184c4735bb65
parentfa321a9ce5992f2ba336c5bf032e874e7b81b0b2 (diff)
rxrpc: Fix local refcounting
[ Upstream commit 68553f1a6f746bf860bce3eb42d78c26a717d9c0 ] Fix rxrpc_unuse_local() to handle a NULL local pointer as it can be called on an unbound socket on which rx->local is not yet set. The following reproduced (includes omitted): int main(void) { socket(AF_RXRPC, SOCK_DGRAM, AF_INET); return 0; } causes the following oops to occur: BUG: kernel NULL pointer dereference, address: 0000000000000010 ... RIP: 0010:rxrpc_unuse_local+0x8/0x1b ... Call Trace: rxrpc_release+0x2b5/0x338 __sock_release+0x37/0xa1 sock_close+0x14/0x17 __fput+0x115/0x1e9 task_work_run+0x72/0x98 do_exit+0x51b/0xa7a ? __context_tracking_exit+0x4e/0x10e do_group_exit+0xab/0xab __x64_sys_exit_group+0x14/0x17 do_syscall_64+0x89/0x1d4 entry_SYSCALL_64_after_hwframe+0x49/0xbe Reported-by: syzbot+20dee719a2e090427b5f@syzkaller.appspotmail.com Fixes: 730c5fd42c1e ("rxrpc: Fix local endpoint refcounting") Signed-off-by: David Howells <dhowells@redhat.com> cc: Jeffrey Altman <jaltman@auristor.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/rxrpc/local_object.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
index 68e9342fd433..72a6e12a9304 100644
--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -403,11 +403,13 @@ void rxrpc_unuse_local(struct rxrpc_local *local)
{
unsigned int au;
- au = atomic_dec_return(&local->active_users);
- if (au == 0)
- rxrpc_queue_local(local);
- else
- rxrpc_put_local(local);
+ if (local) {
+ au = atomic_dec_return(&local->active_users);
+ if (au == 0)
+ rxrpc_queue_local(local);
+ else
+ rxrpc_put_local(local);
+ }
}
/*