| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/13 07:11 | flow | patch-triage |
2mArgs:null Results: {
"EnableConfigs": [
"VSOCKETS",
"VIRTIO_VSOCKETS",
"VIRTIO_VSOCKETS_COMMON",
"VSOCKETS_LOOPBACK",
"VIRTIO_PCI"
],
"FocusSymbols": [
"virtio_transport_recv_pkt_batch",
"virtio_transport_rx_batch_finish",
"virtio_transport_recv_pkt",
"virtio_transport_rx_work",
"virtio_transport_recv_pkt_batchable",
"virtio_transport_recv_connected"
],
"KMSANReasoning": "The patch implements an RX batching optimization for virtio-vsock, allowing a bounded run of packets (up to 64 packets or 64 KiB) destined for the same connected stream socket to be processed under a single socket lock, while deferring sk_data_ready and sk_write_space wakeups.\n\nMemory and state initialization review:\n- The newly introduced `struct virtio_transport_rx_batch` is allocated on the stack in `virtio_transport_rx_work` and explicitly zero-initialized (`= {}`).\n- All local flags and out-parameters (`start_batch`, `batchable`, `free_pkt`, `data_ready_pending`, `write_space_pending`) are properly initialized prior to branching or dereferencing.\n- The new callback pointers in `struct vsock_sock` (`default_data_ready`, `default_write_space`) are set upon socket creation in `__vsock_create()`.\n- No kernel structures are exported or copied to user space (no copy_to_user, put_user, netlink skb attrs, etc.).\n- The packet data handling and skb bounds checking are unchanged; `batch.bytes` and `batch.pkts` only bound the batch size.\n\nBug profile (KASAN/LOCKDEP vs. KMSAN):\nThe primary risks introduced by this change involve locking/concurrency (holding the socket lock across multiple packets, interactions with sockmap callbacks under callback locks) and socket reference counting (holding a socket reference across rx work iterations in `batch-\u003esk`), which could theoretically lead to use-after-free, refcount leaks, or deadlocks. These classes of bugs are thoroughly covered by KASAN, LOCKDEP, and standard refcount tracking. There are no uninitialized memory reads or information leak risks that would require KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false,
"Reasoning": "The patch introduces RX packet batching under a single socket lock for the virtio vsock transport. It adds logic to batch stream packets, defer callback invocations (sk_data_ready and sk_write_space), validate socket state consistency, and manage socket lock lifetimes across multiple RX descriptors. This reachable networking and virtio driver code is accessible in virtualized environments via AF_VSOCK sockets and virtio-vsock / loopback devices, making it an ideal target for syzkaller fuzzing.",
"WorthFuzzing": true
} |
| 1/1 | 2026/10/13 07:11 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit dcf73c5371be225c60de65291b49c22e335ba87b\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Tue Oct 13 07:11:06 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h\nindex f91704731057e..f1396ca3ad9b5 100644\n--- a/include/linux/virtio_vsock.h\n+++ b/include/linux/virtio_vsock.h\n@@ -282,6 +282,19 @@ void virtio_transport_destruct(struct vsock_sock *vsk);\n \n void virtio_transport_recv_pkt(struct virtio_transport *t,\n \t\t\t struct sk_buff *skb, struct net *net);\n+\n+struct virtio_transport_rx_batch {\n+\tstruct sock *sk;\n+\tunsigned int pkts;\n+\tsize_t bytes;\n+\tbool write_space_pending;\n+\tbool data_ready_pending;\n+};\n+\n+void virtio_transport_recv_pkt_batch(struct virtio_transport *t,\n+\t\t\t\t struct sk_buff *skb, struct net *net,\n+\t\t\t\t struct virtio_transport_rx_batch *batch);\n+void virtio_transport_rx_batch_finish(struct virtio_transport_rx_batch *batch);\n void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct sk_buff *skb);\n u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 wanted);\n void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit);\ndiff --git a/include/net/af_vsock.h b/include/net/af_vsock.h\nindex 5549298c1ec6b..a799f08556376 100644\n--- a/include/net/af_vsock.h\n+++ b/include/net/af_vsock.h\n@@ -63,6 +63,9 @@ struct vsock_sock {\n \tu32 peer_shutdown;\n \tbool sent_request;\n \tbool ignore_connecting_rst;\n+\t/* Initial callbacks, used to identify replacements. */\n+\tvoid (*default_data_ready)(struct sock *sk);\n+\tvoid (*default_write_space)(struct sock *sk);\n \n \t/* Protected by lock_sock(sk) */\n \tu64 buffer_size;\ndiff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c\nindex 44cee74519555..f40659ec29df0 100644\n--- a/net/vmw_vsock/af_vsock.c\n+++ b/net/vmw_vsock/af_vsock.c\n@@ -958,6 +958,8 @@ static struct sock *__vsock_create(struct net *net,\n \t\tsk-\u003esk_type = type;\n \n \tvsk = vsock_sk(sk);\n+\tvsk-\u003edefault_data_ready = sk-\u003esk_data_ready;\n+\tvsk-\u003edefault_write_space = sk-\u003esk_write_space;\n \tvsock_addr_init(\u0026vsk-\u003elocal_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);\n \tvsock_addr_init(\u0026vsk-\u003eremote_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);\n \ndiff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c\nindex 4f9aa9c4c3aa5..ef076732158d4 100644\n--- a/net/vmw_vsock/virtio_transport.c\n+++ b/net/vmw_vsock/virtio_transport.c\n@@ -629,8 +629,16 @@ virtio_transport_seqpacket_allow(struct vsock_sock *vsk, u32 remote_cid)\n \treturn seqpacket_allow;\n }\n \n+/*\n+ * Keep a bounded run of packets for one socket under a single socket lock.\n+ * Limit packet count and payload size to bound the work done while locked.\n+ */\n+#define VIRTIO_TRANSPORT_RX_BATCH_MAX_PKTS\t64\n+#define VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES\t(64 * 1024)\n+\n static void virtio_transport_rx_work(struct work_struct *work)\n {\n+\tstruct virtio_transport_rx_batch batch = {};\n \tstruct virtio_vsock *vsock =\n \t\tcontainer_of(work, struct virtio_vsock, rx_work);\n \tstruct virtqueue *vq;\n@@ -666,6 +674,7 @@ static void virtio_transport_rx_work(struct work_struct *work)\n \t\t\t/* Drop short/long packets */\n \t\t\tif (unlikely(len \u003c sizeof(*hdr) ||\n \t\t\t\t len \u003e virtio_vsock_skb_len(skb))) {\n+\t\t\t\tvirtio_transport_rx_batch_finish(\u0026batch);\n \t\t\t\tkfree_skb(skb);\n \t\t\t\tcontinue;\n \t\t\t}\n@@ -673,6 +682,7 @@ static void virtio_transport_rx_work(struct work_struct *work)\n \t\t\thdr = virtio_vsock_hdr(skb);\n \t\t\tpayload_len = le32_to_cpu(hdr-\u003elen);\n \t\t\tif (unlikely(payload_len \u003e len - sizeof(*hdr))) {\n+\t\t\t\tvirtio_transport_rx_batch_finish(\u0026batch);\n \t\t\t\tkfree_skb(skb);\n \t\t\t\tcontinue;\n \t\t\t}\n@@ -680,16 +690,33 @@ static void virtio_transport_rx_work(struct work_struct *work)\n \t\t\tif (payload_len)\n \t\t\t\tvirtio_vsock_skb_put(skb, payload_len);\n \n+\t\t\tif (batch.sk \u0026\u0026\n+\t\t\t payload_len \u003e VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES -\n+\t\t\t\t\t batch.bytes) {\n+\t\t\t\tvirtio_transport_rx_batch_finish(\u0026batch);\n+\t\t\t}\n+\n \t\t\tvirtio_transport_deliver_tap_pkt(skb);\n \n \t\t\t/* Force virtio-transport into global mode since it\n \t\t\t * does not yet support local-mode namespacing.\n \t\t\t */\n-\t\t\tvirtio_transport_recv_pkt(\u0026virtio_transport, skb, NULL);\n+\t\t\tvirtio_transport_recv_pkt_batch(\u0026virtio_transport, skb, NULL,\n+\t\t\t\t\t\t\t\u0026batch);\n+\n+\t\t\tif (batch.sk) {\n+\t\t\t\tbatch.pkts++;\n+\t\t\t\tbatch.bytes += payload_len;\n+\t\t\t\tif (batch.pkts \u003e= VIRTIO_TRANSPORT_RX_BATCH_MAX_PKTS ||\n+\t\t\t\t batch.bytes \u003e= VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES) {\n+\t\t\t\t\tvirtio_transport_rx_batch_finish(\u0026batch);\n+\t\t\t\t}\n+\t\t\t}\n \t\t}\n \t} while (!virtqueue_enable_cb(vq));\n \n out:\n+\tvirtio_transport_rx_batch_finish(\u0026batch);\n \tif (vsock-\u003erx_buf_nr \u003c vsock-\u003erx_buf_max_nr / 2)\n \t\tvirtio_vsock_rx_fill(vsock);\n out_nofill:\ndiff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c\nindex f225f53ed4bab..84822d6bfb958 100644\n--- a/net/vmw_vsock/virtio_transport_common.c\n+++ b/net/vmw_vsock/virtio_transport_common.c\n@@ -576,11 +576,16 @@ virtio_transport_collapse_rx_queue(struct virtio_vsock_sock *vvs,\n \tskb_queue_splice(\u0026new_queue, \u0026vvs-\u003erx_queue);\n }\n \n+static bool\n+virtio_transport_rx_skb_has_headroom(struct virtio_vsock_sock *vvs)\n+{\n+\treturn (u64)(skb_queue_len(\u0026vvs-\u003erx_queue) + 1) * SKB_TRUESIZE(0) \u003c=\n+\t\tvvs-\u003ebuf_alloc;\n+}\n+\n static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,\n \t\t\t\t\tu32 len)\n {\n-\tu64 skb_overhead = (skb_queue_len(\u0026vvs-\u003erx_queue) + 1) * SKB_TRUESIZE(0);\n-\n \t/* Allow at most buf_alloc * 2 total budget (payload + overhead),\n \t * similar to how SO_RCVBUF is doubled to reserve space for sk_buff\n \t * metadata. Check payload against buf_alloc to be sure the other\n@@ -588,7 +593,7 @@ static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,\n \t * queue growth.\n \t */\n \tif ((u64)vvs-\u003ebuf_used + len \u003e vvs-\u003ebuf_alloc ||\n-\t skb_overhead \u003e vvs-\u003ebuf_alloc)\n+\t !virtio_transport_rx_skb_has_headroom(vvs))\n \t\treturn false;\n \n \tvvs-\u003erx_bytes += len;\n@@ -1583,7 +1588,8 @@ virtio_transport_recv_enqueue(struct vsock_sock *vsk,\n \n static int\n virtio_transport_recv_connected(struct sock *sk,\n-\t\t\t\tstruct sk_buff *skb)\n+\t\t\t\tstruct sk_buff *skb,\n+\t\t\t\tbool *data_ready_pending)\n {\n \tstruct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);\n \tstruct vsock_sock *vsk = vsock_sk(sk);\n@@ -1602,7 +1608,13 @@ virtio_transport_recv_connected(struct sock *sk,\n \t\t\tvsock_remove_sock(vsk);\n \t\t\tbreak;\n \t\t}\n-\t\tvsock_data_ready(sk);\n+\t\tif (!data_ready_pending) {\n+\t\t\tvsock_data_ready(sk);\n+\t\t} else if (!*data_ready_pending \u0026\u0026\n+\t\t\t (vsock_stream_has_data(vsk) \u003e= sk-\u003esk_rcvlowat ||\n+\t\t\t sock_flag(sk, SOCK_DONE))) {\n+\t\t\t*data_ready_pending = true;\n+\t\t}\n \t\treturn err;\n \tcase VIRTIO_VSOCK_OP_CREDIT_REQUEST:\n \t\tvirtio_transport_send_credit_update(vsk);\n@@ -1774,84 +1786,96 @@ static bool virtio_transport_valid_type(u16 type)\n \t (type == VIRTIO_VSOCK_TYPE_SEQPACKET);\n }\n \n-/* We are under the virtio-vsock's vsock-\u003erx_lock or vhost-vsock's vq-\u003emutex\n- * lock.\n- */\n-void virtio_transport_recv_pkt(struct virtio_transport *t,\n-\t\t\t struct sk_buff *skb, struct net *net)\n+static struct sock *\n+virtio_transport_find_socket(struct sk_buff *skb, struct sockaddr_vm *src,\n+\t\t\t struct sockaddr_vm *dst, struct net *net)\n {\n \tstruct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);\n-\tstruct sockaddr_vm src, dst;\n-\tstruct vsock_sock *vsk;\n \tstruct sock *sk;\n-\tbool space_available;\n \n-\tvsock_addr_init(\u0026src, le64_to_cpu(hdr-\u003esrc_cid),\n-\t\t\tle32_to_cpu(hdr-\u003esrc_port));\n-\tvsock_addr_init(\u0026dst, le64_to_cpu(hdr-\u003edst_cid),\n-\t\t\tle32_to_cpu(hdr-\u003edst_port));\n-\n-\ttrace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,\n-\t\t\t\t\tdst.svm_cid, dst.svm_port,\n-\t\t\t\t\tle32_to_cpu(hdr-\u003elen),\n-\t\t\t\t\tle16_to_cpu(hdr-\u003etype),\n-\t\t\t\t\tle16_to_cpu(hdr-\u003eop),\n-\t\t\t\t\tle32_to_cpu(hdr-\u003eflags),\n-\t\t\t\t\tle32_to_cpu(hdr-\u003ebuf_alloc),\n-\t\t\t\t\tle32_to_cpu(hdr-\u003efwd_cnt));\n-\n-\tif (!virtio_transport_valid_type(le16_to_cpu(hdr-\u003etype))) {\n-\t\t(void)virtio_transport_reset_no_sock(t, skb, net);\n-\t\tgoto free_pkt;\n-\t}\n+\tif (!virtio_transport_valid_type(le16_to_cpu(hdr-\u003etype)))\n+\t\treturn NULL;\n \n-\t/* The socket must be in connected or bound table\n-\t * otherwise send reset back\n-\t */\n-\tsk = vsock_find_connected_socket_net(\u0026src, \u0026dst, net);\n-\tif (!sk) {\n-\t\tsk = vsock_find_bound_socket_net(\u0026dst, net);\n-\t\tif (!sk) {\n-\t\t\t(void)virtio_transport_reset_no_sock(t, skb, net);\n-\t\t\tgoto free_pkt;\n-\t\t}\n-\t}\n+\tsk = vsock_find_connected_socket_net(src, dst, net);\n+\tif (!sk)\n+\t\tsk = vsock_find_bound_socket_net(dst, net);\n+\tif (!sk)\n+\t\treturn NULL;\n \n \tif (virtio_transport_get_type(sk) != le16_to_cpu(hdr-\u003etype)) {\n-\t\t(void)virtio_transport_reset_no_sock(t, skb, net);\n \t\tsock_put(sk);\n-\t\tgoto free_pkt;\n+\t\treturn NULL;\n \t}\n \n-\tif (!skb_set_owner_sk_safe(skb, sk)) {\n-\t\tWARN_ONCE(1, \"receiving vsock socket has sk_refcnt == 0\\n\");\n-\t\tgoto free_pkt;\n-\t}\n+\treturn sk;\n+}\n \n-\tvsk = vsock_sk(sk);\n+static bool\n+virtio_transport_sock_has_psock(const struct sock *sk)\n+{\n+\treturn (uintptr_t)rcu_access_pointer(__sk_user_data(sk)) \u0026\n+\t SK_USER_DATA_PSOCK;\n+}\n \n-\tlock_sock(sk);\n+static bool\n+virtio_transport_recv_pkt_batchable(struct virtio_transport *t,\n+\t\t\t\t struct sock *sk)\n+{\n+\tstruct vsock_sock *vsk = vsock_sk(sk);\n+\tstruct virtio_vsock_sock *vvs = vsk-\u003etrans;\n+\n+\treturn sk-\u003esk_state == TCP_ESTABLISHED \u0026\u0026\n+\t sk-\u003esk_type == SOCK_STREAM \u0026\u0026\n+\t READ_ONCE(sk-\u003esk_prot) == sk-\u003esk_prot_creator \u0026\u0026\n+\t READ_ONCE(sk-\u003esk_data_ready) == vsk-\u003edefault_data_ready \u0026\u0026\n+\t READ_ONCE(sk-\u003esk_write_space) == vsk-\u003edefault_write_space \u0026\u0026\n+\t !sock_flag(sk, SOCK_DONE) \u0026\u0026\n+\t vsk-\u003etransport == \u0026t-\u003etransport \u0026\u0026\n+\t vvs \u0026\u0026 virtio_transport_rx_skb_has_headroom(vvs) \u0026\u0026\n+\t !virtio_transport_sock_has_psock(sk);\n+}\n \n-\t/* Check if sk has been closed or assigned to another transport before\n-\t * lock_sock (note: listener sockets are not assigned to any transport)\n+/*\n+ * The caller holds sk's socket lock. Set @batchable if the socket can remain\n+ * locked for another ordinary STREAM/RW packet. Return true if the caller\n+ * must free @skb.\n+ */\n+static bool\n+virtio_transport_recv_pkt_locked(struct virtio_transport *t,\n+\t\t\t\t struct sk_buff *skb, struct sock *sk,\n+\t\t\t\t const struct sockaddr_vm *src,\n+\t\t\t\t const struct sockaddr_vm *dst,\n+\t\t\t\t struct net *net, bool *batchable,\n+\t\t\t\t struct virtio_transport_rx_batch *batch)\n+{\n+\tstruct vsock_sock *vsk = vsock_sk(sk);\n+\tbool space_available;\n+\n+\tif (batchable)\n+\t\t*batchable = false;\n+\n+\t/* Listener sockets accept packets from any source and are not assigned to\n+\t * a transport.\n \t */\n \tif (sock_flag(sk, SOCK_DONE) ||\n \t (sk-\u003esk_state != TCP_LISTEN \u0026\u0026\n-\t !vsock_check_source(vsk, \u0026t-\u003etransport, \u0026src))) {\n+\t !vsock_check_source(vsk, \u0026t-\u003etransport, src))) {\n \t\t(void)virtio_transport_reset_no_sock(t, skb, net);\n-\t\trelease_sock(sk);\n-\t\tsock_put(sk);\n-\t\tgoto free_pkt;\n+\t\treturn true;\n \t}\n \n \tspace_available = virtio_transport_space_update(sk, skb);\n \n \t/* Update CID in case it has changed after a transport reset event */\n \tif (vsk-\u003elocal_addr.svm_cid != VMADDR_CID_ANY)\n-\t\tvsk-\u003elocal_addr.svm_cid = dst.svm_cid;\n+\t\tvsk-\u003elocal_addr.svm_cid = dst-\u003esvm_cid;\n \n-\tif (space_available)\n-\t\tsk-\u003esk_write_space(sk);\n+\tif (space_available) {\n+\t\tif (batch)\n+\t\t\tbatch-\u003ewrite_space_pending = true;\n+\t\telse\n+\t\t\tsk-\u003esk_write_space(sk);\n+\t}\n \n \tswitch (sk-\u003esk_state) {\n \tcase TCP_LISTEN:\n@@ -1863,7 +1887,9 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,\n \t\tkfree_skb(skb);\n \t\tbreak;\n \tcase TCP_ESTABLISHED:\n-\t\tvirtio_transport_recv_connected(sk, skb);\n+\t\tvirtio_transport_recv_connected(sk, skb,\n+\t\t\t\t\t\tbatch ?\n+\t\t\t\t\t\t\u0026batch-\u003edata_ready_pending : NULL);\n \t\tbreak;\n \tcase TCP_CLOSING:\n \t\tvirtio_transport_recv_disconnecting(sk, skb);\n@@ -1875,12 +1901,59 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,\n \t\tbreak;\n \t}\n \n+\tif (batchable)\n+\t\t*batchable = virtio_transport_recv_pkt_batchable(t, sk);\n+\n+\treturn false;\n+}\n+\n+/* We are under the virtio-vsock's vsock-\u003erx_lock or vhost-vsock's vq-\u003emutex\n+ * lock.\n+ */\n+void virtio_transport_recv_pkt(struct virtio_transport *t,\n+\t\t\t struct sk_buff *skb, struct net *net)\n+{\n+\tstruct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);\n+\tstruct sockaddr_vm src, dst;\n+\tstruct sock *sk;\n+\tbool free_pkt;\n+\n+\tvsock_addr_init(\u0026src, le64_to_cpu(hdr-\u003esrc_cid),\n+\t\t\tle32_to_cpu(hdr-\u003esrc_port));\n+\tvsock_addr_init(\u0026dst, le64_to_cpu(hdr-\u003edst_cid),\n+\t\t\tle32_to_cpu(hdr-\u003edst_port));\n+\n+\ttrace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,\n+\t\t\t\t\tdst.svm_cid, dst.svm_port,\n+\t\t\t\t\tle32_to_cpu(hdr-\u003elen),\n+\t\t\t\t\tle16_to_cpu(hdr-\u003etype),\n+\t\t\t\t\tle16_to_cpu(hdr-\u003eop),\n+\t\t\t\t\tle32_to_cpu(hdr-\u003eflags),\n+\t\t\t\t\tle32_to_cpu(hdr-\u003ebuf_alloc),\n+\t\t\t\t\tle32_to_cpu(hdr-\u003efwd_cnt));\n+\n+\tsk = virtio_transport_find_socket(skb, \u0026src, \u0026dst, net);\n+\tif (!sk) {\n+\t\t(void)virtio_transport_reset_no_sock(t, skb, net);\n+\t\tgoto free_pkt;\n+\t}\n+\n+\tif (!skb_set_owner_sk_safe(skb, sk)) {\n+\t\tWARN_ONCE(1, \"receiving vsock socket has sk_refcnt == 0\\n\");\n+\t\tgoto free_pkt;\n+\t}\n+\n+\tlock_sock(sk);\n+\tfree_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, \u0026src, \u0026dst,\n+\t\t\t\t\t\t net, NULL, NULL);\n \trelease_sock(sk);\n \n \t/* Release refcnt obtained when we fetched this socket out of the\n \t * bound or connected list.\n \t */\n \tsock_put(sk);\n+\tif (free_pkt)\n+\t\tkfree_skb(skb);\n \treturn;\n \n free_pkt:\n@@ -1888,6 +1961,148 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,\n }\n EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt);\n \n+/*\n+ * Finish the RX batch.\n+ * For a non-empty batch, the caller must hold the socket lock acquired with\n+ * lock_sock(). This function releases the lock and the batch's lookup\n+ * reference.\n+ * An empty batch is a no-op.\n+ */\n+void virtio_transport_rx_batch_finish(struct virtio_transport_rx_batch *batch)\n+{\n+\tbool write_space_pending = batch-\u003ewrite_space_pending;\n+\tbool data_ready_pending = batch-\u003edata_ready_pending;\n+\tstruct sock *sk = batch-\u003esk;\n+\n+\tbatch-\u003esk = NULL;\n+\tbatch-\u003epkts = 0;\n+\tbatch-\u003ebytes = 0;\n+\tbatch-\u003ewrite_space_pending = false;\n+\tbatch-\u003edata_ready_pending = false;\n+\n+\tif (!sk)\n+\t\treturn;\n+\n+\tif (write_space_pending)\n+\t\tvsock_sk(sk)-\u003edefault_write_space(sk);\n+\n+\trelease_sock(sk);\n+\n+\tif (data_ready_pending)\n+\t\tvsock_sk(sk)-\u003edefault_data_ready(sk);\n+\n+\tsock_put(sk);\n+}\n+EXPORT_SYMBOL_GPL(virtio_transport_rx_batch_finish);\n+\n+void virtio_transport_recv_pkt_batch(struct virtio_transport *t,\n+\t\t\t\t struct sk_buff *skb, struct net *net,\n+\t\t\t\t struct virtio_transport_rx_batch *batch)\n+{\n+\tstruct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);\n+\tstruct sockaddr_vm src, dst;\n+\tstruct vsock_sock *vsk;\n+\tbool batchable, start_batch;\n+\tstruct sock *sk;\n+\tbool free_pkt;\n+\n+\t/* Only STREAM/RW packets can share a socket lock. */\n+\tif (le16_to_cpu(hdr-\u003etype) != VIRTIO_VSOCK_TYPE_STREAM ||\n+\t le16_to_cpu(hdr-\u003eop) != VIRTIO_VSOCK_OP_RW) {\n+\t\tvirtio_transport_rx_batch_finish(batch);\n+\t\tvirtio_transport_recv_pkt(t, skb, net);\n+\t\treturn;\n+\t}\n+\n+\tvsock_addr_init(\u0026src, le64_to_cpu(hdr-\u003esrc_cid),\n+\t\t\tle32_to_cpu(hdr-\u003esrc_port));\n+\tvsock_addr_init(\u0026dst, le64_to_cpu(hdr-\u003edst_cid),\n+\t\t\tle32_to_cpu(hdr-\u003edst_port));\n+\n+\ttrace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,\n+\t\t\t\t\tdst.svm_cid, dst.svm_port,\n+\t\t\t\t\tle32_to_cpu(hdr-\u003elen),\n+\t\t\t\t\tle16_to_cpu(hdr-\u003etype),\n+\t\t\t\t\tle16_to_cpu(hdr-\u003eop),\n+\t\t\t\t\tle32_to_cpu(hdr-\u003eflags),\n+\t\t\t\t\tle32_to_cpu(hdr-\u003ebuf_alloc),\n+\t\t\t\t\tle32_to_cpu(hdr-\u003efwd_cnt));\n+\n+\tif (batch-\u003esk) {\n+\t\tvsk = vsock_sk(batch-\u003esk);\n+\t\tif (vsock_addr_equals_addr(\u0026src, \u0026vsk-\u003eremote_addr) \u0026\u0026\n+\t\t dst.svm_port == vsk-\u003elocal_addr.svm_port \u0026\u0026\n+\t\t vsock_net_check_mode(sock_net(batch-\u003esk), net) \u0026\u0026\n+\t\t virtio_transport_recv_pkt_batchable(t, batch-\u003esk)) {\n+\t\t\tsk = batch-\u003esk;\n+\t\t\tif (!skb_set_owner_sk_safe(skb, sk)) {\n+\t\t\t\tWARN_ONCE(1, \"receiving vsock socket has sk_refcnt == 0\\n\");\n+\t\t\t\tvirtio_transport_rx_batch_finish(batch);\n+\t\t\t\tkfree_skb(skb);\n+\t\t\t\treturn;\n+\t\t\t}\n+\n+\t\t\tfree_pkt = virtio_transport_recv_pkt_locked(t, skb, sk,\n+\t\t\t\t\t\t\t\t \u0026src, \u0026dst,\n+\t\t\t\t\t\t\t\t net,\n+\t\t\t\t\t\t\t\t \u0026batchable,\n+\t\t\t\t\t\t\t\t batch);\n+\t\t\tif (!batchable)\n+\t\t\t\tvirtio_transport_rx_batch_finish(batch);\n+\t\t\tif (free_pkt)\n+\t\t\t\tkfree_skb(skb);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tvirtio_transport_rx_batch_finish(batch);\n+\t}\n+\n+\tsk = virtio_transport_find_socket(skb, \u0026src, \u0026dst, net);\n+\tif (!sk) {\n+\t\t(void)virtio_transport_reset_no_sock(t, skb, net);\n+\t\tkfree_skb(skb);\n+\t\treturn;\n+\t}\n+\n+\tif (!skb_set_owner_sk_safe(skb, sk)) {\n+\t\tWARN_ONCE(1, \"receiving vsock socket has sk_refcnt == 0\\n\");\n+\t\tkfree_skb(skb);\n+\t\treturn;\n+\t}\n+\n+\tlock_sock(sk);\n+\t/*\n+\t * Sockmap teardown restores callbacks under sk_callback_lock. Keep the\n+\t * initial eligibility check consistent with that update.\n+\t */\n+\tread_lock_bh(\u0026sk-\u003esk_callback_lock);\n+\tstart_batch = virtio_transport_recv_pkt_batchable(t, sk);\n+\tread_unlock_bh(\u0026sk-\u003esk_callback_lock);\n+\n+\tif (start_batch)\n+\t\tbatch-\u003esk = sk;\n+\n+\tfree_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, \u0026src, \u0026dst,\n+\t\t\t\t\t\t net,\n+\t\t\t\t\t\t start_batch ? \u0026batchable : NULL,\n+\t\t\t\t\t\t start_batch ? batch : NULL);\n+\tif (start_batch \u0026\u0026 batchable) {\n+\t\t/* Keep the lookup reference until the batch is released. */\n+\t\treturn;\n+\t}\n+\n+\tif (start_batch) {\n+\t\tvirtio_transport_rx_batch_finish(batch);\n+\t} else {\n+\t\trelease_sock(sk);\n+\t\tsock_put(sk);\n+\t}\n+\n+\tif (free_pkt)\n+\t\tkfree_skb(skb);\n+}\n+EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt_batch);\n+\n /* Remove skbs found in a queue that have a vsk that matches.\n *\n * Each skb is freed.\n"
} |
| 2/1 | 2026/10/13 07:11 | agent | patch-evaluator |
2mModel:core Args: null Results: {
"EnableConfigs": [
"VSOCKETS",
"VIRTIO_VSOCKETS",
"VIRTIO_VSOCKETS_COMMON",
"VSOCKETS_LOOPBACK",
"VIRTIO_PCI"
],
"FocusSymbols": [
"virtio_transport_recv_pkt_batch",
"virtio_transport_rx_batch_finish",
"virtio_transport_recv_pkt",
"virtio_transport_rx_work",
"virtio_transport_recv_pkt_batchable",
"virtio_transport_recv_connected"
],
"Reasoning": "The patch introduces RX packet batching under a single socket lock for the virtio vsock transport. It adds logic to batch stream packets, defer callback invocations (sk_data_ready and sk_write_space), validate socket state consistency, and manage socket lock lifetimes across multiple RX descriptors. This reachable networking and virtio driver code is accessible in virtualized environments via AF_VSOCK sockets and virtio-vsock / loopback devices, making it an ideal target for syzkaller fuzzing.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit dcf73c5371be225c60de65291b49c22e335ba87b
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Oct 13 07:11:06 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h
index f91704731057e..f1396ca3ad9b5 100644
--- a/include/linux/virtio_vsock.h
+++ b/include/linux/virtio_vsock.h
@@ -282,6 +282,19 @@ void virtio_transport_destruct(struct vsock_sock *vsk);
void virtio_transport_recv_pkt(struct virtio_transport *t,
struct sk_buff *skb, struct net *net);
+
+struct virtio_transport_rx_batch {
+ struct sock *sk;
+ unsigned int pkts;
+ size_t bytes;
+ bool write_space_pending;
+ bool data_ready_pending;
+};
+
+void virtio_transport_recv_pkt_batch(struct virtio_transport *t,
+ struct sk_buff *skb, struct net *net,
+ struct virtio_transport_rx_batch *batch);
+void virtio_transport_rx_batch_finish(struct virtio_transport_rx_batch *batch);
void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct sk_buff *skb);
u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 wanted);
void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit);
diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 5549298c1ec6b..a799f08556376 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -63,6 +63,9 @@ struct vsock_sock {
u32 peer_shutdown;
bool sent_request;
bool ignore_connecting_rst;
+ /* Initial callbacks, used to identify replacements. */
+ void (*default_data_ready)(struct sock *sk);
+ void (*default_write_space)(struct sock *sk);
/* Protected by lock_sock(sk) */
u64 buffer_size;
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 44cee74519555..f40659ec29df0 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -958,6 +958,8 @@ static struct sock *__vsock_create(struct net *net,
sk->sk_type = type;
vsk = vsock_sk(sk);
+ vsk->default_data_ready = sk->sk_data_ready;
+ vsk->default_write_space = sk->sk_write_space;
vsock_addr_init(&vsk->local_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);
vsock_addr_init(&vsk->remote_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 4f9aa9c4c3aa5..ef076732158d4 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -629,8 +629,16 @@ virtio_transport_seqpacket_allow(struct vsock_sock *vsk, u32 remote_cid)
return seqpacket_allow;
}
+/*
+ * Keep a bounded run of packets for one socket under a single socket lock.
+ * Limit packet count and payload size to bound the work done while locked.
+ */
+#define VIRTIO_TRANSPORT_RX_BATCH_MAX_PKTS 64
+#define VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES (64 * 1024)
+
static void virtio_transport_rx_work(struct work_struct *work)
{
+ struct virtio_transport_rx_batch batch = {};
struct virtio_vsock *vsock =
container_of(work, struct virtio_vsock, rx_work);
struct virtqueue *vq;
@@ -666,6 +674,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
/* Drop short/long packets */
if (unlikely(len < sizeof(*hdr) ||
len > virtio_vsock_skb_len(skb))) {
+ virtio_transport_rx_batch_finish(&batch);
kfree_skb(skb);
continue;
}
@@ -673,6 +682,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
hdr = virtio_vsock_hdr(skb);
payload_len = le32_to_cpu(hdr->len);
if (unlikely(payload_len > len - sizeof(*hdr))) {
+ virtio_transport_rx_batch_finish(&batch);
kfree_skb(skb);
continue;
}
@@ -680,16 +690,33 @@ static void virtio_transport_rx_work(struct work_struct *work)
if (payload_len)
virtio_vsock_skb_put(skb, payload_len);
+ if (batch.sk &&
+ payload_len > VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES -
+ batch.bytes) {
+ virtio_transport_rx_batch_finish(&batch);
+ }
+
virtio_transport_deliver_tap_pkt(skb);
/* Force virtio-transport into global mode since it
* does not yet support local-mode namespacing.
*/
- virtio_transport_recv_pkt(&virtio_transport, skb, NULL);
+ virtio_transport_recv_pkt_batch(&virtio_transport, skb, NULL,
+ &batch);
+
+ if (batch.sk) {
+ batch.pkts++;
+ batch.bytes += payload_len;
+ if (batch.pkts >= VIRTIO_TRANSPORT_RX_BATCH_MAX_PKTS ||
+ batch.bytes >= VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES) {
+ virtio_transport_rx_batch_finish(&batch);
+ }
+ }
}
} while (!virtqueue_enable_cb(vq));
out:
+ virtio_transport_rx_batch_finish(&batch);
if (vsock->rx_buf_nr < vsock->rx_buf_max_nr / 2)
virtio_vsock_rx_fill(vsock);
out_nofill:
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index f225f53ed4bab..84822d6bfb958 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -576,11 +576,16 @@ virtio_transport_collapse_rx_queue(struct virtio_vsock_sock *vvs,
skb_queue_splice(&new_queue, &vvs->rx_queue);
}
+static bool
+virtio_transport_rx_skb_has_headroom(struct virtio_vsock_sock *vvs)
+{
+ return (u64)(skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0) <=
+ vvs->buf_alloc;
+}
+
static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,
u32 len)
{
- u64 skb_overhead = (skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
-
/* Allow at most buf_alloc * 2 total budget (payload + overhead),
* similar to how SO_RCVBUF is doubled to reserve space for sk_buff
* metadata. Check payload against buf_alloc to be sure the other
@@ -588,7 +593,7 @@ static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,
* queue growth.
*/
if ((u64)vvs->buf_used + len > vvs->buf_alloc ||
- skb_overhead > vvs->buf_alloc)
+ !virtio_transport_rx_skb_has_headroom(vvs))
return false;
vvs->rx_bytes += len;
@@ -1583,7 +1588,8 @@ virtio_transport_recv_enqueue(struct vsock_sock *vsk,
static int
virtio_transport_recv_connected(struct sock *sk,
- struct sk_buff *skb)
+ struct sk_buff *skb,
+ bool *data_ready_pending)
{
struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
struct vsock_sock *vsk = vsock_sk(sk);
@@ -1602,7 +1608,13 @@ virtio_transport_recv_connected(struct sock *sk,
vsock_remove_sock(vsk);
break;
}
- vsock_data_ready(sk);
+ if (!data_ready_pending) {
+ vsock_data_ready(sk);
+ } else if (!*data_ready_pending &&
+ (vsock_stream_has_data(vsk) >= sk->sk_rcvlowat ||
+ sock_flag(sk, SOCK_DONE))) {
+ *data_ready_pending = true;
+ }
return err;
case VIRTIO_VSOCK_OP_CREDIT_REQUEST:
virtio_transport_send_credit_update(vsk);
@@ -1774,84 +1786,96 @@ static bool virtio_transport_valid_type(u16 type)
(type == VIRTIO_VSOCK_TYPE_SEQPACKET);
}
-/* We are under the virtio-vsock's vsock->rx_lock or vhost-vsock's vq->mutex
- * lock.
- */
-void virtio_transport_recv_pkt(struct virtio_transport *t,
- struct sk_buff *skb, struct net *net)
+static struct sock *
+virtio_transport_find_socket(struct sk_buff *skb, struct sockaddr_vm *src,
+ struct sockaddr_vm *dst, struct net *net)
{
struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
- struct sockaddr_vm src, dst;
- struct vsock_sock *vsk;
struct sock *sk;
- bool space_available;
- vsock_addr_init(&src, le64_to_cpu(hdr->src_cid),
- le32_to_cpu(hdr->src_port));
- vsock_addr_init(&dst, le64_to_cpu(hdr->dst_cid),
- le32_to_cpu(hdr->dst_port));
-
- trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
- dst.svm_cid, dst.svm_port,
- le32_to_cpu(hdr->len),
- le16_to_cpu(hdr->type),
- le16_to_cpu(hdr->op),
- le32_to_cpu(hdr->flags),
- le32_to_cpu(hdr->buf_alloc),
- le32_to_cpu(hdr->fwd_cnt));
-
- if (!virtio_transport_valid_type(le16_to_cpu(hdr->type))) {
- (void)virtio_transport_reset_no_sock(t, skb, net);
- goto free_pkt;
- }
+ if (!virtio_transport_valid_type(le16_to_cpu(hdr->type)))
+ return NULL;
- /* The socket must be in connected or bound table
- * otherwise send reset back
- */
- sk = vsock_find_connected_socket_net(&src, &dst, net);
- if (!sk) {
- sk = vsock_find_bound_socket_net(&dst, net);
- if (!sk) {
- (void)virtio_transport_reset_no_sock(t, skb, net);
- goto free_pkt;
- }
- }
+ sk = vsock_find_connected_socket_net(src, dst, net);
+ if (!sk)
+ sk = vsock_find_bound_socket_net(dst, net);
+ if (!sk)
+ return NULL;
if (virtio_transport_get_type(sk) != le16_to_cpu(hdr->type)) {
- (void)virtio_transport_reset_no_sock(t, skb, net);
sock_put(sk);
- goto free_pkt;
+ return NULL;
}
- if (!skb_set_owner_sk_safe(skb, sk)) {
- WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
- goto free_pkt;
- }
+ return sk;
+}
- vsk = vsock_sk(sk);
+static bool
+virtio_transport_sock_has_psock(const struct sock *sk)
+{
+ return (uintptr_t)rcu_access_pointer(__sk_user_data(sk)) &
+ SK_USER_DATA_PSOCK;
+}
- lock_sock(sk);
+static bool
+virtio_transport_recv_pkt_batchable(struct virtio_transport *t,
+ struct sock *sk)
+{
+ struct vsock_sock *vsk = vsock_sk(sk);
+ struct virtio_vsock_sock *vvs = vsk->trans;
+
+ return sk->sk_state == TCP_ESTABLISHED &&
+ sk->sk_type == SOCK_STREAM &&
+ READ_ONCE(sk->sk_prot) == sk->sk_prot_creator &&
+ READ_ONCE(sk->sk_data_ready) == vsk->default_data_ready &&
+ READ_ONCE(sk->sk_write_space) == vsk->default_write_space &&
+ !sock_flag(sk, SOCK_DONE) &&
+ vsk->transport == &t->transport &&
+ vvs && virtio_transport_rx_skb_has_headroom(vvs) &&
+ !virtio_transport_sock_has_psock(sk);
+}
- /* Check if sk has been closed or assigned to another transport before
- * lock_sock (note: listener sockets are not assigned to any transport)
+/*
+ * The caller holds sk's socket lock. Set @batchable if the socket can remain
+ * locked for another ordinary STREAM/RW packet. Return true if the caller
+ * must free @skb.
+ */
+static bool
+virtio_transport_recv_pkt_locked(struct virtio_transport *t,
+ struct sk_buff *skb, struct sock *sk,
+ const struct sockaddr_vm *src,
+ const struct sockaddr_vm *dst,
+ struct net *net, bool *batchable,
+ struct virtio_transport_rx_batch *batch)
+{
+ struct vsock_sock *vsk = vsock_sk(sk);
+ bool space_available;
+
+ if (batchable)
+ *batchable = false;
+
+ /* Listener sockets accept packets from any source and are not assigned to
+ * a transport.
*/
if (sock_flag(sk, SOCK_DONE) ||
(sk->sk_state != TCP_LISTEN &&
- !vsock_check_source(vsk, &t->transport, &src))) {
+ !vsock_check_source(vsk, &t->transport, src))) {
(void)virtio_transport_reset_no_sock(t, skb, net);
- release_sock(sk);
- sock_put(sk);
- goto free_pkt;
+ return true;
}
space_available = virtio_transport_space_update(sk, skb);
/* Update CID in case it has changed after a transport reset event */
if (vsk->local_addr.svm_cid != VMADDR_CID_ANY)
- vsk->local_addr.svm_cid = dst.svm_cid;
+ vsk->local_addr.svm_cid = dst->svm_cid;
- if (space_available)
- sk->sk_write_space(sk);
+ if (space_available) {
+ if (batch)
+ batch->write_space_pending = true;
+ else
+ sk->sk_write_space(sk);
+ }
switch (sk->sk_state) {
case TCP_LISTEN:
@@ -1863,7 +1887,9 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
kfree_skb(skb);
break;
case TCP_ESTABLISHED:
- virtio_transport_recv_connected(sk, skb);
+ virtio_transport_recv_connected(sk, skb,
+ batch ?
+ &batch->data_ready_pending : NULL);
break;
case TCP_CLOSING:
virtio_transport_recv_disconnecting(sk, skb);
@@ -1875,12 +1901,59 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
break;
}
+ if (batchable)
+ *batchable = virtio_transport_recv_pkt_batchable(t, sk);
+
+ return false;
+}
+
+/* We are under the virtio-vsock's vsock->rx_lock or vhost-vsock's vq->mutex
+ * lock.
+ */
+void virtio_transport_recv_pkt(struct virtio_transport *t,
+ struct sk_buff *skb, struct net *net)
+{
+ struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
+ struct sockaddr_vm src, dst;
+ struct sock *sk;
+ bool free_pkt;
+
+ vsock_addr_init(&src, le64_to_cpu(hdr->src_cid),
+ le32_to_cpu(hdr->src_port));
+ vsock_addr_init(&dst, le64_to_cpu(hdr->dst_cid),
+ le32_to_cpu(hdr->dst_port));
+
+ trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
+ dst.svm_cid, dst.svm_port,
+ le32_to_cpu(hdr->len),
+ le16_to_cpu(hdr->type),
+ le16_to_cpu(hdr->op),
+ le32_to_cpu(hdr->flags),
+ le32_to_cpu(hdr->buf_alloc),
+ le32_to_cpu(hdr->fwd_cnt));
+
+ sk = virtio_transport_find_socket(skb, &src, &dst, net);
+ if (!sk) {
+ (void)virtio_transport_reset_no_sock(t, skb, net);
+ goto free_pkt;
+ }
+
+ if (!skb_set_owner_sk_safe(skb, sk)) {
+ WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
+ goto free_pkt;
+ }
+
+ lock_sock(sk);
+ free_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, &src, &dst,
+ net, NULL, NULL);
release_sock(sk);
/* Release refcnt obtained when we fetched this socket out of the
* bound or connected list.
*/
sock_put(sk);
+ if (free_pkt)
+ kfree_skb(skb);
return;
free_pkt:
@@ -1888,6 +1961,148 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
}
EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt);
+/*
+ * Finish the RX batch.
+ * For a non-empty batch, the caller must hold the socket lock acquired with
+ * lock_sock(). This function releases the lock and the batch's lookup
+ * reference.
+ * An empty batch is a no-op.
+ */
+void virtio_transport_rx_batch_finish(struct virtio_transport_rx_batch *batch)
+{
+ bool write_space_pending = batch->write_space_pending;
+ bool data_ready_pending = batch->data_ready_pending;
+ struct sock *sk = batch->sk;
+
+ batch->sk = NULL;
+ batch->pkts = 0;
+ batch->bytes = 0;
+ batch->write_space_pending = false;
+ batch->data_ready_pending = false;
+
+ if (!sk)
+ return;
+
+ if (write_space_pending)
+ vsock_sk(sk)->default_write_space(sk);
+
+ release_sock(sk);
+
+ if (data_ready_pending)
+ vsock_sk(sk)->default_data_ready(sk);
+
+ sock_put(sk);
+}
+EXPORT_SYMBOL_GPL(virtio_transport_rx_batch_finish);
+
+void virtio_transport_recv_pkt_batch(struct virtio_transport *t,
+ struct sk_buff *skb, struct net *net,
+ struct virtio_transport_rx_batch *batch)
+{
+ struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
+ struct sockaddr_vm src, dst;
+ struct vsock_sock *vsk;
+ bool batchable, start_batch;
+ struct sock *sk;
+ bool free_pkt;
+
+ /* Only STREAM/RW packets can share a socket lock. */
+ if (le16_to_cpu(hdr->type) != VIRTIO_VSOCK_TYPE_STREAM ||
+ le16_to_cpu(hdr->op) != VIRTIO_VSOCK_OP_RW) {
+ virtio_transport_rx_batch_finish(batch);
+ virtio_transport_recv_pkt(t, skb, net);
+ return;
+ }
+
+ vsock_addr_init(&src, le64_to_cpu(hdr->src_cid),
+ le32_to_cpu(hdr->src_port));
+ vsock_addr_init(&dst, le64_to_cpu(hdr->dst_cid),
+ le32_to_cpu(hdr->dst_port));
+
+ trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
+ dst.svm_cid, dst.svm_port,
+ le32_to_cpu(hdr->len),
+ le16_to_cpu(hdr->type),
+ le16_to_cpu(hdr->op),
+ le32_to_cpu(hdr->flags),
+ le32_to_cpu(hdr->buf_alloc),
+ le32_to_cpu(hdr->fwd_cnt));
+
+ if (batch->sk) {
+ vsk = vsock_sk(batch->sk);
+ if (vsock_addr_equals_addr(&src, &vsk->remote_addr) &&
+ dst.svm_port == vsk->local_addr.svm_port &&
+ vsock_net_check_mode(sock_net(batch->sk), net) &&
+ virtio_transport_recv_pkt_batchable(t, batch->sk)) {
+ sk = batch->sk;
+ if (!skb_set_owner_sk_safe(skb, sk)) {
+ WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
+ virtio_transport_rx_batch_finish(batch);
+ kfree_skb(skb);
+ return;
+ }
+
+ free_pkt = virtio_transport_recv_pkt_locked(t, skb, sk,
+ &src, &dst,
+ net,
+ &batchable,
+ batch);
+ if (!batchable)
+ virtio_transport_rx_batch_finish(batch);
+ if (free_pkt)
+ kfree_skb(skb);
+ return;
+ }
+
+ virtio_transport_rx_batch_finish(batch);
+ }
+
+ sk = virtio_transport_find_socket(skb, &src, &dst, net);
+ if (!sk) {
+ (void)virtio_transport_reset_no_sock(t, skb, net);
+ kfree_skb(skb);
+ return;
+ }
+
+ if (!skb_set_owner_sk_safe(skb, sk)) {
+ WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
+ kfree_skb(skb);
+ return;
+ }
+
+ lock_sock(sk);
+ /*
+ * Sockmap teardown restores callbacks under sk_callback_lock. Keep the
+ * initial eligibility check consistent with that update.
+ */
+ read_lock_bh(&sk->sk_callback_lock);
+ start_batch = virtio_transport_recv_pkt_batchable(t, sk);
+ read_unlock_bh(&sk->sk_callback_lock);
+
+ if (start_batch)
+ batch->sk = sk;
+
+ free_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, &src, &dst,
+ net,
+ start_batch ? &batchable : NULL,
+ start_batch ? batch : NULL);
+ if (start_batch && batchable) {
+ /* Keep the lookup reference until the batch is released. */
+ return;
+ }
+
+ if (start_batch) {
+ virtio_transport_rx_batch_finish(batch);
+ } else {
+ release_sock(sk);
+ sock_put(sk);
+ }
+
+ if (free_pkt)
+ kfree_skb(skb);
+}
+EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt_batch);
+
/* Remove skbs found in a queue that have a vsk that matches.
*
* Each skb is freed.
|
| 3/2 | 2026/10/13 07:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 9994 output: 34 thoughts: 559 Thoughts: **Analyzing the Virtio VSock RX Batching Patch for Fuzzing with Syzkaller** Okay, let's break down this patch and figure out the best approach for fuzzing it with syzkaller. My first thought is to understand the patch's purpose – it's RX batching for virtio vsock. The diff involves changes to several key files: `include/linux/virtio_vsock.h`, `include/net/af_vsock.h`, `net/vmw_vsock/af_vsock.c`, `net/vmw_vsock/virtio_transport.c`, and `net/vmw_vsock/virtio_transport_common.c`. These file paths suggest this is core to the transport mechanism, and touches the user-facing API. Specifically, it looks like there are new structures and functions being introduced: `virtio_transport_rx_batch`, `virtio_transport_recv_pkt_batch`, `virtio_transport_rx_batch_finish`, `virtio_transport_recv_pkt_locked`, `virtio_transport_find_socket`, `virtio_transport_recv_pkt_batchable`, and modifications within `virtio_transport_rx_work` in `virtio_transport.c`. It's also deferring callbacks and adding checks for headroom, and sockmap/psock interactions, state transitions, and socket locking. This is complex, and could introduce subtle race conditions. Now, the crucial question is reachability: can we even *get* to this code with syzkaller? It looks like we're dealing with virtio vsock, so the question is, can we actually reach vsock or virtio_transport code in a standard virtualized environment like QEMU. Virtio vsock is a standard virtio device (thanks to `CONFIG_VIRTIO_VSOCK` and `CONFIG_VSOCK`). Excellent. I need to make sure this can be reached in syzkaller. Hold on a second... does syzkaller *already* have vsock support? I vaguely recall seeing something about it. Yes, it does! Syzkaller has vsock syscalls (e.g., `socket(AF_VSOCK, ...)`). But the key piece here is `virtio_transport`. That's the guest driver. So the question becomes, can we reliably fuzz *virtio_transport*? We need to determine if we can reach and fuzz it effectively with the existing vsock support. I need to confirm which code paths lead to `virtio_transport_common.c` and `virtio_transport.c`. I'll search for `virtio_transport` and related terms like `vhost_vsock` and `vsock_loopback` to get a broader picture of where and how these transport mechanisms are used. Then, I can tailor the fuzzing strategy and config flags to target the relevant code and expose any potential bugs introduced by this patch. |
| 4/2 | 2026/10/13 07:11 | tool | grepper |
0mArgs:{
"Expression": "virtio_transport_common",
"PathPrefixes": [
"net/vmw_vsock"
]
}Results: {
"Output": "net/vmw_vsock/Kconfig=29=config VSOCKETS_LOOPBACK\n--\nnet/vmw_vsock/Kconfig-35-\t This module implements a loopback transport for Virtual Sockets,\nnet/vmw_vsock/Kconfig:36:\t using vmw_vsock_virtio_transport_common.\nnet/vmw_vsock/Kconfig-37-\n--\nnet/vmw_vsock/Kconfig=66=config VIRTIO_VSOCKETS_COMMON\n--\nnet/vmw_vsock/Kconfig-70-\t the virtio_vsock. The module will be called\nnet/vmw_vsock/Kconfig:71:\t vmw_vsock_virtio_transport_common.\nnet/vmw_vsock/Kconfig-72-\n--\nnet/vmw_vsock/Makefile=5=obj-$(CONFIG_VIRTIO_VSOCKETS) += vmw_vsock_virtio_transport.o\nnet/vmw_vsock/Makefile:6:obj-$(CONFIG_VIRTIO_VSOCKETS_COMMON) += vmw_vsock_virtio_transport_common.o\nnet/vmw_vsock/Makefile-7-obj-$(CONFIG_HYPERV_VSOCKETS) += hv_sock.o\n--\nnet/vmw_vsock/Makefile=18=vmw_vsock_virtio_transport-y += virtio_transport.o\nnet/vmw_vsock/Makefile-19-\nnet/vmw_vsock/Makefile:20:vmw_vsock_virtio_transport_common-y += virtio_transport_common.o\nnet/vmw_vsock/Makefile-21-\n--\nnet/vmw_vsock/virtio_transport_common.c-20-#define CREATE_TRACE_POINTS\nnet/vmw_vsock/virtio_transport_common.c:21:#include \u003ctrace/events/vsock_virtio_transport_common.h\u003e\nnet/vmw_vsock/virtio_transport_common.c-22-\n--\nnet/vmw_vsock/vsock_loopback.c-1-// SPDX-License-Identifier: GPL-2.0-only\nnet/vmw_vsock/vsock_loopback.c:2:/* loopback transport for vsock using virtio_transport_common APIs\nnet/vmw_vsock/vsock_loopback.c-3- *\n"
} |
| 5/2 | 2026/10/13 07:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 11836 output: 36 thoughts: 48 Thoughts: Okay, let's dive in. **Analyzing vsock_loopback.c** Alright, my internal radar is pinging. I need to understand the data flow in this `vsock_loopback.c` module. My immediate question is: does it leverage `virtio_transport_recv_pkt`? That function is crucial for packet reception in a virtio-based environment, so I need to verify its usage here. Time to crack open the source code and confirm. Let's get to it. |
| 6/2 | 2026/10/13 07:11 | tool | grepper |
0mArgs:{
"Expression": "virtio_transport_recv_pkt",
"PathPrefixes": [
"net/vmw_vsock"
]
}Results: {
"Output": "net/vmw_vsock/virtio_transport.c=639=static void virtio_transport_rx_work(struct work_struct *work)\n--\nnet/vmw_vsock/virtio_transport.c-703-\t\t\t */\nnet/vmw_vsock/virtio_transport.c:704:\t\t\tvirtio_transport_recv_pkt_batch(\u0026virtio_transport, skb, NULL,\nnet/vmw_vsock/virtio_transport.c-705-\t\t\t\t\t\t\t\u0026batch);\n--\nnet/vmw_vsock/virtio_transport_common.c=1820=static bool\nnet/vmw_vsock/virtio_transport_common.c:1821:virtio_transport_recv_pkt_batchable(struct virtio_transport *t,\nnet/vmw_vsock/virtio_transport_common.c-1822-\t\t\t\t struct sock *sk)\n--\nnet/vmw_vsock/virtio_transport_common.c=1843=static bool\nnet/vmw_vsock/virtio_transport_common.c:1844:virtio_transport_recv_pkt_locked(struct virtio_transport *t,\nnet/vmw_vsock/virtio_transport_common.c-1845-\t\t\t\t struct sk_buff *skb, struct sock *sk,\n--\nnet/vmw_vsock/virtio_transport_common.c-1904-\tif (batchable)\nnet/vmw_vsock/virtio_transport_common.c:1905:\t\t*batchable = virtio_transport_recv_pkt_batchable(t, sk);\nnet/vmw_vsock/virtio_transport_common.c-1906-\n--\nnet/vmw_vsock/virtio_transport_common.c-1912- */\nnet/vmw_vsock/virtio_transport_common.c:1913:void virtio_transport_recv_pkt(struct virtio_transport *t,\nnet/vmw_vsock/virtio_transport_common.c-1914-\t\t\t struct sk_buff *skb, struct net *net)\n--\nnet/vmw_vsock/virtio_transport_common.c-1925-\nnet/vmw_vsock/virtio_transport_common.c:1926:\ttrace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,\nnet/vmw_vsock/virtio_transport_common.c-1927-\t\t\t\t\tdst.svm_cid, dst.svm_port,\n--\nnet/vmw_vsock/virtio_transport_common.c-1946-\tlock_sock(sk);\nnet/vmw_vsock/virtio_transport_common.c:1947:\tfree_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, \u0026src, \u0026dst,\nnet/vmw_vsock/virtio_transport_common.c-1948-\t\t\t\t\t\t net, NULL, NULL);\n--\nnet/vmw_vsock/virtio_transport_common.c-1961-}\nnet/vmw_vsock/virtio_transport_common.c:1962:EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt);\nnet/vmw_vsock/virtio_transport_common.c-1963-\n--\nnet/vmw_vsock/virtio_transport_common.c=1996=EXPORT_SYMBOL_GPL(virtio_transport_rx_batch_finish);\nnet/vmw_vsock/virtio_transport_common.c-1997-\nnet/vmw_vsock/virtio_transport_common.c:1998:void virtio_transport_recv_pkt_batch(struct virtio_transport *t,\nnet/vmw_vsock/virtio_transport_common.c-1999-\t\t\t\t struct sk_buff *skb, struct net *net,\n--\nnet/vmw_vsock/virtio_transport_common.c-2012-\t\tvirtio_transport_rx_batch_finish(batch);\nnet/vmw_vsock/virtio_transport_common.c:2013:\t\tvirtio_transport_recv_pkt(t, skb, net);\nnet/vmw_vsock/virtio_transport_common.c-2014-\t\treturn;\n--\nnet/vmw_vsock/virtio_transport_common.c-2021-\nnet/vmw_vsock/virtio_transport_common.c:2022:\ttrace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,\nnet/vmw_vsock/virtio_transport_common.c-2023-\t\t\t\t\tdst.svm_cid, dst.svm_port,\n--\nnet/vmw_vsock/virtio_transport_common.c-2035-\t\t vsock_net_check_mode(sock_net(batch-\u003esk), net) \u0026\u0026\nnet/vmw_vsock/virtio_transport_common.c:2036:\t\t virtio_transport_recv_pkt_batchable(t, batch-\u003esk)) {\nnet/vmw_vsock/virtio_transport_common.c-2037-\t\t\tsk = batch-\u003esk;\n--\nnet/vmw_vsock/virtio_transport_common.c-2044-\nnet/vmw_vsock/virtio_transport_common.c:2045:\t\t\tfree_pkt = virtio_transport_recv_pkt_locked(t, skb, sk,\nnet/vmw_vsock/virtio_transport_common.c-2046-\t\t\t\t\t\t\t\t \u0026src, \u0026dst,\n--\nnet/vmw_vsock/virtio_transport_common.c-2078-\tread_lock_bh(\u0026sk-\u003esk_callback_lock);\nnet/vmw_vsock/virtio_transport_common.c:2079:\tstart_batch = virtio_transport_recv_pkt_batchable(t, sk);\nnet/vmw_vsock/virtio_transport_common.c-2080-\tread_unlock_bh(\u0026sk-\u003esk_callback_lock);\n--\nnet/vmw_vsock/virtio_transport_common.c-2084-\nnet/vmw_vsock/virtio_transport_common.c:2085:\tfree_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, \u0026src, \u0026dst,\nnet/vmw_vsock/virtio_transport_common.c-2086-\t\t\t\t\t\t net,\n--\nnet/vmw_vsock/virtio_transport_common.c-2103-}\nnet/vmw_vsock/virtio_transport_common.c:2104:EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt_batch);\nnet/vmw_vsock/virtio_transport_common.c-2105-\n--\nnet/vmw_vsock/vsock_loopback.c=123=static void vsock_loopback_work(struct work_struct *work)\n--\nnet/vmw_vsock/vsock_loopback.c-141-\t\tvirtio_transport_deliver_tap_pkt(skb);\nnet/vmw_vsock/vsock_loopback.c:142:\t\tvirtio_transport_recv_pkt(\u0026loopback_transport, skb,\nnet/vmw_vsock/vsock_loopback.c-143-\t\t\t\t\t sock_net(skb-\u003esk));\n"
} |
| 7/2 | 2026/10/13 07:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 13936 output: 33 thoughts: 336 Thoughts: **My Analysis of VSock Packet Reception** Okay, so I'm digging into how vsock packets are handled, and it looks like `vsock_loopback.c` kicks things off with a call to `virtio_transport_recv_pkt` through the `virtio_transport_recv_pkt(&loopback_transport, skb, sock_net(skb->sk));`. That's the entry point for the loopback scenario, which is important to remember. Now, that call in turn leads us to `virtio_transport_common.c`. Inside this file, `virtio_transport_recv_pkt` makes two critical calls: `virtio_transport_find_socket` and then `virtio_transport_recv_pkt_locked`. It's all starting to click together, the logic seems pretty clear. Then, there's `virtio_transport_recv_pkt_batch`, which is also important. I see that it is called within `virtio_transport_rx_work`. That makes sense - we've got batch processing for these incoming packets. Wait a second, there's also the standard virtio-vsock instantiation (`-device vhost-vsock-pci` or virtio-vsock-pci) in QEMU and other virtualized environments. And of course, there's `vsock_loopback` which is the standard setup for local vsock in Linux. That's also used by syzkaller. Hmm, I need to confirm if `vsock_loopback` is actually functional for syzkaller. Yes, it does. Excellent. Syzkaller is fuzzing AF_VSOCK over loopback, using CID = VMADDR_CID_LOCAL. That's a good data point. The more I look at this, I see that the `virtio_transport.c` is specifically for the virtio-vsock PCI/MMIO device, but the `virtio_transport_common.c` code is shared between virtio-vsock and vsock_loopback, and vhost/vsock. That's the key - it's a common layer. Okay, let's broaden the search a little. I need to get a complete picture. What other code paths call `virtio_transport_recv_pkt` or `virtio_transport_recv_pkt_batch`? Let's check `drivers/vhost/vsock.c` as well, since that's another important player in the vsock architecture. I should check that for completeness. |
| 8/2 | 2026/10/13 07:11 | tool | grepper |
0mArgs:{
"Expression": "virtio_transport_recv_pkt",
"PathPrefixes": [
"drivers/vhost"
]
}Results: {
"Output": "drivers/vhost/vsock.c=523=static void vhost_vsock_handle_tx_kick(struct vhost_work *work)\n--\ndrivers/vhost/vsock.c-583-\t\t vhost_transport_get_local_cid())\ndrivers/vhost/vsock.c:584:\t\t\tvirtio_transport_recv_pkt(\u0026vhost_transport, skb,\ndrivers/vhost/vsock.c-585-\t\t\t\t\t\t vsock-\u003enet);\n"
} |
| 9/2 | 2026/10/13 07:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14993 output: 36 thoughts: 165 Thoughts: **Investigating the vsock Implementation** Okay, let's break this down. My initial focus is on the vsock implementation, particularly how it handles incoming packets when the Connection ID (CID) matches the local CID. I've noted that `vhost_transport_recv_pkt` within `drivers/vhost/vsock.c` seems crucial here, given its use in this scenario. I'm also aware that, within a QEMU guest environment, the virtio-vsock device leverages `virtio_transport.c`. This suggests a connection between the virtualized device and the transport layer. In the context of syzkaller, the necessary configuration options are enabled: `CONFIG_VIRTIO_VSOCKETS`, `CONFIG_VSOCKETS`, `CONFIG_VSOCKETS_LOOPBACK`, and `CONFIG_VHOST_VSOCK`, along with `CONFIG_VIRTIO_VSOCKETS_COMMON`. This gives a strong indication of the relevant code pathways. Now, I need to pinpoint the exact Kconfig symbols and their dependencies. I'll need to check the `net/vmw_vsock/Kconfig` file. This should give me a more granular understanding of the vsock configuration options. |
| 10/2 | 2026/10/13 07:11 | tool | read-file |
0mArgs:{
"File": "net/vmw_vsock/Kconfig",
"FirstLine": 1,
"LineCount": 80
}Results: {
"Contents": " 1:\t# SPDX-License-Identifier: GPL-2.0-only\n 2:\t#\n 3:\t# Vsock protocol\n 4:\t#\n 5:\t\n 6:\tconfig VSOCKETS\n 7:\t\ttristate \"Virtual Socket protocol\"\n 8:\t\thelp\n 9:\t\t Virtual Socket Protocol is a socket protocol similar to TCP/IP\n 10:\t\t allowing communication between Virtual Machines and hypervisor\n 11:\t\t or host.\n 12:\t\n 13:\t\t You should also select one or more hypervisor-specific transports\n 14:\t\t below.\n 15:\t\n 16:\t\t To compile this driver as a module, choose M here: the module\n 17:\t\t will be called vsock. If unsure, say N.\n 18:\t\n 19:\tconfig VSOCKETS_DIAG\n 20:\t\ttristate \"Virtual Sockets monitoring interface\"\n 21:\t\tdepends on VSOCKETS\n 22:\t\tdefault y\n 23:\t\thelp\n 24:\t\t Support for PF_VSOCK sockets monitoring interface used by the ss tool.\n 25:\t\t If unsure, say Y.\n 26:\t\n 27:\t\t Enable this module so userspace applications can query open sockets.\n 28:\t\n 29:\tconfig VSOCKETS_LOOPBACK\n 30:\t\ttristate \"Virtual Sockets loopback transport\"\n 31:\t\tdepends on VSOCKETS\n 32:\t\tdefault y\n 33:\t\tselect VIRTIO_VSOCKETS_COMMON\n 34:\t\thelp\n 35:\t\t This module implements a loopback transport for Virtual Sockets,\n 36:\t\t using vmw_vsock_virtio_transport_common.\n 37:\t\n 38:\t\t To compile this driver as a module, choose M here: the module\n 39:\t\t will be called vsock_loopback. If unsure, say N.\n 40:\t\n 41:\tconfig VMWARE_VMCI_VSOCKETS\n 42:\t\ttristate \"VMware VMCI transport for Virtual Sockets\"\n 43:\t\tdepends on VSOCKETS \u0026\u0026 VMWARE_VMCI\n 44:\t\thelp\n 45:\t\t This module implements a VMCI transport for Virtual Sockets.\n 46:\t\n 47:\t\t Enable this transport if your Virtual Machine runs on a VMware\n 48:\t\t hypervisor.\n 49:\t\n 50:\t\t To compile this driver as a module, choose M here: the module\n 51:\t\t will be called vmw_vsock_vmci_transport. If unsure, say N.\n 52:\t\n 53:\tconfig VIRTIO_VSOCKETS\n 54:\t\ttristate \"virtio transport for Virtual Sockets\"\n 55:\t\tdepends on VSOCKETS \u0026\u0026 VIRTIO\n 56:\t\tselect VIRTIO_VSOCKETS_COMMON\n 57:\t\thelp\n 58:\t\t This module implements a virtio transport for Virtual Sockets.\n 59:\t\n 60:\t\t Enable this transport if your Virtual Machine host supports Virtual\n 61:\t\t Sockets over virtio.\n 62:\t\n 63:\t\t To compile this driver as a module, choose M here: the module will be\n 64:\t\t called vmw_vsock_virtio_transport. If unsure, say N.\n 65:\t\n 66:\tconfig VIRTIO_VSOCKETS_COMMON\n 67:\t\ttristate\n 68:\t\thelp\n 69:\t\t This option is selected by any driver which needs to access\n 70:\t\t the virtio_vsock. The module will be called\n 71:\t\t vmw_vsock_virtio_transport_common.\n 72:\t\n 73:\tconfig HYPERV_VSOCKETS\n 74:\t\ttristate \"Hyper-V transport for Virtual Sockets\"\n 75:\t\tdepends on VSOCKETS \u0026\u0026 HYPERV_VMBUS\n 76:\t\thelp\n 77:\t\t This module implements a Hyper-V transport for Virtual Sockets.\n 78:\t\n 79:\t\t Enable this transport if your Virtual Machine host supports Virtual\n 80:\t\t Sockets over Hyper-V VMBus.\n"
} |
| 11/2 | 2026/10/13 07:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 16530 output: 30 thoughts: 22 Thoughts: Here's a summary of my thought process: **Verifying VHOST_VSOCK Configuration** Okay, so I'm double-checking the configuration options related to vhost-vsock. I've already confirmed some things, but I need to make absolutely certain that the configuration is correct. The next logical step is to delve into the `drivers/vhost/Kconfig` file. It's a key source for configuration options, and I need to see how `VHOST_VSOCK` is handled there, just to be thorough and leave no stone unturned in this investigation. Better to be certain, especially when dealing with critical infrastructure. |
| 12/2 | 2026/10/13 07:12 | tool | grepper |
0mArgs:{
"Expression": "VHOST_VSOCK",
"PathPrefixes": [
"drivers/vhost"
]
}Results: {
"Output": "drivers/vhost/Kconfig=46=config VHOST_SCSI\n--\ndrivers/vhost/Kconfig-55-\ndrivers/vhost/Kconfig:56:config VHOST_VSOCK\ndrivers/vhost/Kconfig-57-\ttristate \"vhost virtio-vsock driver\"\n--\ndrivers/vhost/Makefile=6=vhost_scsi-y := scsi.o\ndrivers/vhost/Makefile-7-\ndrivers/vhost/Makefile:8:obj-$(CONFIG_VHOST_VSOCK) += vhost_vsock.o\ndrivers/vhost/Makefile-9-vhost_vsock-y := vsock.o\n--\ndrivers/vhost/vhost.c=870=static void __vhost_vq_attach_worker(struct vhost_virtqueue *vq,\n--\ndrivers/vhost/vhost.c-919-\t\t/*\ndrivers/vhost/vhost.c:920:\t\t * vsock can queue anytime after VHOST_VSOCK_SET_GUEST_CID.\ndrivers/vhost/vhost.c-921-\t\t * Warn if it adds support for multiple workers but forgets to\n--\ndrivers/vhost/vsock.c-21-\ndrivers/vhost/vsock.c:22:#define VHOST_VSOCK_DEFAULT_HOST_CID\t2\ndrivers/vhost/vsock.c-23-/* Max number of bytes transferred before requeueing the job.\ndrivers/vhost/vsock.c-24- * Using this limit prevents one virtqueue from starving others. */\ndrivers/vhost/vsock.c:25:#define VHOST_VSOCK_WEIGHT 0x80000\ndrivers/vhost/vsock.c-26-/* Max number of packets transferred before requeueing the job.\n--\ndrivers/vhost/vsock.c-29- */\ndrivers/vhost/vsock.c:30:#define VHOST_VSOCK_PKT_WEIGHT 256\ndrivers/vhost/vsock.c-31-\ndrivers/vhost/vsock.c=32=static const int vhost_vsock_bits[] = {\n--\ndrivers/vhost/vsock.c-37-\ndrivers/vhost/vsock.c:38:#define VHOST_VSOCK_FEATURES VHOST_FEATURES_U64(vhost_vsock_bits, 0)\ndrivers/vhost/vsock.c-39-\ndrivers/vhost/vsock.c=40=enum {\ndrivers/vhost/vsock.c:41:\tVHOST_VSOCK_BACKEND_FEATURES = (1ULL \u003c\u003c VHOST_BACKEND_F_IOTLB_MSG_V2)\ndrivers/vhost/vsock.c-42-};\n--\ndrivers/vhost/vsock.c=66=static u32 vhost_transport_get_local_cid(void)\ndrivers/vhost/vsock.c-67-{\ndrivers/vhost/vsock.c:68:\treturn VHOST_VSOCK_DEFAULT_HOST_CID;\ndrivers/vhost/vsock.c-69-}\n--\ndrivers/vhost/vsock.c=698=static int vhost_vsock_dev_open(struct inode *inode, struct file *file)\n--\ndrivers/vhost/vsock.c-731-\tvhost_dev_init(\u0026vsock-\u003edev, vqs, ARRAY_SIZE(vsock-\u003evqs),\ndrivers/vhost/vsock.c:732:\t\t UIO_MAXIOV, VHOST_VSOCK_PKT_WEIGHT,\ndrivers/vhost/vsock.c:733:\t\t VHOST_VSOCK_WEIGHT, true, NULL);\ndrivers/vhost/vsock.c-734-\n--\ndrivers/vhost/vsock.c=854=static int vhost_vsock_set_features(struct vhost_vsock *vsock, u64 features)\n--\ndrivers/vhost/vsock.c-858-\ndrivers/vhost/vsock.c:859:\tif (features \u0026 ~VHOST_VSOCK_FEATURES)\ndrivers/vhost/vsock.c-860-\t\treturn -EOPNOTSUPP;\n--\ndrivers/vhost/vsock.c=891=static long vhost_vsock_dev_ioctl(struct file *f, unsigned int ioctl,\n--\ndrivers/vhost/vsock.c-901-\tswitch (ioctl) {\ndrivers/vhost/vsock.c:902:\tcase VHOST_VSOCK_SET_GUEST_CID:\ndrivers/vhost/vsock.c-903-\t\tif (copy_from_user(\u0026guest_cid, argp, sizeof(guest_cid)))\n--\ndrivers/vhost/vsock.c-905-\t\treturn vhost_vsock_set_cid(vsock, guest_cid);\ndrivers/vhost/vsock.c:906:\tcase VHOST_VSOCK_SET_RUNNING:\ndrivers/vhost/vsock.c-907-\t\tif (copy_from_user(\u0026start, argp, sizeof(start)))\n--\ndrivers/vhost/vsock.c-913-\tcase VHOST_GET_FEATURES:\ndrivers/vhost/vsock.c:914:\t\tfeatures = VHOST_VSOCK_FEATURES;\ndrivers/vhost/vsock.c-915-\t\tif (copy_to_user(argp, \u0026features, sizeof(features)))\n--\ndrivers/vhost/vsock.c-922-\tcase VHOST_GET_BACKEND_FEATURES:\ndrivers/vhost/vsock.c:923:\t\tfeatures = VHOST_VSOCK_BACKEND_FEATURES;\ndrivers/vhost/vsock.c-924-\t\tif (copy_to_user(argp, \u0026features, sizeof(features)))\n--\ndrivers/vhost/vsock.c-929-\t\t\treturn -EFAULT;\ndrivers/vhost/vsock.c:930:\t\tif (features \u0026 ~VHOST_VSOCK_BACKEND_FEATURES)\ndrivers/vhost/vsock.c-931-\t\t\treturn -EOPNOTSUPP;\n--\ndrivers/vhost/vsock.c=986=static struct miscdevice vhost_vsock_misc = {\ndrivers/vhost/vsock.c:987:\t.minor = VHOST_VSOCK_MINOR,\ndrivers/vhost/vsock.c-988-\t.name = \"vhost-vsock\",\n--\ndrivers/vhost/vsock.c=1020=MODULE_DESCRIPTION(\"vhost transport for vsock \");\ndrivers/vhost/vsock.c:1021:MODULE_ALIAS_MISCDEV(VHOST_VSOCK_MINOR);\ndrivers/vhost/vsock.c-1022-MODULE_ALIAS(\"devname:vhost-vsock\");\n"
} |
| 13/2 | 2026/10/13 07:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18426 output: 36 thoughts: 3542 Thoughts: **Analysis of the Virtio-VSOCK Patch for Fuzzing Suitability** Okay, let's break this down from a fuzzing perspective. First off, I see modifications across several files, including the `virtio_vsock` headers, the core `af_vsock.c` implementation, and the `virtio_transport` layer. Right away, this piques my interest. It looks like we're dealing with changes to the guest-side virtio-vsock driver and its associated transport mechanisms, specifically focusing on packet handling and potentially adding batching. I'm zeroing in on `net/vmw_vsock/virtio_transport.c` and `net/vmw_vsock/virtio_transport_common.c` mainly, as those are the heart of this. The `virtio_transport_rx_work` function now appears to implement packet batching logic which definitely warrants closer scrutiny. The introduction of `virtio_transport_rx_batch_finish` and `virtio_transport_recv_pkt_batch` is a big deal as they will be critical. The code now appears to group packets together which could be a source of various memory and logic errors. The `virtio_transport_recv_pkt` is refactored, and it's calling `virtio_transport_recv_pkt_locked` which is used by `vsock_loopback.c`. The patch also seems to touch socket creation and data readiness handling through `af_vsock.c` and potentially introduces interactions with sockmap or other socket metadata. Socket state and connection handling are always fruitful fuzzing targets. The `__vsock_create` function is modified, and the `vsock_data_ready` and `vsock_write_space` functions are now saved. I'm thinking about the fuzzing approach. Virtio-vsock is a guest-side driver, and its operation via QEMU makes it a great target for fuzzing. Standard QEMU setups with virtio devices are common in syzkaller environments, so it shouldn't be hard to set this up. In fact, if the loopback transport is involved, it makes fuzzing even easier! The modifications involve code that is directly reachable in standard virtio configurations. We're not talking about some obscure hardware or unreachable logic. This patch touches multiple subsystems, and all these things make this code WorthFuzzing=true. Now, let's think about focus symbols. I will prioritize exported symbols: `virtio_transport_recv_pkt`, `virtio_transport_recv_pkt_batch`, and `virtio_transport_rx_batch_finish`. Since `virtio_transport_rx_work` is a static work handler, I'll need to examine how the work queue is invoked to decide whether it's feasible as a focus symbol or whether we target other functions that use it such as `virtio_transport_recv_pkt`. I'll check the config flags next. The key here will be `CONFIG_VSOCKETS`, `CONFIG_VSOCKETS_LOOPBACK` and `CONFIG_VIRTIO_VSOCK` to ensure the relevant code is compiled. |
| 14/2 | 2026/10/13 07:12 | tool | grepper |
0mArgs:{
"Expression": "virtio_transport_rx_work",
"PathPrefixes": [
"net/vmw_vsock"
]
}Results: {
"Output": "net/vmw_vsock/virtio_transport.c=614=virtio_transport_seqpacket_allow(struct vsock_sock *vsk, u32 remote_cid)\n--\nnet/vmw_vsock/virtio_transport.c-638-\nnet/vmw_vsock/virtio_transport.c:639:static void virtio_transport_rx_work(struct work_struct *work)\nnet/vmw_vsock/virtio_transport.c-640-{\n--\nnet/vmw_vsock/virtio_transport.c=827=static int virtio_vsock_probe(struct virtio_device *vdev)\n--\nnet/vmw_vsock/virtio_transport.c-856-\tskb_queue_head_init(\u0026vsock-\u003esend_pkt_queue);\nnet/vmw_vsock/virtio_transport.c:857:\tINIT_WORK(\u0026vsock-\u003erx_work, virtio_transport_rx_work);\nnet/vmw_vsock/virtio_transport.c-858-\tINIT_WORK(\u0026vsock-\u003etx_work, virtio_transport_tx_work);\n"
} |
| 15/2 | 2026/10/13 07:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 22991 output: 31 thoughts: 1355 Thoughts: **Analyzing the Virtio vsock Receive Path and Enabling Configurations** Okay, let's break this down. First, I'm looking at the core receive path within the virtio vsock implementation. `virtio_transport_rx_work` is definitely a key entry point, since it's used with `INIT_WORK`, meaning its address is taken, so the compiler *cannot* inline it. It's a distinct symbol. I'm also checking `virtio_transport_recv_pkt_batch` because it is exported, and then also checking `virtio_transport_rx_batch_finish`, and `virtio_transport_recv_pkt`. Since they're exported symbols, they are definitely code targets. Now, that brings up the question of whether `virtio_transport_recv_pkt_locked` could be inlined by the compiler. It's only called in a couple of places in `virtio_transport_common.c`, so there's a chance it is inlined into the callers, which are `virtio_transport_recv_pkt` and `virtio_transport_recv_pkt_batch`. So, listing `virtio_transport_recv_pkt_batch`, `virtio_transport_rx_batch_finish`, `virtio_transport_recv_pkt`, and `virtio_transport_rx_work` is likely the most direct and safest way to target the core logic of the code. Then I wondered about `virtio_transport_recv_connected` since it's called in `virtio_transport_recv_pkt_locked`. Similarly, `virtio_transport_recv_pkt_batchable` and `virtio_transport_find_socket` were also brought up to see if any of these functions may require coverage. `virtio_transport_recv_pkt_batchable` is called from `virtio_transport_recv_pkt_batch` in multiple places, so that function may or may not be inlined. I think including the exported functions from both files (`virtio_transport.c` and `virtio_transport_common.c`) will ensure coverage of the batching and receiving logic. Now, let's shift gears to the enabling configurations. I'm going to determine the Kconfig options that are *required* to compile this specific code. First, examining `net/vmw_vsock/Makefile` tells me that `CONFIG_VIRTIO_VSOCKETS` and `CONFIG_VIRTIO_VSOCKETS_COMMON` are relevant, linking to `virtio_transport.o` and `virtio_transport_common.o` respectively. The Kconfig files give a better picture: `CONFIG_VSOCKETS`, `CONFIG_VIRTIO_VSOCKETS`, and `CONFIG_VIRTIO_VSOCKETS_COMMON` are the key ones to focus on. `CONFIG_VHOST_VSOCK` also appears to bring in `VIRTIO_VSOCKETS_COMMON`. `net/vmw_vsock/af_vsock.c` gets compiled under `CONFIG_VSOCKETS`. `CONFIG_VSOCKETS_LOOPBACK` also exercises `virtio_transport_recv_pkt`! And `CONFIG_VIRTIO_VSOCKETS` is responsible for exercising `virtio_transport_rx_work` and `virtio_transport_recv_pkt_batch`! So, to compile the three source files (`virtio_transport.c`, `virtio_transport_common.c`, and `af_vsock.c`), I'll need `VSOCKETS`, `VIRTIO`, and `VIRTIO_VSOCKETS`. The `VIRTIO_VSOCKETS_COMMON` option is *selected* by others, but specifying it directly would be good for completeness (or I can select it with `VSOCKETS_LOOPBACK` if that becomes more useful). I should make sure `VIRTIO` is a standard config, which I'll check in the virtio Kconfig file. Finally, I confirm that `VIRTIO_VSOCKETS` depends on `VSOCKETS && VIRTIO` and selects `VIRTIO_VSOCKETS_COMMON`. Alright, that should cover the compilation aspect. |
| 16/2 | 2026/10/13 07:13 | tool | grepper |
0mArgs:{
"Expression": "config VIRTIO\\b",
"PathPrefixes": [
"drivers/virtio"
]
}Results: {
"Output": "drivers/virtio/Kconfig=2=config VIRTIO_ANCHOR\n--\ndrivers/virtio/Kconfig-4-\ndrivers/virtio/Kconfig:5:config VIRTIO\ndrivers/virtio/Kconfig-6-\ttristate\n"
} |
| 17/2 | 2026/10/13 07:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25370 output: 33 thoughts: 43 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Investigating VIRTIO Configuration Options** Alright, I need to figure out the dependencies or triggers that enable or select the `VIRTIO` subsystem. My immediate thought is to check which configuration symbols are responsible for its activation. Are we looking at `VIRTIO_PCI` or perhaps `VIRTIO_MENU`? It's a classic situation where a look at the Kconfig files holds the key. Let's dive straight into `drivers/virtio/Kconfig` to trace the configuration logic. That's the most likely place to start unraveling the control flow. |
| 18/2 | 2026/10/13 07:13 | tool | read-file |
0mArgs:{
"File": "drivers/virtio/Kconfig",
"FirstLine": 1,
"LineCount": 40
}Results: {
"Contents": " 1:\t# SPDX-License-Identifier: GPL-2.0-only\n 2:\tconfig VIRTIO_ANCHOR\n 3:\t\tbool\n 4:\t\n 5:\tconfig VIRTIO\n 6:\t\ttristate\n 7:\t\tselect VIRTIO_ANCHOR\n 8:\t\thelp\n 9:\t\t This option is selected by any driver which implements the virtio\n 10:\t\t bus, such as CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_MMIO, CONFIG_RPMSG\n 11:\t\t or CONFIG_S390_GUEST.\n 12:\t\n 13:\tconfig VIRTIO_PCI_LIB\n 14:\t\ttristate\n 15:\t\thelp\n 16:\t\t Modern PCI device implementation. This module implements the\n 17:\t\t basic probe and control for devices which are based on modern\n 18:\t\t PCI device with possible vendor specific extensions. Any\n 19:\t\t module that selects this module must depend on PCI.\n 20:\t\n 21:\tconfig VIRTIO_PCI_LIB_LEGACY\n 22:\t\ttristate\n 23:\t\thelp\n 24:\t\t Legacy PCI device (Virtio PCI Card 0.9.x Draft and older device)\n 25:\t\t implementation.\n 26:\t\t This module implements the basic probe and control for devices\n 27:\t\t which are based on legacy PCI device. Any module that selects this\n 28:\t\t module must depend on PCI.\n 29:\t\n 30:\tmenuconfig VIRTIO_MENU\n 31:\t\tbool \"Virtio drivers\"\n 32:\t\tdefault y\n 33:\t\n 34:\tif VIRTIO_MENU\n 35:\t\n 36:\tconfig VIRTIO_HARDEN_NOTIFICATION\n 37:\t bool \"Harden virtio notification\"\n 38:\t depends on BROKEN\n 39:\t help\n 40:\t Enable this to harden the device notifications and suppress\n"
} |
| 19/2 | 2026/10/13 07:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26101 output: 250 thoughts: 752 Thoughts: **My Analysis of VIRTIO vsock RX Path Fuzzing** Okay, so I've been tracing through the kernel configuration dependencies to understand what needs to be enabled for fuzzing the VIRTIO vsock receive path. It seems pretty straightforward: `VIRTIO_PCI` pulls in `VIRTIO`, and `VIRTIO_VSOCKETS` depends on both `VSOCKETS` and `VIRTIO`. The `select` statements are also interesting, `VIRTIO_VSOCKETS` and `VSOCKETS_LOOPBACK` both select `VIRTIO_VSOCKETS_COMMON`. My current plan, based on those dependencies, is to enable `VSOCKETS`, `VIRTIO_VSOCKETS`, `VIRTIO_VSOCKETS_COMMON`, `VSOCKETS_LOOPBACK`, and either `VIRTIO_PCI` or `VIRTIO`, as both seem equivalent. I've double-checked that `VIRTIO_VSOCKETS` is necessary because `virtio_transport.c` is compiled when it's enabled and `virtio_transport_common.c` is compiled when `VIRTIO_VSOCKETS_COMMON` is enabled. `af_vsock.c` is also compiled when `VSOCKETS` is enabled. Now, let's get the parameters right for `set-results`. `WorthFuzzing` is obviously `true` here. The `Reasoning` should be a concise explanation, and the `FocusSymbols` are the key functions: `virtio_transport_rx_work`, `virtio_transport_recv_pkt_batch`, `virtio_transport_rx_batch_finish`, `virtio_transport_recv_pkt`, `virtio_transport_recv_pkt_locked` (although that's static, so it's probably fine), `virtio_transport_recv_pkt_batchable`, and `virtio_transport_recv_connected`. I've also checked and verified that none of these functions are ubiquitous. They're all very specific to the virtio vsock receive path. I'm also going to include `virtio_transport_find_socket` as a focus symbol. Finally, I'll set `EnableConfigs` to `VSOCKETS`, `VIRTIO_VSOCKETS`, `VIRTIO_VSOCKETS_COMMON`, `VSOCKETS_LOOPBACK`, and `VIRTIO_PCI`. I've confirmed that enabling these will trigger the fuzzing of "reachable Drivers and Protocols: Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.)" I've also made sure to strip the `CONFIG_` prefix. All conditions are met; I'm ready to call `set-results`. |
| 20/2 | 2026/10/13 07:13 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"VSOCKETS",
"VIRTIO_VSOCKETS",
"VIRTIO_VSOCKETS_COMMON",
"VSOCKETS_LOOPBACK",
"VIRTIO_PCI"
],
"FocusSymbols": [
"virtio_transport_recv_pkt_batch",
"virtio_transport_rx_batch_finish",
"virtio_transport_recv_pkt",
"virtio_transport_rx_work",
"virtio_transport_recv_pkt_batchable",
"virtio_transport_recv_connected"
],
"Reasoning": "The patch introduces RX packet batching under a single socket lock for the virtio vsock transport. It adds logic to batch stream packets, defer callback invocations (sk_data_ready and sk_write_space), validate socket state consistency, and manage socket lock lifetimes across multiple RX descriptors. This reachable networking and virtio driver code is accessible in virtualized environments via AF_VSOCK sockets and virtio-vsock / loopback devices, making it an ideal target for syzkaller fuzzing.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"VSOCKETS",
"VIRTIO_VSOCKETS",
"VIRTIO_VSOCKETS_COMMON",
"VSOCKETS_LOOPBACK",
"VIRTIO_PCI"
],
"FocusSymbols": [
"virtio_transport_recv_pkt_batch",
"virtio_transport_rx_batch_finish",
"virtio_transport_recv_pkt",
"virtio_transport_rx_work",
"virtio_transport_recv_pkt_batchable",
"virtio_transport_recv_connected"
],
"Reasoning": "The patch introduces RX packet batching under a single socket lock for the virtio vsock transport. It adds logic to batch stream packets, defer callback invocations (sk_data_ready and sk_write_space), validate socket state consistency, and manage socket lock lifetimes across multiple RX descriptors. This reachable networking and virtio driver code is accessible in virtualized environments via AF_VSOCK sockets and virtio-vsock / loopback devices, making it an ideal target for syzkaller fuzzing.",
"WorthFuzzing": true
} |
| 21/1 | 2026/10/13 07:13 | action | If |
0mArgs:{
"WorthFuzzing": true
}Results: null |
| 22/2 | 2026/10/13 07:13 | agent | kmsan-evaluator |
0mModel:core Args: null Results: {
"KMSANReasoning": "The patch implements an RX batching optimization for virtio-vsock, allowing a bounded run of packets (up to 64 packets or 64 KiB) destined for the same connected stream socket to be processed under a single socket lock, while deferring sk_data_ready and sk_write_space wakeups.\n\nMemory and state initialization review:\n- The newly introduced `struct virtio_transport_rx_batch` is allocated on the stack in `virtio_transport_rx_work` and explicitly zero-initialized (`= {}`).\n- All local flags and out-parameters (`start_batch`, `batchable`, `free_pkt`, `data_ready_pending`, `write_space_pending`) are properly initialized prior to branching or dereferencing.\n- The new callback pointers in `struct vsock_sock` (`default_data_ready`, `default_write_space`) are set upon socket creation in `__vsock_create()`.\n- No kernel structures are exported or copied to user space (no copy_to_user, put_user, netlink skb attrs, etc.).\n- The packet data handling and skb bounds checking are unchanged; `batch.bytes` and `batch.pkts` only bound the batch size.\n\nBug profile (KASAN/LOCKDEP vs. KMSAN):\nThe primary risks introduced by this change involve locking/concurrency (holding the socket lock across multiple packets, interactions with sockmap callbacks under callback locks) and socket reference counting (holding a socket reference across rx work iterations in `batch-\u003esk`), which could theoretically lead to use-after-free, refcount leaks, or deadlocks. These classes of bugs are thoroughly covered by KASAN, LOCKDEP, and standard refcount tracking. There are no uninitialized memory reads or information leak risks that would require KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit dcf73c5371be225c60de65291b49c22e335ba87b
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Oct 13 07:11:06 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h
index f91704731057e..f1396ca3ad9b5 100644
--- a/include/linux/virtio_vsock.h
+++ b/include/linux/virtio_vsock.h
@@ -282,6 +282,19 @@ void virtio_transport_destruct(struct vsock_sock *vsk);
void virtio_transport_recv_pkt(struct virtio_transport *t,
struct sk_buff *skb, struct net *net);
+
+struct virtio_transport_rx_batch {
+ struct sock *sk;
+ unsigned int pkts;
+ size_t bytes;
+ bool write_space_pending;
+ bool data_ready_pending;
+};
+
+void virtio_transport_recv_pkt_batch(struct virtio_transport *t,
+ struct sk_buff *skb, struct net *net,
+ struct virtio_transport_rx_batch *batch);
+void virtio_transport_rx_batch_finish(struct virtio_transport_rx_batch *batch);
void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct sk_buff *skb);
u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 wanted);
void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit);
diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 5549298c1ec6b..a799f08556376 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -63,6 +63,9 @@ struct vsock_sock {
u32 peer_shutdown;
bool sent_request;
bool ignore_connecting_rst;
+ /* Initial callbacks, used to identify replacements. */
+ void (*default_data_ready)(struct sock *sk);
+ void (*default_write_space)(struct sock *sk);
/* Protected by lock_sock(sk) */
u64 buffer_size;
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 44cee74519555..f40659ec29df0 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -958,6 +958,8 @@ static struct sock *__vsock_create(struct net *net,
sk->sk_type = type;
vsk = vsock_sk(sk);
+ vsk->default_data_ready = sk->sk_data_ready;
+ vsk->default_write_space = sk->sk_write_space;
vsock_addr_init(&vsk->local_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);
vsock_addr_init(&vsk->remote_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 4f9aa9c4c3aa5..ef076732158d4 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -629,8 +629,16 @@ virtio_transport_seqpacket_allow(struct vsock_sock *vsk, u32 remote_cid)
return seqpacket_allow;
}
+/*
+ * Keep a bounded run of packets for one socket under a single socket lock.
+ * Limit packet count and payload size to bound the work done while locked.
+ */
+#define VIRTIO_TRANSPORT_RX_BATCH_MAX_PKTS 64
+#define VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES (64 * 1024)
+
static void virtio_transport_rx_work(struct work_struct *work)
{
+ struct virtio_transport_rx_batch batch = {};
struct virtio_vsock *vsock =
container_of(work, struct virtio_vsock, rx_work);
struct virtqueue *vq;
@@ -666,6 +674,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
/* Drop short/long packets */
if (unlikely(len < sizeof(*hdr) ||
len > virtio_vsock_skb_len(skb))) {
+ virtio_transport_rx_batch_finish(&batch);
kfree_skb(skb);
continue;
}
@@ -673,6 +682,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
hdr = virtio_vsock_hdr(skb);
payload_len = le32_to_cpu(hdr->len);
if (unlikely(payload_len > len - sizeof(*hdr))) {
+ virtio_transport_rx_batch_finish(&batch);
kfree_skb(skb);
continue;
}
@@ -680,16 +690,33 @@ static void virtio_transport_rx_work(struct work_struct *work)
if (payload_len)
virtio_vsock_skb_put(skb, payload_len);
+ if (batch.sk &&
+ payload_len > VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES -
+ batch.bytes) {
+ virtio_transport_rx_batch_finish(&batch);
+ }
+
virtio_transport_deliver_tap_pkt(skb);
/* Force virtio-transport into global mode since it
* does not yet support local-mode namespacing.
*/
- virtio_transport_recv_pkt(&virtio_transport, skb, NULL);
+ virtio_transport_recv_pkt_batch(&virtio_transport, skb, NULL,
+ &batch);
+
+ if (batch.sk) {
+ batch.pkts++;
+ batch.bytes += payload_len;
+ if (batch.pkts >= VIRTIO_TRANSPORT_RX_BATCH_MAX_PKTS ||
+ batch.bytes >= VIRTIO_TRANSPORT_RX_BATCH_MAX_BYTES) {
+ virtio_transport_rx_batch_finish(&batch);
+ }
+ }
}
} while (!virtqueue_enable_cb(vq));
out:
+ virtio_transport_rx_batch_finish(&batch);
if (vsock->rx_buf_nr < vsock->rx_buf_max_nr / 2)
virtio_vsock_rx_fill(vsock);
out_nofill:
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index f225f53ed4bab..84822d6bfb958 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -576,11 +576,16 @@ virtio_transport_collapse_rx_queue(struct virtio_vsock_sock *vvs,
skb_queue_splice(&new_queue, &vvs->rx_queue);
}
+static bool
+virtio_transport_rx_skb_has_headroom(struct virtio_vsock_sock *vvs)
+{
+ return (u64)(skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0) <=
+ vvs->buf_alloc;
+}
+
static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,
u32 len)
{
- u64 skb_overhead = (skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
-
/* Allow at most buf_alloc * 2 total budget (payload + overhead),
* similar to how SO_RCVBUF is doubled to reserve space for sk_buff
* metadata. Check payload against buf_alloc to be sure the other
@@ -588,7 +593,7 @@ static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,
* queue growth.
*/
if ((u64)vvs->buf_used + len > vvs->buf_alloc ||
- skb_overhead > vvs->buf_alloc)
+ !virtio_transport_rx_skb_has_headroom(vvs))
return false;
vvs->rx_bytes += len;
@@ -1583,7 +1588,8 @@ virtio_transport_recv_enqueue(struct vsock_sock *vsk,
static int
virtio_transport_recv_connected(struct sock *sk,
- struct sk_buff *skb)
+ struct sk_buff *skb,
+ bool *data_ready_pending)
{
struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
struct vsock_sock *vsk = vsock_sk(sk);
@@ -1602,7 +1608,13 @@ virtio_transport_recv_connected(struct sock *sk,
vsock_remove_sock(vsk);
break;
}
- vsock_data_ready(sk);
+ if (!data_ready_pending) {
+ vsock_data_ready(sk);
+ } else if (!*data_ready_pending &&
+ (vsock_stream_has_data(vsk) >= sk->sk_rcvlowat ||
+ sock_flag(sk, SOCK_DONE))) {
+ *data_ready_pending = true;
+ }
return err;
case VIRTIO_VSOCK_OP_CREDIT_REQUEST:
virtio_transport_send_credit_update(vsk);
@@ -1774,84 +1786,96 @@ static bool virtio_transport_valid_type(u16 type)
(type == VIRTIO_VSOCK_TYPE_SEQPACKET);
}
-/* We are under the virtio-vsock's vsock->rx_lock or vhost-vsock's vq->mutex
- * lock.
- */
-void virtio_transport_recv_pkt(struct virtio_transport *t,
- struct sk_buff *skb, struct net *net)
+static struct sock *
+virtio_transport_find_socket(struct sk_buff *skb, struct sockaddr_vm *src,
+ struct sockaddr_vm *dst, struct net *net)
{
struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
- struct sockaddr_vm src, dst;
- struct vsock_sock *vsk;
struct sock *sk;
- bool space_available;
- vsock_addr_init(&src, le64_to_cpu(hdr->src_cid),
- le32_to_cpu(hdr->src_port));
- vsock_addr_init(&dst, le64_to_cpu(hdr->dst_cid),
- le32_to_cpu(hdr->dst_port));
-
- trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
- dst.svm_cid, dst.svm_port,
- le32_to_cpu(hdr->len),
- le16_to_cpu(hdr->type),
- le16_to_cpu(hdr->op),
- le32_to_cpu(hdr->flags),
- le32_to_cpu(hdr->buf_alloc),
- le32_to_cpu(hdr->fwd_cnt));
-
- if (!virtio_transport_valid_type(le16_to_cpu(hdr->type))) {
- (void)virtio_transport_reset_no_sock(t, skb, net);
- goto free_pkt;
- }
+ if (!virtio_transport_valid_type(le16_to_cpu(hdr->type)))
+ return NULL;
- /* The socket must be in connected or bound table
- * otherwise send reset back
- */
- sk = vsock_find_connected_socket_net(&src, &dst, net);
- if (!sk) {
- sk = vsock_find_bound_socket_net(&dst, net);
- if (!sk) {
- (void)virtio_transport_reset_no_sock(t, skb, net);
- goto free_pkt;
- }
- }
+ sk = vsock_find_connected_socket_net(src, dst, net);
+ if (!sk)
+ sk = vsock_find_bound_socket_net(dst, net);
+ if (!sk)
+ return NULL;
if (virtio_transport_get_type(sk) != le16_to_cpu(hdr->type)) {
- (void)virtio_transport_reset_no_sock(t, skb, net);
sock_put(sk);
- goto free_pkt;
+ return NULL;
}
- if (!skb_set_owner_sk_safe(skb, sk)) {
- WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
- goto free_pkt;
- }
+ return sk;
+}
- vsk = vsock_sk(sk);
+static bool
+virtio_transport_sock_has_psock(const struct sock *sk)
+{
+ return (uintptr_t)rcu_access_pointer(__sk_user_data(sk)) &
+ SK_USER_DATA_PSOCK;
+}
- lock_sock(sk);
+static bool
+virtio_transport_recv_pkt_batchable(struct virtio_transport *t,
+ struct sock *sk)
+{
+ struct vsock_sock *vsk = vsock_sk(sk);
+ struct virtio_vsock_sock *vvs = vsk->trans;
+
+ return sk->sk_state == TCP_ESTABLISHED &&
+ sk->sk_type == SOCK_STREAM &&
+ READ_ONCE(sk->sk_prot) == sk->sk_prot_creator &&
+ READ_ONCE(sk->sk_data_ready) == vsk->default_data_ready &&
+ READ_ONCE(sk->sk_write_space) == vsk->default_write_space &&
+ !sock_flag(sk, SOCK_DONE) &&
+ vsk->transport == &t->transport &&
+ vvs && virtio_transport_rx_skb_has_headroom(vvs) &&
+ !virtio_transport_sock_has_psock(sk);
+}
- /* Check if sk has been closed or assigned to another transport before
- * lock_sock (note: listener sockets are not assigned to any transport)
+/*
+ * The caller holds sk's socket lock. Set @batchable if the socket can remain
+ * locked for another ordinary STREAM/RW packet. Return true if the caller
+ * must free @skb.
+ */
+static bool
+virtio_transport_recv_pkt_locked(struct virtio_transport *t,
+ struct sk_buff *skb, struct sock *sk,
+ const struct sockaddr_vm *src,
+ const struct sockaddr_vm *dst,
+ struct net *net, bool *batchable,
+ struct virtio_transport_rx_batch *batch)
+{
+ struct vsock_sock *vsk = vsock_sk(sk);
+ bool space_available;
+
+ if (batchable)
+ *batchable = false;
+
+ /* Listener sockets accept packets from any source and are not assigned to
+ * a transport.
*/
if (sock_flag(sk, SOCK_DONE) ||
(sk->sk_state != TCP_LISTEN &&
- !vsock_check_source(vsk, &t->transport, &src))) {
+ !vsock_check_source(vsk, &t->transport, src))) {
(void)virtio_transport_reset_no_sock(t, skb, net);
- release_sock(sk);
- sock_put(sk);
- goto free_pkt;
+ return true;
}
space_available = virtio_transport_space_update(sk, skb);
/* Update CID in case it has changed after a transport reset event */
if (vsk->local_addr.svm_cid != VMADDR_CID_ANY)
- vsk->local_addr.svm_cid = dst.svm_cid;
+ vsk->local_addr.svm_cid = dst->svm_cid;
- if (space_available)
- sk->sk_write_space(sk);
+ if (space_available) {
+ if (batch)
+ batch->write_space_pending = true;
+ else
+ sk->sk_write_space(sk);
+ }
switch (sk->sk_state) {
case TCP_LISTEN:
@@ -1863,7 +1887,9 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
kfree_skb(skb);
break;
case TCP_ESTABLISHED:
- virtio_transport_recv_connected(sk, skb);
+ virtio_transport_recv_connected(sk, skb,
+ batch ?
+ &batch->data_ready_pending : NULL);
break;
case TCP_CLOSING:
virtio_transport_recv_disconnecting(sk, skb);
@@ -1875,12 +1901,59 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
break;
}
+ if (batchable)
+ *batchable = virtio_transport_recv_pkt_batchable(t, sk);
+
+ return false;
+}
+
+/* We are under the virtio-vsock's vsock->rx_lock or vhost-vsock's vq->mutex
+ * lock.
+ */
+void virtio_transport_recv_pkt(struct virtio_transport *t,
+ struct sk_buff *skb, struct net *net)
+{
+ struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
+ struct sockaddr_vm src, dst;
+ struct sock *sk;
+ bool free_pkt;
+
+ vsock_addr_init(&src, le64_to_cpu(hdr->src_cid),
+ le32_to_cpu(hdr->src_port));
+ vsock_addr_init(&dst, le64_to_cpu(hdr->dst_cid),
+ le32_to_cpu(hdr->dst_port));
+
+ trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
+ dst.svm_cid, dst.svm_port,
+ le32_to_cpu(hdr->len),
+ le16_to_cpu(hdr->type),
+ le16_to_cpu(hdr->op),
+ le32_to_cpu(hdr->flags),
+ le32_to_cpu(hdr->buf_alloc),
+ le32_to_cpu(hdr->fwd_cnt));
+
+ sk = virtio_transport_find_socket(skb, &src, &dst, net);
+ if (!sk) {
+ (void)virtio_transport_reset_no_sock(t, skb, net);
+ goto free_pkt;
+ }
+
+ if (!skb_set_owner_sk_safe(skb, sk)) {
+ WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
+ goto free_pkt;
+ }
+
+ lock_sock(sk);
+ free_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, &src, &dst,
+ net, NULL, NULL);
release_sock(sk);
/* Release refcnt obtained when we fetched this socket out of the
* bound or connected list.
*/
sock_put(sk);
+ if (free_pkt)
+ kfree_skb(skb);
return;
free_pkt:
@@ -1888,6 +1961,148 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
}
EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt);
+/*
+ * Finish the RX batch.
+ * For a non-empty batch, the caller must hold the socket lock acquired with
+ * lock_sock(). This function releases the lock and the batch's lookup
+ * reference.
+ * An empty batch is a no-op.
+ */
+void virtio_transport_rx_batch_finish(struct virtio_transport_rx_batch *batch)
+{
+ bool write_space_pending = batch->write_space_pending;
+ bool data_ready_pending = batch->data_ready_pending;
+ struct sock *sk = batch->sk;
+
+ batch->sk = NULL;
+ batch->pkts = 0;
+ batch->bytes = 0;
+ batch->write_space_pending = false;
+ batch->data_ready_pending = false;
+
+ if (!sk)
+ return;
+
+ if (write_space_pending)
+ vsock_sk(sk)->default_write_space(sk);
+
+ release_sock(sk);
+
+ if (data_ready_pending)
+ vsock_sk(sk)->default_data_ready(sk);
+
+ sock_put(sk);
+}
+EXPORT_SYMBOL_GPL(virtio_transport_rx_batch_finish);
+
+void virtio_transport_recv_pkt_batch(struct virtio_transport *t,
+ struct sk_buff *skb, struct net *net,
+ struct virtio_transport_rx_batch *batch)
+{
+ struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
+ struct sockaddr_vm src, dst;
+ struct vsock_sock *vsk;
+ bool batchable, start_batch;
+ struct sock *sk;
+ bool free_pkt;
+
+ /* Only STREAM/RW packets can share a socket lock. */
+ if (le16_to_cpu(hdr->type) != VIRTIO_VSOCK_TYPE_STREAM ||
+ le16_to_cpu(hdr->op) != VIRTIO_VSOCK_OP_RW) {
+ virtio_transport_rx_batch_finish(batch);
+ virtio_transport_recv_pkt(t, skb, net);
+ return;
+ }
+
+ vsock_addr_init(&src, le64_to_cpu(hdr->src_cid),
+ le32_to_cpu(hdr->src_port));
+ vsock_addr_init(&dst, le64_to_cpu(hdr->dst_cid),
+ le32_to_cpu(hdr->dst_port));
+
+ trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
+ dst.svm_cid, dst.svm_port,
+ le32_to_cpu(hdr->len),
+ le16_to_cpu(hdr->type),
+ le16_to_cpu(hdr->op),
+ le32_to_cpu(hdr->flags),
+ le32_to_cpu(hdr->buf_alloc),
+ le32_to_cpu(hdr->fwd_cnt));
+
+ if (batch->sk) {
+ vsk = vsock_sk(batch->sk);
+ if (vsock_addr_equals_addr(&src, &vsk->remote_addr) &&
+ dst.svm_port == vsk->local_addr.svm_port &&
+ vsock_net_check_mode(sock_net(batch->sk), net) &&
+ virtio_transport_recv_pkt_batchable(t, batch->sk)) {
+ sk = batch->sk;
+ if (!skb_set_owner_sk_safe(skb, sk)) {
+ WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
+ virtio_transport_rx_batch_finish(batch);
+ kfree_skb(skb);
+ return;
+ }
+
+ free_pkt = virtio_transport_recv_pkt_locked(t, skb, sk,
+ &src, &dst,
+ net,
+ &batchable,
+ batch);
+ if (!batchable)
+ virtio_transport_rx_batch_finish(batch);
+ if (free_pkt)
+ kfree_skb(skb);
+ return;
+ }
+
+ virtio_transport_rx_batch_finish(batch);
+ }
+
+ sk = virtio_transport_find_socket(skb, &src, &dst, net);
+ if (!sk) {
+ (void)virtio_transport_reset_no_sock(t, skb, net);
+ kfree_skb(skb);
+ return;
+ }
+
+ if (!skb_set_owner_sk_safe(skb, sk)) {
+ WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
+ kfree_skb(skb);
+ return;
+ }
+
+ lock_sock(sk);
+ /*
+ * Sockmap teardown restores callbacks under sk_callback_lock. Keep the
+ * initial eligibility check consistent with that update.
+ */
+ read_lock_bh(&sk->sk_callback_lock);
+ start_batch = virtio_transport_recv_pkt_batchable(t, sk);
+ read_unlock_bh(&sk->sk_callback_lock);
+
+ if (start_batch)
+ batch->sk = sk;
+
+ free_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, &src, &dst,
+ net,
+ start_batch ? &batchable : NULL,
+ start_batch ? batch : NULL);
+ if (start_batch && batchable) {
+ /* Keep the lookup reference until the batch is released. */
+ return;
+ }
+
+ if (start_batch) {
+ virtio_transport_rx_batch_finish(batch);
+ } else {
+ release_sock(sk);
+ sock_put(sk);
+ }
+
+ if (free_pkt)
+ kfree_skb(skb);
+}
+EXPORT_SYMBOL_GPL(virtio_transport_recv_pkt_batch);
+
/* Remove skbs found in a queue that have a vsk that matches.
*
* Each skb is freed.
|
| 23/3 | 2026/10/13 07:13 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 9206 output: 431 thoughts: 2525 Thoughts: **KMSAN Assessment: virtio/vsock rx batching optimization!**
Okay, let's break this down. My goal is to figure out if this patch series on virtio/vsock rx batching warrants a KMSAN fuzzing session. Given my experience, I know a KMSAN session is costly and should only be triggered if we're dealing with issues that KASAN, LOCKDEP, or other standard tools can't catch. The core of my analysis revolves around identifying if this patch introduces or exposes the risk of reading uninitialized memory, either on the stack, heap, or during kernel-to-user data transfers.
First, I examined the patch details: a new `struct virtio_transport_rx_batch` for packet batching, new callback pointers in `struct vsock_sock` that are initialized with socket's existing `data_ready` and `write_space` and associated functions to manage and process these batches. I'm looking for anything that screams "uninitialized memory." The initial zero-initialization of the `struct virtio_transport_rx_batch batch = {};` seems safe. The various flags and pointers within the batching logic are carefully initialized before use, especially the `batchable` flag, which is checked and set consistently.
I scrutinized the data flow. Is any of this data being copied to user space? No, this patch operates entirely within the kernel's RX path, optimizing batching and delayed socket wakeups. No direct data transfer to user space. It seems the patch is primarily changing the concurrency and packet processing flow.
I considered potential bug scenarios: concurrency/locking bugs (holding locks, callback serialization, sockmap interactions), reference counting bugs (use-after-free, leaks), and logic bugs (dropped packets, delayed notifications). These are potential issues, but I'm confident they are all within the scope of KASAN, LOCKDEP, refcount tracking, and other standard debugging tools. Importantly, none of these seem like uninitialized memory issues that KMSAN is specifically designed to catch.
I systematically walked through my checklist: Is any kernel structure being sent to user space where fields might be uninitialized? No. Are there any branches that depend on uninitialized variables? No. Are complex data structures being allocated and used without complete initialization? The stack allocation with zero-initialization of `batch` seems fine. Are there any bounds checks or logic that could lead to reading uninitialized bytes of existing buffers? No, data handling and bounds checking in `virtio_vsock_hdr` are unaffected; the changes are just about batching and deferring socket events.
Based on all this, there's no smoking gun here that points to uninitialized memory being read. KASAN and LOCKDEP will be sufficient to identify any memory safety or locking issues. Therefore, my conclusion is that `NeedsKMSAN` should be `false`.
For clarity, I will articulate my reasoning, contrasting KASAN vs KMSAN applicability. I'll summarize the patch's rx batching optimization, how memory is handled, and emphasize potential risks, such as concurrency bugs and socket reference counting issues. Then, I'll re-emphasize the absence of KMSAN-specific triggers, namely uninitialized stack/heap reads, data copies to user space, and payload boundaries manipulations. This will provide a concise justification for why KASAN and LOCKDEP are fully adequate here and why a KMSAN session would be a misuse of resources. And then, I will call `set-results`.
|
| 24/3 | 2026/10/13 07:13 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch implements an RX batching optimization for virtio-vsock, allowing a bounded run of packets (up to 64 packets or 64 KiB) destined for the same connected stream socket to be processed under a single socket lock, while deferring sk_data_ready and sk_write_space wakeups.\n\nMemory and state initialization review:\n- The newly introduced `struct virtio_transport_rx_batch` is allocated on the stack in `virtio_transport_rx_work` and explicitly zero-initialized (`= {}`).\n- All local flags and out-parameters (`start_batch`, `batchable`, `free_pkt`, `data_ready_pending`, `write_space_pending`) are properly initialized prior to branching or dereferencing.\n- The new callback pointers in `struct vsock_sock` (`default_data_ready`, `default_write_space`) are set upon socket creation in `__vsock_create()`.\n- No kernel structures are exported or copied to user space (no copy_to_user, put_user, netlink skb attrs, etc.).\n- The packet data handling and skb bounds checking are unchanged; `batch.bytes` and `batch.pkts` only bound the batch size.\n\nBug profile (KASAN/LOCKDEP vs. KMSAN):\nThe primary risks introduced by this change involve locking/concurrency (holding the socket lock across multiple packets, interactions with sockmap callbacks under callback locks) and socket reference counting (holding a socket reference across rx work iterations in `batch-\u003esk`), which could theoretically lead to use-after-free, refcount leaks, or deadlocks. These classes of bugs are thoroughly covered by KASAN, LOCKDEP, and standard refcount tracking. There are no uninitialized memory reads or information leak risks that would require KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch implements an RX batching optimization for virtio-vsock, allowing a bounded run of packets (up to 64 packets or 64 KiB) destined for the same connected stream socket to be processed under a single socket lock, while deferring sk_data_ready and sk_write_space wakeups.\n\nMemory and state initialization review:\n- The newly introduced `struct virtio_transport_rx_batch` is allocated on the stack in `virtio_transport_rx_work` and explicitly zero-initialized (`= {}`).\n- All local flags and out-parameters (`start_batch`, `batchable`, `free_pkt`, `data_ready_pending`, `write_space_pending`) are properly initialized prior to branching or dereferencing.\n- The new callback pointers in `struct vsock_sock` (`default_data_ready`, `default_write_space`) are set upon socket creation in `__vsock_create()`.\n- No kernel structures are exported or copied to user space (no copy_to_user, put_user, netlink skb attrs, etc.).\n- The packet data handling and skb bounds checking are unchanged; `batch.bytes` and `batch.pkts` only bound the batch size.\n\nBug profile (KASAN/LOCKDEP vs. KMSAN):\nThe primary risks introduced by this change involve locking/concurrency (holding the socket lock across multiple packets, interactions with sockmap callbacks under callback locks) and socket reference counting (holding a socket reference across rx work iterations in `batch-\u003esk`), which could theoretically lead to use-after-free, refcount leaks, or deadlocks. These classes of bugs are thoroughly covered by KASAN, LOCKDEP, and standard refcount tracking. There are no uninitialized memory reads or information leak risks that would require KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|