* [PATCH net] rxrpc: Fix local refcounting
@ 2019-08-09 21:47 David Howells
2019-08-09 22:34 ` Jeffrey E Altman
2019-08-12 4:29 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: David Howells @ 2019-08-09 21:47 UTC (permalink / raw)
To: netdev; +Cc: dhowells, jaltman, linux-afs, linux-kernel
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>
---
net/rxrpc/local_object.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
index 9798159ee65f..c9db3e762d8d 100644
--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -402,11 +402,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);
+ }
}
/*
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] rxrpc: Fix local refcounting
2019-08-09 21:47 [PATCH net] rxrpc: Fix local refcounting David Howells
@ 2019-08-09 22:34 ` Jeffrey E Altman
2019-08-12 4:29 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey E Altman @ 2019-08-09 22:34 UTC (permalink / raw)
To: David Howells, netdev; +Cc: linux-afs, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 1932 bytes --]
David,
Looks good to me.
You can add a Reviewed-by line.
Thanks.
Jeffrey Altman
On 8/9/2019 5:47 PM, David Howells wrote:
> 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>
> ---
>
> net/rxrpc/local_object.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
> index 9798159ee65f..c9db3e762d8d 100644
> --- a/net/rxrpc/local_object.c
> +++ b/net/rxrpc/local_object.c
> @@ -402,11 +402,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);
> + }
> }
>
> /*
>
[-- Attachment #1.2: jaltman.vcf --]
[-- Type: text/x-vcard, Size: 283 bytes --]
begin:vcard
fn:Jeffrey Altman
n:Altman;Jeffrey
org:AuriStor, Inc.
adr:;;255 W 94TH ST STE 6B;New York;NY;10025-6985;United States
email;internet:jaltman@auristor.com
title:CEO
tel;work:+1-212-769-9018
url:https://www.linkedin.com/in/jeffreyaltman/
version:2.1
end:vcard
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4033 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] rxrpc: Fix local refcounting
2019-08-09 21:47 [PATCH net] rxrpc: Fix local refcounting David Howells
2019-08-09 22:34 ` Jeffrey E Altman
@ 2019-08-12 4:29 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-08-12 4:29 UTC (permalink / raw)
To: dhowells; +Cc: netdev, jaltman, linux-afs, linux-kernel
From: David Howells <dhowells@redhat.com>
Date: Fri, 09 Aug 2019 22:47:47 +0100
> 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>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-12 4:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 21:47 [PATCH net] rxrpc: Fix local refcounting David Howells
2019-08-09 22:34 ` Jeffrey E Altman
2019-08-12 4:29 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).