linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/4] sockmap, vsock: For connectible sockets allow only connected
@ 2025-02-13 11:58 Michal Luczaj
  2025-02-13 11:58 ` [PATCH net 1/4] " Michal Luczaj
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Michal Luczaj @ 2025-02-13 11:58 UTC (permalink / raw)
  To: John Fastabend, Jakub Sitnicki, Eric Dumazet, Kuniyuki Iwashima,
	Paolo Abeni, Willem de Bruijn, David S. Miller, Jakub Kicinski,
	Simon Horman, Stefano Garzarella, Michael S. Tsirkin,
	Bobby Eshleman, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Mykola Lysenko, Shuah Khan
  Cc: netdev, bpf, linux-kernel, linux-kselftest, Michal Luczaj

Series deals with one more case of vsock surprising BPF/sockmap by being
inconsistency about (having an) assigned transport.

KASAN: null-ptr-deref in range [0x0000000000000120-0x0000000000000127]
CPU: 7 UID: 0 PID: 56 Comm: kworker/7:0 Not tainted 6.14.0-rc1+
Workqueue: vsock-loopback vsock_loopback_work
RIP: 0010:vsock_read_skb+0x4b/0x90
Call Trace:
 sk_psock_verdict_data_ready+0xa4/0x2e0
 virtio_transport_recv_pkt+0x1ca8/0x2acc
 vsock_loopback_work+0x27d/0x3f0
 process_one_work+0x846/0x1420
 worker_thread+0x5b3/0xf80
 kthread+0x35a/0x700
 ret_from_fork+0x2d/0x70
 ret_from_fork_asm+0x1a/0x30

This bug, similarly to commit f6abafcd32f9 ("vsock/bpf: return early if
transport is not assigned"), could be fixed with a single NULL check. But
instead, let's explore another approach: take a hint from
vsock_bpf_update_proto() and teach sockmap to accept only vsocks that are
already connected (no risk of transport being dropped or reassigned). At
the same time straight reject the listeners (vsock listening sockets do not
carry any transport anyway). This way BPF does not have to worry about
vsk->transport becoming NULL.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
Michal Luczaj (4):
      sockmap, vsock: For connectible sockets allow only connected
      vsock/bpf: Warn on socket without transport
      selftest/bpf: Adapt vsock_delete_on_close to sockmap rejecting unconnected
      selftest/bpf: Add vsock test for sockmap rejecting unconnected

 net/core/sock_map.c                                |  3 +
 net/vmw_vsock/af_vsock.c                           |  3 +
 net/vmw_vsock/vsock_bpf.c                          |  2 +-
 .../selftests/bpf/prog_tests/sockmap_basic.c       | 70 ++++++++++++++++------
 4 files changed, 59 insertions(+), 19 deletions(-)
---
base-commit: 9c01a177c2e4b55d2bcce8a1f6bdd1d46a8320e3
change-id: 20250210-vsock-listen-sockmap-nullptr-e6e82ca79611

Best regards,
-- 
Michal Luczaj <mhal@rbox.co>


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

end of thread, other threads:[~2025-02-18 11:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 11:58 [PATCH net 0/4] sockmap, vsock: For connectible sockets allow only connected Michal Luczaj
2025-02-13 11:58 ` [PATCH net 1/4] " Michal Luczaj
2025-02-14 13:11   ` Michal Luczaj
2025-02-18  8:52     ` Stefano Garzarella
2025-02-13 11:58 ` [PATCH net 2/4] vsock/bpf: Warn on socket without transport Michal Luczaj
2025-02-17 10:59   ` Stefano Garzarella
2025-02-17 19:45     ` Michal Luczaj
2025-02-18  8:49       ` Stefano Garzarella
2025-02-13 11:58 ` [PATCH net 3/4] selftest/bpf: Adapt vsock_delete_on_close to sockmap rejecting unconnected Michal Luczaj
2025-02-18  8:53   ` Stefano Garzarella
2025-02-13 11:58 ` [PATCH net 4/4] selftest/bpf: Add vsock test for " Michal Luczaj
2025-02-14 13:12   ` Michal Luczaj
2025-02-18  8:54   ` Stefano Garzarella
2025-02-18 11:10 ` [PATCH net 0/4] sockmap, vsock: For connectible sockets allow only connected 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).