All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] virtio/vsock: avoid NULL deref in virtio_transport_seqpacket_allow()
@ 2021-06-21 14:53 Eric Dumazet
  2021-06-21 16:08 ` Stefano Garzarella
  2021-06-22 17:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2021-06-21 14:53 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: netdev, Eric Dumazet, Eric Dumazet, Arseny Krasnov, syzbot

From: Eric Dumazet <edumazet@google.com>

Make sure the_virtio_vsock is not NULL before dereferencing it.

general protection fault, probably for non-canonical address 0xdffffc0000000071: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000388-0x000000000000038f]
CPU: 0 PID: 8452 Comm: syz-executor406 Not tainted 5.13.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:virtio_transport_seqpacket_allow+0xbf/0x210 net/vmw_vsock/virtio_transport.c:503
Code: e8 c6 d9 ab f8 84 db 0f 84 0f 01 00 00 e8 09 d3 ab f8 48 8d bd 88 03 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 06 0f 8e 2a 01 00 00 44 0f b6 a5 88 03 00 00
RSP: 0018:ffffc90003757c18 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: 0000000000000001 RCX: 0000000000000000
RDX: 0000000000000071 RSI: ffffffff88c908e7 RDI: 0000000000000388
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: ffffffff88c90a06 R11: 0000000000000000 R12: 0000000000000000
R13: ffffffff88c90840 R14: 0000000000000000 R15: 0000000000000001
FS:  0000000001bee300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000082 CR3: 000000002847e000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 vsock_assign_transport+0x575/0x700 net/vmw_vsock/af_vsock.c:490
 vsock_connect+0x200/0xc00 net/vmw_vsock/af_vsock.c:1337
 __sys_connect_file+0x155/0x1a0 net/socket.c:1824
 __sys_connect+0x161/0x190 net/socket.c:1841
 __do_sys_connect net/socket.c:1851 [inline]
 __se_sys_connect net/socket.c:1848 [inline]
 __x64_sys_connect+0x6f/0xb0 net/socket.c:1848
 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x43ee69
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd49e7c788 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: ffffffffffffffda RBX: 0000000000400488 RCX: 000000000043ee69
RDX: 0000000000000010 RSI: 0000000020000080 RDI: 0000000000000003
RBP: 0000000000402e50 R08: 0000000000000000 R09: 0000000000400488
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000402ee0
R13: 0000000000000000 R14: 00000000004ac018 R15: 0000000000400488

Fixes: 53efbba12cc7 ("virtio/vsock: enable SEQPACKET for transport")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Arseny Krasnov <arseny.krasnov@kaspersky.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
---
 net/vmw_vsock/virtio_transport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index e73ce652bf3c3c291a12e95d26cdbd24747a7467..ed1664e7bd88840c4e336628efa76048e55f37c0 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -498,9 +498,11 @@ static bool virtio_transport_seqpacket_allow(u32 remote_cid)
 	struct virtio_vsock *vsock;
 	bool seqpacket_allow;
 
+	seqpacket_allow = false;
 	rcu_read_lock();
 	vsock = rcu_dereference(the_virtio_vsock);
-	seqpacket_allow = vsock->seqpacket_allow;
+	if (vsock)
+		seqpacket_allow = vsock->seqpacket_allow;
 	rcu_read_unlock();
 
 	return seqpacket_allow;
-- 
2.32.0.288.g62a8d224e6-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] virtio/vsock: avoid NULL deref in virtio_transport_seqpacket_allow()
  2021-06-21 14:53 [PATCH net-next] virtio/vsock: avoid NULL deref in virtio_transport_seqpacket_allow() Eric Dumazet
@ 2021-06-21 16:08 ` Stefano Garzarella
  2021-06-22 17:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2021-06-21 16:08 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, netdev, Eric Dumazet,
	Arseny Krasnov, syzbot

