From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B40261D63E4; Sat, 30 May 2026 18:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780167038; cv=none; b=kjS04Zl6QmMQzbkJPdIdV4VDhsIqwXSM46nXDlGmVfBzFtLswTH9Etnw2VZY0oYUVx8QBUXLeHN7uekuHQCVFI5K0Fwav6X4klTUzrk0QjjdoOHrc2YTE/zjsW8flz/SOjsPEmrg73YpIax5lidhvuwCpeJOmDsQeFhzFDnT3+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780167038; c=relaxed/simple; bh=Ww1rYVA0a3Hp3oC8TifdagWuFmtBM6mvdmQiIGLnRqI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pHh12P89SgGNtLGFTeE4bpstn2DrbX6ZW/A1CDz3XvCW6DH+lmTTpxd1RzaWNuN6paeBY0OmCOaliOS1UxTPAFGB3bNxDDFQeMQ/49S8ckO3TYji58Q33t2WrL+a3u1Ph+w9Z8csDxQFGY1RxJrlPB289g7BrcmaBmnErUt/I94= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aV1BzsbQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="aV1BzsbQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04ACA1F00893; Sat, 30 May 2026 18:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780167037; bh=I9t32nd3mQeGUZOalHv1h4qBEO5DLcuGw5Un7s4jf6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aV1BzsbQHZlBuHswfFg/S3jZJvcc6szTyhdzEpiQWe1CTDzOpgnBTSdbs2Drp5sIb /kIRFZ6Hpv/PgeQC6uX1Z9o3ROj/T5+jQc/z4dTOqXh02Gx6yudt+qCg8c6pDJxfxo 3h+JMzPtbtu9NzfWXXVVXAS1LDjKEvsglshuRX34= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Minh Nguyen , Bryan Tan , Jakub Kicinski Subject: [PATCH 5.10 538/589] vsock/vmci: fix UAF when peer resets connection during handshake Date: Sat, 30 May 2026 18:06:59 +0200 Message-ID: <20260530160238.833252523@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160224.570625122@linuxfoundation.org> References: <20260530160224.570625122@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Minh Nguyen commit 99e22ddf4edb63dc8382bc028af928056d3450cf upstream. vmci_transport_recv_connecting_server() returned err = 0 for a peer RST in its default switch arm: err = pkt->type == VMCI_TRANSPORT_PACKET_TYPE_RST ? 0 : -EINVAL; That made vmci_transport_recv_listen() skip vsock_remove_pending(), leaving the pending socket on the listener's pending_links with sk_state = TCP_CLOSE while destroy: still dropped the explicit reference taken before schedule_delayed_work(). One second later vsock_pending_work() observed is_pending=true and performed full cleanup: vsock_remove_pending() then the two trailing sock_put(sk) calls -- the first reached refcount 0 and __sk_freed the socket, and the second wrote into the freed object: BUG: KASAN: slab-use-after-free in refcount_warn_saturate Write of size 4 at addr ffff88800b1cac80 by task kworker Workqueue: events vsock_pending_work Treat peer RST like any other unexpected packet type (err = -EINVAL). All destroy: arms now return err < 0, so vmci_transport_recv_listen() removes pending from pending_links synchronously and vsock_pending_work() takes the is_pending=false / !rejected branch, dropping only its own work reference. This also closes the multi-packet race Sashiko reported on v2: pending is removed from the list before any subsequent packet can find it. The pre-existing sk_acceptq_removed() gap on the err < 0 path of vmci_transport_recv_listen() that Sashiko also noted is not introduced or changed by this patch. Tested on lts-6.12.79 with KASAN: 52/100 unpatched -> 0/100 patched. Fixes: d021c344051a ("VSOCK: Introduce VM Sockets") Cc: stable@vger.kernel.org Signed-off-by: Minh Nguyen Acked-by: Bryan Tan Link: https://patch.msgid.link/20260519102310.237181-1-minhnguyen.080505@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/vmw_vsock/vmci_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/vmw_vsock/vmci_transport.c +++ b/net/vmw_vsock/vmci_transport.c @@ -1158,7 +1158,7 @@ vmci_transport_recv_connecting_server(st /* Close and cleanup the connection. */ vmci_transport_send_reset(pending, pkt); skerr = EPROTO; - err = pkt->type == VMCI_TRANSPORT_PACKET_TYPE_RST ? 0 : -EINVAL; + err = -EINVAL; goto destroy; }