linux/net
Ilia Gavrilov 7c24a4e87e vsock: Fix memory leak in vmci_transport_recv_dgram_cb()
During the closure of a datagram socket, the vmci_transport_recv_dgram_cb()
function may be called, which will add the packets
to the socket's backlog; then, after the receive queue is cleared,
the __release_sock() function will move the packet back from the socket's
backlog to the receive queue, which will lead to a memory leak.

sock_close
  __sock_release
    __vsock_release
      // take ownership by user-space
      lock_sock_nested
      sock_set_flag(sk, SOCK_DEAD)
      vmci_transport_release
                                      vmci_dispatch_dgs
                                        vmci_datagram_invoke_guest_handler
                                          vmci_transport_recv_dgram_cb
                                            sk_receive_skb
                                              if (!sock_owned_by_user(sk))
                                                  [...]
                                         (!)  else if sk_add_backlog()
                                                  [...]
  (!) skb_queue_purge(&sk->sk_receive_queue)

      release_sock
        __release_sock
          // move all packets from the backlog
          // to the receive queue
   (!)    sk_backlog_rcv
            vsock_queue_rcv_skb
            [...]
              __sock_queue_rcv_skb
                if (!sock_flag(sk, SOCK_DEAD))
                  // Since the socket is "dead", the function will not
                  // be called
                  sk->sk_data_ready(sk)
        sock_release_ownership(sk);
        sock_put

Add a receive queue cleanup in the socket destructor to fix this.

syzkaller report:

unreferenced object 0xffff8880117bfb80 (size 240):
  comm "irq/56-vmw_vmci", pid 205, jiffies 4295064448 (age 73.992s)
  hex dump (first 32 bytes):
    78 dc 26 1e 80 88 ff ff 78 dc 26 1e 80 88 ff ff  x.&.....x.&.....
    00 00 00 00 00 00 00 00 c0 da 26 1e 80 88 ff ff  ..........&.....
  backtrace:
    [<ffffffff82be8d97>] __alloc_skb+0x287/0x330 net/core/skbuff.c:505
    [<ffffffffa114bcbd>] vmci_transport_recv_dgram_cb+0xbd/0x210 [vmw_vsock_vmci_transport]
    [<ffffffffa05072c6>] vmci_datagram_invoke_guest_handler+0x366/0x450 [vmw_vmci]
    [<ffffffffa050ad75>] vmci_dispatch_dgs+0x235/0x490 [vmw_vmci]
    [<ffffffffa050b025>] vmci_interrupt+0x55/0x290 [vmw_vmci]
    [<ffffffff8137ad2b>] irq_thread_fn+0x8b/0x1a0 kernel/irq/manage.c:1205
    [<ffffffff8137c7ae>] irq_thread+0x28e/0x530 kernel/irq/manage.c:1314
    [<ffffffff81253dd6>] kthread+0x2e6/0x3a0 kernel/kthread.c:376
    [<ffffffff81004392>] ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:295

Found by InfoTeCS on behalf of Linux Verification Center
(linuxtesting.org) with Syzkaller.

