From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 BB115346AF1 for ; Tue, 5 May 2026 10:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777976789; cv=none; b=CmiPZN6jhnXfvwLydR4tXyV2usVi95AkOJXXlj46EbCCzx7l81ZD5qzUDDgQO90XQ/vM0OWJSE7gfmAoxEF+nnmO/i20+cKqs9jlEcJ51Qxs/mxb0+rX/L/Vsa6ohC8rWl0D2GARN03lA4Vk7DYdMBl6f0mfV3BrtSVgbciU+2A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777976789; c=relaxed/simple; bh=RRVfVaOkvzElgVyb2yZpLwWWK5VmJ9IAKgLIwU5tDcM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Yyx9gNtLkINqR2gs2pE/BCMY0dAEjTgCc0vsuFLNA955yZfj699nS9BKgtdfNjX4oUB6s1N/l+A/GGASlj9wMs/Gdapi9aNL2+QN5owTXtm/NDc3HgRLobOZNuctJ8D2ks28tSx8plEfzkDfffb5YZPnGi/pWgncy76PcZu1BNA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eGDbEP2C; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=JgS1uo6x; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eGDbEP2C"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="JgS1uo6x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777976786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1OCMbAA6XIkOk80k4O/cwTIGAofxbZ6zwNtF/F1aXko=; b=eGDbEP2C6NgHWsCRw46WhvmNp3RaXFAbb797/fKXI+jQ4KYzH0pkgaWeK0qGuLmnETS+IJ 3xNB1EKGUfqpAW7uiV8/IH8SaQxM4sCMqgN1x/i8+ObomPiv4/jvKtLZ9j99rojgssPPBB JtGOf3xbsCoJx9EvkElAJI2dAYNk/s4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-Hgoj4NVAMsazphboG0B2ng-1; Tue, 05 May 2026 06:26:24 -0400 X-MC-Unique: Hgoj4NVAMsazphboG0B2ng-1 X-Mimecast-MFC-AGG-ID: Hgoj4NVAMsazphboG0B2ng_1777976783 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-48a5fb71a84so25799755e9.1 for ; Tue, 05 May 2026 03:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1777976783; x=1778581583; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1OCMbAA6XIkOk80k4O/cwTIGAofxbZ6zwNtF/F1aXko=; b=JgS1uo6xmcggPsJkl1C1y+OM04GxvtHWSPbB6lnzgLxjCqCSpm76nTWFbHZoaESpOV HNr+BXZTaoTwiHn0vaNOuLHjHb2btdmeXJeO3y90t9ACagZ/Z31RfmoV7p4Fl0uA8wDh poj2G1bDUHsGduk1kYHLkxkbfTq7yzodDHTSPxmlEdKOc1JmNeb9Caq7F7Ml7wuGEoFr kMPYIFl0sG3G2+AIVhjzyG2kag28zrrgT60gLOKSJkLy0LbzeftrJUx8EQQn3I7dKF5Y 3px8Eoc90Ww4IMNqYwABYnNN+MjsPo89EptF9eDPyvI0XHlBab17RfAKMUt4JwPI7pcl 3lPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777976783; x=1778581583; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1OCMbAA6XIkOk80k4O/cwTIGAofxbZ6zwNtF/F1aXko=; b=shShRiUn+0bRXCn8uyjYVjOEzQkp7alyquckoBr9K5inBoq7/9GCGumgyKcFT+25TC jicT32wnFBzuv/Rpd5WaVNXyMTK7k36sE42AXpHyzw6dyFjdW6vdFRJ8os55FH8n5/UW 34RcyjGvwzGSbMekK7tV3KcoWALyKZUH2lwhbepZx1bCiWd0YGarYUTqYaVLygMWHYyl OMUARPDrkJiG52qNu8eT7aqCEaKtcWtHxdPH0kc0eO1WjiBSqmBoe5KITndbC24UMl3n q38UeSjoczin5RDYmpUY6cgfHl9bxx/5LszQ/2CbqB1c3HeU0HVBS/kamEQV5n84hMca gBVw== X-Forwarded-Encrypted: i=1; AFNElJ9t4zkaPXpHCrGS0zYQ75i/VDlSWlCx5OgUUn1a9U5NJGHZF+owptlDU74SJvsmUyjIPY+o1VWhn/aHV2U=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4yAweFqgCI0kQ61pmZrSKQVkfDxsofyFfhVt7GhG9wHClsoiP BDl0KBGiVRs0APK1Fsc6sEFu5sZgwJ6XutQo1tqorffJV0pNNHRHZBqd2bXo8XgjbT7JCdIuuva 5g1hwTEeqNCVqth721pUNnAeajXNCov3GitNP4YrH+B445NOF4ORixBNmL1BkbbRoAw== X-Gm-Gg: AeBDieui8m31tz9KtuEfDjOZ736TDk73E2SqKr/l495g2PPbvPTPbK1oDmBISq89pPG HTixkszftJtRjgeZBN6bXpOltaOQ26Z316Dlgtf60OkunMHJuO5sJAUa+CjQvjaSLPuUn3Rd35o 3C2g8pHNezb0O6DirUc7eYqmHd3d9r844nQYiRDL5A7CpezYzTAL2pv4b5iM5c9wK+UV5+YtdUw AuP4q7KSIn0jkzqqITGhNIAwlTgzZug/I2k/Beb/GPB6AYo3LZ84819v4K1UHPYC4vi9f7TK7My Rq5bCIhvi5rurzdhsADCbIVR3vlRiHgYGVVZNY7wuOvS+aoTK5EhsRtssJZ+cXH+6SYlSNxmdmF klnQADoYTA2F76kPjVP0kQtKmGBMFu+1ZQzBbnivoyAFxf/DiVWaLAKPel1V1DwjR7OI= X-Received: by 2002:a05:600c:4e16:b0:486:f893:56c6 with SMTP id 5b1f17b1804b1-48d1425b450mr48869385e9.10.1777976783426; Tue, 05 May 2026 03:26:23 -0700 (PDT) X-Received: by 2002:a05:600c:4e16:b0:486:f893:56c6 with SMTP id 5b1f17b1804b1-48d1425b450mr48868885e9.10.1777976782990; Tue, 05 May 2026 03:26:22 -0700 (PDT) Received: from [192.168.88.32] ([212.105.155.47]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48d17714dc8sm28079685e9.4.2026.05.05.03.26.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 May 2026 03:26:22 -0700 (PDT) Message-ID: Date: Tue, 5 May 2026 12:26:21 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] vsock/virtio: fix vsockmon info leak in non-linear tap copy To: sgarzare@redhat.com, stefanha@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, horms@kernel.org, Yiqi Sun , kvm@vger.kernel.org, virtualization@lists.linux.dev References: <20260430071110.380509-1-sunyiqixm@gmail.com> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20260430071110.380509-1-sunyiqixm@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/30/26 9:11 AM, Yiqi Sun wrote: > vsockmon mirrors packets through virtio_transport_build_skb(), which > builds a new skb and copies the payload into it. For non-linear skbs, > this goes through virtio_transport_copy_nonlinear_skb(). > > Helper manually initializes a iov_iter, but leaves iov_iter.count unset. > As a result, skb_copy_datagram_iter() sees zero writable bytes > in the destination iterator and copies no payload data. > > This becomes an info leak because virtio_transport_build_skb() has > already reserved payload_len bytes in the new skb with skb_put(). The > skb is then returned to the tap path with that payload area still > uninitialized, so userspace reading from a vsockmon device can observe > heap contents and potentially kernel address. > > Fix it by initializing iov_iter.count to the number of bytes to copy. > > Fixes: 4b0bf10eb077 ("vsock/virtio: non-linear skb handling for tap") > Signed-off-by: Yiqi Sun > --- > net/vmw_vsock/virtio_transport_common.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c > index 416d533f493d..6b26ee57ccab 100644 > --- a/net/vmw_vsock/virtio_transport_common.c > +++ b/net/vmw_vsock/virtio_transport_common.c > @@ -152,7 +152,7 @@ static void virtio_transport_copy_nonlinear_skb(const struct sk_buff *skb, > iov_iter.nr_segs = 1; > > to_copy = min_t(size_t, len, skb->len); > - > + iov_iter.count = to_copy; > skb_copy_datagram_iter(skb, VIRTIO_VSOCK_SKB_CB(skb)->offset, > &iov_iter, to_copy); @Stefano, @Stefan, the patch LGTM, but sashiko pointed out to a pre-existing issue you should probably want to address: > to_copy = min_t(size_t, len, skb->len); Does this length calculation account for the offset when a packet is split across multiple transmissions? If a packet is requeued, VIRTIO_VSOCK_SKB_CB(skb)->offset is increased, but to_copy still evaluates to the full length of the skb. /P