On Mon, Jun 21, 2021 at 07:53:48AM -0700, Eric Dumazet wrote:
>From: Eric Dumazet <edumazet@google.com>
>
>Make sure the_virtio_vsock is not NULL before dereferencing it.
>
>general protection fault, probably for non-canonical address 0xdffffc0000000071: 0000 [#1] PREEMPT SMP KASAN
>KASAN: null-ptr-deref in range [0x0000000000000388-0x000000000000038f]
>CPU: 0 PID: 8452 Comm: syz-executor406 Not tainted 5.13.0-rc6-syzkaller #0
>Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
>RIP: 0010:virtio_transport_seqpacket_allow+0xbf/0x210 net/vmw_vsock/virtio_transport.c:503
>Code: e8 c6 d9 ab f8 84 db 0f 84 0f 01 00 00 e8 09 d3 ab f8 48 8d bd 88 03 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 06 0f 8e 2a 01 00 00 44 0f b6 a5 88 03 00 00
>RSP: 0018:ffffc90003757c18 EFLAGS: 00010206
>RAX: dffffc0000000000 RBX: 0000000000000001 RCX: 0000000000000000
>RDX: 0000000000000071 RSI: ffffffff88c908e7 RDI: 0000000000000388
>RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
>R10: ffffffff88c90a06 R11: 0000000000000000 R12: 0000000000000000
>R13: ffffffff88c90840 R14: 0000000000000000 R15: 0000000000000001
>FS:  0000000001bee300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
>CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>CR2: 0000000020000082 CR3: 000000002847e000 CR4: 00000000001506f0
>DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>Call Trace:
> vsock_assign_transport+0x575/0x700 net/vmw_vsock/af_vsock.c:490
> vsock_connect+0x200/0xc00 net/vmw_vsock/af_vsock.c:1337
> __sys_connect_file+0x155/0x1a0 net/socket.c:1824
> __sys_connect+0x161/0x190 net/socket.c:1841
> __do_sys_connect net/socket.c:1851 [inline]
> __se_sys_connect net/socket.c:1848 [inline]
> __x64_sys_connect+0x6f/0xb0 net/socket.c:1848
> do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
> entry_SYSCALL_64_after_hwframe+0x44/0xae
>RIP: 0033:0x43ee69
>Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
>RSP: 002b:00007ffd49e7c788 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
>RAX: ffffffffffffffda RBX: 0000000000400488 RCX: 000000000043ee69
>RDX: 0000000000000010 RSI: 0000000020000080 RDI: 0000000000000003
>RBP: 0000000000402e50 R08: 0000000000000000 R09: 0000000000400488
>R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000402ee0
>R13: 0000000000000000 R14: 00000000004ac018 R15: 0000000000400488
>
>Fixes: 53efbba12cc7 ("virtio/vsock: enable SEQPACKET for transport")
>Signed-off-by: Eric Dumazet <edumazet@google.com>
>Cc: Arseny Krasnov <arseny.krasnov@kaspersky.com>
>Reported-by: syzbot <syzkaller@googlegroups.com>
>---
> net/vmw_vsock/virtio_transport.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
>index e73ce652bf3c3c291a12e95d26cdbd24747a7467..ed1664e7bd88840c4e336628efa76048e55f37c0 100644
>--- a/net/vmw_vsock/virtio_transport.c
>+++ b/net/vmw_vsock/virtio_transport.c
>@@ -498,9 +498,11 @@ static bool virtio_transport_seqpacket_allow(u32 remote_cid)
> 	struct virtio_vsock *vsock;
> 	bool seqpacket_allow;
>
>+	seqpacket_allow = false;
> 	rcu_read_lock();
> 	vsock = rcu_dereference(the_virtio_vsock);
>-	seqpacket_allow = vsock->seqpacket_allow;
>+	if (vsock)
>+		seqpacket_allow = vsock->seqpacket_allow;
> 	rcu_read_unlock();
>
> 	return seqpacket_allow;
>-- 
>2.32.0.288.g62a8d224e6-goog
>

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] virtio/vsock: avoid NULL deref in virtio_transport_seqpacket_allow()
  2021-06-21 14:53 [PATCH net-next] virtio/vsock: avoid NULL deref in virtio_transport_seqpacket_allow() Eric Dumazet
  2021-06-21 16:08 ` Stefano Garzarella
@ 2021-06-22 17:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-22 17:00 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, netdev, edumazet, arseny.krasnov, syzkaller

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Mon, 21 Jun 2021 07:53:48 -0700 you wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Make sure the_virtio_vsock is not NULL before dereferencing it.
> 
> general protection fault, probably for non-canonical address 0xdffffc0000000071: 0000 [#1] PREEMPT SMP KASAN
> KASAN: null-ptr-deref in range [0x0000000000000388-0x000000000000038f]
> CPU: 0 PID: 8452 Comm: syz-executor406 Not tainted 5.13.0-rc6-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:virtio_transport_seqpacket_allow+0xbf/0x210 net/vmw_vsock/virtio_transport.c:503
> Code: e8 c6 d9 ab f8 84 db 0f 84 0f 01 00 00 e8 09 d3 ab f8 48 8d bd 88 03 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 06 0f 8e 2a 01 00 00 44 0f b6 a5 88 03 00 00
> RSP: 0018:ffffc90003757c18 EFLAGS: 00010206
> RAX: dffffc0000000000 RBX: 0000000000000001 RCX: 0000000000000000
> RDX: 0000000000000071 RSI: ffffffff88c908e7 RDI: 0000000000000388
> RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
> R10: ffffffff88c90a06 R11: 0000000000000000 R12: 0000000000000000
> R13: ffffffff88c90840 R14: 0000000000000000 R15: 0000000000000001
> FS:  0000000001bee300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000000020000082 CR3: 000000002847e000 CR4: 00000000001506f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
>  vsock_assign_transport+0x575/0x700 net/vmw_vsock/af_vsock.c:490
>  vsock_connect+0x200/0xc00 net/vmw_vsock/af_vsock.c:1337
>  __sys_connect_file+0x155/0x1a0 net/socket.c:1824
>  __sys_connect+0x161/0x190 net/socket.c:1841
>  __do_sys_connect net/socket.c:1851 [inline]
>  __se_sys_connect net/socket.c:1848 [inline]
>  __x64_sys_connect+0x6f/0xb0 net/socket.c:1848
>  do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
>  entry_SYSCALL_64_after_hwframe+0x44/0xae
> RIP: 0033:0x43ee69
> Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
> RSP: 002b:00007ffd49e7c788 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
> RAX: ffffffffffffffda RBX: 0000000000400488 RCX: 000000000043ee69
> RDX: 0000000000000010 RSI: 0000000020000080 RDI: 0000000000000003
> RBP: 0000000000402e50 R08: 0000000000000000 R09: 0000000000400488
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000402ee0
> R13: 0000000000000000 R14: 00000000004ac018 R15: 0000000000400488
> 
> [...]

Here is the summary with links:
  - [net-next] virtio/vsock: avoid NULL deref in virtio_transport_seqpacket_allow()
    https://git.kernel.org/netdev/net-next/c/64295f0d01ae

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] 3+ messages in thread

end of thread, other threads:[~2021-06-22 17:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 14:53 [PATCH net-next] virtio/vsock: avoid NULL deref in virtio_transport_seqpacket_allow() Eric Dumazet
2021-06-21 16:08 ` Stefano Garzarella
2021-06-22 17:00 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.