Fixes: d021c34405 ("VSOCK: Introduce VM Sockets")
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Ilia Gavrilov <Ilia.Gavrilov@infotecs.ru>
Link: https://patch.msgid.link/20261008144046.90853-1-Ilia.Gavrilov@infotecs.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-08 11:46:13 -07:00
..
6lowpan net: 6lowpan: fix mismatched comments 2026-09-02 09:03:06 +02:00
9p 9p: Add missing read barrier in virtio zero-copy path 2026-06-21 05:22:57 +00:00
802 appletalk: move the protocol out of tree 2026-06-16 14:37:06 -07:00
8021q vlan: ensure sufficient headroom in vlan_dev_hard_header() 2026-09-24 11:00:59 -07:00
atm pppoatm: ensure a writable skb header and linear data 2026-09-15 17:07:01 -07:00
batman-adv treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
bluetooth Bluetooth: ISO: Serialize concurrent connect calls 2026-10-05 13:10:47 -04:00
bpf bpf: Use kvfree() in xdp_test_run_teardown() 2026-09-12 12:11:41 -07:00
bridge ipv4: validate checksum_start before completing checksum 2026-10-08 11:03:47 -07:00
can can: fix unique skb identifier regression under RPS 2026-10-01 17:05:03 +02:00
ceph libceph: remove pinning assertion in ceph_msg_data_iter_next() 2026-09-02 12:23:05 +02:00
core net: skbuff: don't leave stale bytes in skb_copy_and_csum_bits() 2026-10-08 10:57:41 -07:00
dcb
devlink devlink: fix devlink_rel reference leak when notify work is pending 2026-10-06 17:16:14 -07:00
dns_resolver keys, dns: Drop unused NUL terminator from upayload->data 2026-08-10 16:20:42 -07:00
dsa net: dsa: tag_brcm: legacy FCS: request needed tailroom 2026-09-09 13:31:08 -07:00
ethernet
ethtool net: ethtool: let tsconfig reach a PHY-only timestamp provider 2026-09-28 19:26:41 -07:00
handshake handshake: Require admin permission for DONE command 2026-06-12 15:45:44 -07:00
hsr net: hsr: enable promiscuous mode on interlink port with fwd offload 2026-09-10 08:45:00 -07:00
ieee802154 ieee802154: 6lowpan: fix NULL dereference in lowpan_newlink 2026-09-02 09:54:27 +02:00
ife net/sched: act_ife: Only operate on Ethernet frames 2026-08-24 11:59:59 -07:00
ipv4 ipv4: do not warn on route notification size race 2026-10-08 11:32:36 -07:00
ipv6 ipv6: do not warn on route notification size race 2026-10-08 11:32:36 -07:00
iucv net/iucv: fix the recvmsg window update 2026-08-31 15:51:22 -07:00
kcm net: kcm: Hold RCU read lock while running BPF parser 2026-08-17 13:43:58 -07:00
key ipsec-2026-06-22 2026-06-23 16:22:24 -07:00
l2tp net: l2tp: do not propagate multicast notification errors 2026-08-24 11:43:28 -07:00
l3mdev
lapb
llc llc: fix skb UAF and leaks on llc_mac_hdr_init() failure 2026-09-24 11:00:59 -07:00
mac80211 wifi: mac80211: don't estimate airtime for unsupported rate widths 2026-10-07 12:46:15 +02:00
mac802154 mac802154: fix use-after-free of sdata via queued RX frames 2026-09-03 11:00:54 +02:00
mctp net/mctp: publish the mctp_dev only after it is initialised 2026-09-25 16:34:40 -07:00
mpls Summary 2026-08-20 08:46:41 -07:00
mptcp mptcp: fix bad accounting in __mptcp_subflow_push_pending() 2026-09-17 08:14:33 -07:00
ncsi net/ncsi: fix heap OOB read in NCSI_CMD_SEND_CMD payload length 2026-08-05 17:24:57 -07:00
netfilter ipv4: validate checksum_start before completing checksum 2026-10-08 11:03:47 -07:00
netlabel Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-06-11 14:33:35 -07:00
netlink genetlink: report the real command id for dump-only ops in policy dumps 2026-09-22 15:21:32 +02:00
nfc nfc: llcp: fix slab-out-of-bounds reads when logging service names 2026-09-23 22:13:17 +02:00
nsh
openvswitch net: openvswitch: validate transport header presence in set_ipv6_addr 2026-10-08 11:33:38 -07:00
packet net/packet: call packet_parse_headers after virtio_net_hdr_to_skb 2026-10-08 10:59:20 -07:00
phonet phonet: pep: convert getsockopt to sockopt_t 2026-08-03 16:55:23 -07:00
psample net: psample: fix info leak in PSAMPLE_ATTR_DATA 2026-06-17 16:35:50 -07:00
psp net: psp: avoid conflicts with skb->decrypted and sk_validate_xmit_skb() 2026-09-16 19:18:24 -07:00
qrtr net: qrtr: resend HELLO on MHI resume 2026-09-20 11:21:10 -07:00
rds net/rds: size a connection's path set by the transport it ends up with 2026-09-24 10:03:23 -07:00
rfkill Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
rxrpc treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
sched net/sched: cls_route: reject change with no routing attribute 2026-10-06 17:59:06 -07:00
sctp sctp: copy zeroed stats to user in sctp_getsockopt_pr_streamstatus() when !streamoute 2026-10-06 18:15:13 -07:00
shaper net: shaper: add a note that we expect cap dumps to be tiny 2026-06-11 12:55:23 +02:00
smc net/smc: protect clcsock lifetime in smc_getname 2026-10-08 11:33:12 -07:00
strparser strparser: make sure __strp_recv isn't running before tearing down the parser 2026-10-06 18:29:12 -07:00
sunrpc treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
switchdev
tipc tipc: destroy topsrv workqueues before closing connections 2026-10-02 08:20:15 +01:00
tls tls: device: fix out-of-bounds write in tls_append_frag() 2026-08-25 10:04:02 +02:00
unix af_unix: Unify scc_index when finalising SCC in __unix_walk_scc(). 2026-09-15 16:45:05 -07:00
vmw_vsock vsock: Fix memory leak in vmci_transport_recv_dgram_cb() 2026-10-08 11:46:13 -07:00
wireless wifi: cfg80211: preserve hidden-group beacon IE ownership 2026-09-22 10:47:54 +02:00
x25 net/x25: fix use-after-free of the socket by its timers 2026-07-30 18:46:45 -07:00
xdp xsk: Use a 32-bit compare in xsk_map_gen_lookup 2026-09-17 10:56:16 -07:00
xfrm ipv4: validate checksum_start before completing checksum 2026-10-08 11:03:47 -07:00
compat.c net: af_unix: useful handling of LSM denials on SCM_RIGHTS 2026-08-17 18:14:52 -07:00
devres.c
Kconfig appletalk: move the protocol out of tree 2026-06-16 14:37:06 -07:00
Kconfig.debug
Makefile appletalk: move the protocol out of tree 2026-06-16 14:37:06 -07:00
socket.c Major changes: 2026-08-20 07:36:20 -07:00
sysctl_net.c net: enforce net sysctl registration 2026-08-13 13:12:21 +02:00