* [PATCH net] rxrpc: fix some null-ptr-deref bugs in server_key.c
@ 2022-03-30 14:22 David Howells
2022-03-31 10:43 ` Paolo Abeni
2022-03-31 13:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: David Howells @ 2022-03-30 14:22 UTC (permalink / raw)
To: netdev
Cc: Xiaolong Huang, Xiaolong Huang, Marc Dionne, linux-afs, dhowells,
linux-kernel
From: Xiaolong Huang <butterflyhuangxx@gmail.com>
Some function calls are not implemented in rxrpc_no_security, there are
preparse_server_key, free_preparse_server_key and destroy_server_key.
When rxrpc security type is rxrpc_no_security, user can easily trigger a
null-ptr-deref bug via ioctl. So judgment should be added to prevent it
The crash log:
user@syzkaller:~$ ./rxrpc_preparse_s
[ 37.956878][T15626] BUG: kernel NULL pointer dereference, address: 0000000000000000
[ 37.957645][T15626] #PF: supervisor instruction fetch in kernel mode
[ 37.958229][T15626] #PF: error_code(0x0010) - not-present page
[ 37.958762][T15626] PGD 4aadf067 P4D 4aadf067 PUD 4aade067 PMD 0
[ 37.959321][T15626] Oops: 0010 [#1] PREEMPT SMP
[ 37.959739][T15626] CPU: 0 PID: 15626 Comm: rxrpc_preparse_ Not tainted 5.17.0-01442-gb47d5a4f6b8d #43
[ 37.960588][T15626] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
[ 37.961474][T15626] RIP: 0010:0x0
[ 37.961787][T15626] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[ 37.962480][T15626] RSP: 0018:ffffc9000d9abdc0 EFLAGS: 00010286
[ 37.963018][T15626] RAX: ffffffff84335200 RBX: ffff888012a1ce80 RCX: 0000000000000000
[ 37.963727][T15626] RDX: 0000000000000000 RSI: ffffffff84a736dc RDI: ffffc9000d9abe48
[ 37.964425][T15626] RBP: ffffc9000d9abe48 R08: 0000000000000000 R09: 0000000000000002
[ 37.965118][T15626] R10: 000000000000000a R11: f000000000000000 R12: ffff888013145680
[ 37.965836][T15626] R13: 0000000000000000 R14: ffffffffffffffec R15: ffff8880432aba80
[ 37.966441][T15626] FS: 00007f2177907700(0000) GS:ffff88803ec00000(0000) knlGS:0000000000000000
[ 37.966979][T15626] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 37.967384][T15626] CR2: ffffffffffffffd6 CR3: 000000004aaf1000 CR4: 00000000000006f0
[ 37.967864][T15626] Call Trace:
[ 37.968062][T15626] <TASK>
[ 37.968240][T15626] rxrpc_preparse_s+0x59/0x90
[ 37.968541][T15626] key_create_or_update+0x174/0x510
[ 37.968863][T15626] __x64_sys_add_key+0x139/0x1d0
[ 37.969165][T15626] do_syscall_64+0x35/0xb0
[ 37.969451][T15626] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 37.969824][T15626] RIP: 0033:0x43a1f9
Signed-off-by: Xiaolong Huang <butterflyhuangxx@gmail.com>
Tested-by: Xiaolong Huang <butterflyhuangxx@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
Link: http://lists.infradead.org/pipermail/linux-afs/2022-March/005069.html
---
net/rxrpc/server_key.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/rxrpc/server_key.c b/net/rxrpc/server_key.c
index ead3471307ee..ee269e0e6ee8 100644
--- a/net/rxrpc/server_key.c
+++ b/net/rxrpc/server_key.c
@@ -84,6 +84,9 @@ static int rxrpc_preparse_s(struct key_preparsed_payload *prep)
prep->payload.data[1] = (struct rxrpc_security *)sec;
+ if (!sec->preparse_server_key)
+ return -EINVAL;
+
return sec->preparse_server_key(prep);
}
@@ -91,7 +94,7 @@ static void rxrpc_free_preparse_s(struct key_preparsed_payload *prep)
{
const struct rxrpc_security *sec = prep->payload.data[1];
- if (sec)
+ if (sec && sec->free_preparse_server_key)
sec->free_preparse_server_key(prep);
}
@@ -99,7 +102,7 @@ static void rxrpc_destroy_s(struct key *key)
{
const struct rxrpc_security *sec = key->payload.data[1];
- if (sec)
+ if (sec && sec->destroy_server_key)
sec->destroy_server_key(key);
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] rxrpc: fix some null-ptr-deref bugs in server_key.c
2022-03-30 14:22 [PATCH net] rxrpc: fix some null-ptr-deref bugs in server_key.c David Howells
@ 2022-03-31 10:43 ` Paolo Abeni
2022-03-31 12:16 ` David Howells
2022-03-31 13:30 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2022-03-31 10:43 UTC (permalink / raw)
To: David Howells, netdev
Cc: Xiaolong Huang, Marc Dionne, linux-afs, linux-kernel
On Wed, 2022-03-30 at 15:22 +0100, David Howells wrote:
> From: Xiaolong Huang <butterflyhuangxx@gmail.com>
>
> Some function calls are not implemented in rxrpc_no_security, there are
> preparse_server_key, free_preparse_server_key and destroy_server_key.
> When rxrpc security type is rxrpc_no_security, user can easily trigger a
> null-ptr-deref bug via ioctl. So judgment should be added to prevent it
>
> The crash log:
> user@syzkaller:~$ ./rxrpc_preparse_s
> [ 37.956878][T15626] BUG: kernel NULL pointer dereference, address: 0000000000000000
> [ 37.957645][T15626] #PF: supervisor instruction fetch in kernel mode
> [ 37.958229][T15626] #PF: error_code(0x0010) - not-present page
> [ 37.958762][T15626] PGD 4aadf067 P4D 4aadf067 PUD 4aade067 PMD 0
> [ 37.959321][T15626] Oops: 0010 [#1] PREEMPT SMP
> [ 37.959739][T15626] CPU: 0 PID: 15626 Comm: rxrpc_preparse_ Not tainted 5.17.0-01442-gb47d5a4f6b8d #43
> [ 37.960588][T15626] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
> [ 37.961474][T15626] RIP: 0010:0x0
> [ 37.961787][T15626] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
> [ 37.962480][T15626] RSP: 0018:ffffc9000d9abdc0 EFLAGS: 00010286
> [ 37.963018][T15626] RAX: ffffffff84335200 RBX: ffff888012a1ce80 RCX: 0000000000000000
> [ 37.963727][T15626] RDX: 0000000000000000 RSI: ffffffff84a736dc RDI: ffffc9000d9abe48
> [ 37.964425][T15626] RBP: ffffc9000d9abe48 R08: 0000000000000000 R09: 0000000000000002
> [ 37.965118][T15626] R10: 000000000000000a R11: f000000000000000 R12: ffff888013145680
> [ 37.965836][T15626] R13: 0000000000000000 R14: ffffffffffffffec R15: ffff8880432aba80
> [ 37.966441][T15626] FS: 00007f2177907700(0000) GS:ffff88803ec00000(0000) knlGS:0000000000000000
> [ 37.966979][T15626] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 37.967384][T15626] CR2: ffffffffffffffd6 CR3: 000000004aaf1000 CR4: 00000000000006f0
> [ 37.967864][T15626] Call Trace:
> [ 37.968062][T15626] <TASK>
> [ 37.968240][T15626] rxrpc_preparse_s+0x59/0x90
> [ 37.968541][T15626] key_create_or_update+0x174/0x510
> [ 37.968863][T15626] __x64_sys_add_key+0x139/0x1d0
> [ 37.969165][T15626] do_syscall_64+0x35/0xb0
> [ 37.969451][T15626] entry_SYSCALL_64_after_hwframe+0x44/0xae
> [ 37.969824][T15626] RIP: 0033:0x43a1f9
>
> Signed-off-by: Xiaolong Huang <butterflyhuangxx@gmail.com>
> Tested-by: Xiaolong Huang <butterflyhuangxx@gmail.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> Acked-by: Marc Dionne <marc.dionne@auristor.com>
> cc: linux-afs@lists.infradead.org
> Link: http://lists.infradead.org/pipermail/linux-afs/2022-March/005069.html
It looks like we can add a couple of fixes tag to help stable teams:
Fixes: d5953f6543b5 ("rxrpc: Allow security classes to give more info on server keys")
Fixes: 12da59fcab5a ("xrpc: Hand server key parsing off to the security class")
Does the above looks good to you?
Thanks!
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] rxrpc: fix some null-ptr-deref bugs in server_key.c
2022-03-31 10:43 ` Paolo Abeni
@ 2022-03-31 12:16 ` David Howells
2022-03-31 13:20 ` Paolo Abeni
0 siblings, 1 reply; 5+ messages in thread
From: David Howells @ 2022-03-31 12:16 UTC (permalink / raw)
To: Paolo Abeni
Cc: dhowells, netdev, Xiaolong Huang, Marc Dionne, linux-afs,
linux-kernel
Paolo Abeni <pabeni@redhat.com> wrote:
> It looks like we can add a couple of fixes tag to help stable teams:
>
> Fixes: d5953f6543b5 ("rxrpc: Allow security classes to give more info on server keys")
Not this one. This includes a check for the one op it adds:
+ if (sec && sec->describe_server_key)
+ sec->describe_server_key(key, m);
> Fixes: 12da59fcab5a ("xrpc: Hand server key parsing off to the security class")
There's a missing 'r' in "rxrpc:" in the patch subject, but otherwise this one
looks like the right one.
Thanks,
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] rxrpc: fix some null-ptr-deref bugs in server_key.c
2022-03-31 12:16 ` David Howells
@ 2022-03-31 13:20 ` Paolo Abeni
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2022-03-31 13:20 UTC (permalink / raw)
To: David Howells
Cc: netdev, Xiaolong Huang, Marc Dionne, linux-afs, linux-kernel
On Thu, 2022-03-31 at 13:16 +0100, David Howells wrote:
> Paolo Abeni <pabeni@redhat.com> wrote:
>
> > It looks like we can add a couple of fixes tag to help stable teams:
> >
> > Fixes: d5953f6543b5 ("rxrpc: Allow security classes to give more info on server keys")
>
> Not this one. This includes a check for the one op it adds:
>
> + if (sec && sec->describe_server_key)
> + sec->describe_server_key(key, m);
>
>
> > Fixes: 12da59fcab5a ("xrpc: Hand server key parsing off to the security class")
>
> There's a missing 'r' in "rxrpc:" in the patch subject, but otherwise this one
> looks like the right one.
Thank you for double-checking. No need to repost, I'll add the tag
while applying it.
Cheeers,
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] rxrpc: fix some null-ptr-deref bugs in server_key.c
2022-03-30 14:22 [PATCH net] rxrpc: fix some null-ptr-deref bugs in server_key.c David Howells
2022-03-31 10:43 ` Paolo Abeni
@ 2022-03-31 13:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-31 13:30 UTC (permalink / raw)
To: David Howells
Cc: netdev, butterflyhuangxx, marc.dionne, linux-afs, linux-kernel
Hello:
This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:
On Wed, 30 Mar 2022 15:22:14 +0100 you wrote:
> From: Xiaolong Huang <butterflyhuangxx@gmail.com>
>
> Some function calls are not implemented in rxrpc_no_security, there are
> preparse_server_key, free_preparse_server_key and destroy_server_key.
> When rxrpc security type is rxrpc_no_security, user can easily trigger a
> null-ptr-deref bug via ioctl. So judgment should be added to prevent it
>
> [...]
Here is the summary with links:
- [net] rxrpc: fix some null-ptr-deref bugs in server_key.c
https://git.kernel.org/netdev/net/c/ff8376ade4f6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-31 13:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-30 14:22 [PATCH net] rxrpc: fix some null-ptr-deref bugs in server_key.c David Howells
2022-03-31 10:43 ` Paolo Abeni
2022-03-31 12:16 ` David Howells
2022-03-31 13:20 ` Paolo Abeni
2022-03-31 13:30 ` patchwork-bot+netdevbpf
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).