From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D10733A9E9 for ; Thu, 7 May 2026 20:12:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778184762; cv=none; b=uc9uUsIBjS13EaGQFQsN6zhCvGPTGc07ErwdY7PQWxVeIbmoVWpPomQt7KtdsbYqs3j0M268auSVJe0tSm6vtu7ERA9QHoeQb8D9MFhdPnnssANzJKAY8WEb/Bv7vAzl68IlJulLj71ttC5eDV4btxgFrOO+kDCYuHrdOYXgo30= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778184762; c=relaxed/simple; bh=YiA1eEseDRCOb+C4MPisetZeRtex0Ar8vxo2COhJHQM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E2IsjUgm9oBlMIF0RISeq04T05fjcAZaKqnwn/aJ03dv4yGBdWHtCgvlbgXZmmcBoM0zhaMoh80pxl8PL9MTFtfHXuAgmBAnvZbDf2X57d2OmA74c5KAtHQr2YfwqvCGFry2u9qRlV5dHBZUeMJD4GcWlv2B7yFLKhw12G1F9P4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T/g/ge06; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T/g/ge06" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-8ec37d52c0dso178716485a.0 for ; Thu, 07 May 2026 13:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778184760; x=1778789560; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CufiyOMzWgsZjfa0uu9olo/GL0CEznYyMUEZlGLNhMU=; b=T/g/ge061pRx5t3ffnUhKYtUO1RKS8vcp/2PZ57Ge6G/H/wCYga5KeuVfgq4E/8WZj mqTxGJPqx0Vg9m/Q/tcgRtOMaca503DSeo1ZGJAZjrstg9VYO6MuHTyFdyQjw3ByD+XA P9Muo/iBBht1PhJdjiUfJABtnlwNlONhVlNNnVlNWnnUSjQKQSNA8S5kKGTKbeGwACBd QcmBXc1xlKiyJsDe1EG4sfjPcsTxbSAIOWXNtB3L7v/2AO2c4Wmnrs6xByPM0mFpBlAL rM9HL3Y0ubuZw1ZmmGLpodyBmSVbaNBlANnOXopMMh6NThpaktkZTSSOkoByIJYJ3GjM S9Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778184760; x=1778789560; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CufiyOMzWgsZjfa0uu9olo/GL0CEznYyMUEZlGLNhMU=; b=WFczqpZIlN4HnnrRwiNMH7zGYFSucYB1ycZl9+4d1Jo5iHp9j2fP3eSyLBMMjwc+fr iet1wwYKSzMBWfTJPP7bqIum+RM+S3x+ZPIDYq0dLd3+k1w9+w1OjoNzxZ7Y+GRTiFU9 RIMUJluomuagDpHslKS80pTTnZnq2YYNCrnINzfCUZENJDtxH4GwLV26Ud6Hu5t4shtu GMIfSrbEvZrKt5fSeF9J+XlDHQeF4y14BtCM5MNxvXtEYHPqBA3YOboDc5Aak/60nnSD 1vZSe1+QbzW288bwfX7RG6H20Te6osTpovio4Gk83RnJYS42CAEpce4w2pcWtQ8Zw8KG QDSw== X-Forwarded-Encrypted: i=1; AFNElJ/FrQdjPibDM8P7M2NacH22K265AJcF7K6WPR5UxfTEJtSyZ6nN5KdDfV3wCYf7S8cbEC9kBSmJQAVAYYI=@vger.kernel.org X-Gm-Message-State: AOJu0YzBfYwQrkntL27ZHl5Jf8lezKY4qCf2mwggyks1lC+Q1FMYbLC5 B0qNbYn0N1CrNYdLUm5lHUTiQb6nv969jTDQfMNpjx74W66q5tax1+Ky X-Gm-Gg: AeBDiesIjQZlkPuAMXLVojaJ5LZoBsfhiN97xf46Wmw3sfpsd0OLaGuG+Q+Fw1EDBKC rqHIbhNurBhTCsKZET+5XrtEvm6Um2I9W/Sb9CuES92fN9x9CW6DrNPaQ7WtJLiN+88tngEs2II 0Ha0n8mhsYseR+voQX9NYR/IryYvtdQ3Nu0sYE9tRy3vwhoLSvwutv5sJYw9VGc/XcwiaaoN1Ws SWDAUWZbW871kpssfB7+kehtCRpX/xcKqbk9puIdjss5H5u7VrTrndlzUuk/Ix/B7f4D7Zv++CM ZekEZav64hurnF8BhFcovHO71RY8abkMjLqDWgileOOCsDIrbB3yRp2ZEPCZlYptrkLFBgV+R5Q 76yv6AeNd/ifTgLDirHJNzFy/RCgSZxrE7s+i3KNC7VcSGqAIyI0WTcqZhpZU5i4QbgIRY+4tQ+ AroG0drc12/U63fqwYDECXDm76lOrb+vFO6di05xzghl0DhN8= X-Received: by 2002:a05:620a:258e:b0:8ee:3715:2127 with SMTP id af79cd13be357-904d63e7a0amr1428892785a.38.1778184760010; Thu, 07 May 2026 13:12:40 -0700 (PDT) Received: from devvm29614.prn0.facebook.com ([2a03:2880:f800:31::]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8fc2c91cd89sm2059382385a.35.2026.05.07.13.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 13:12:39 -0700 (PDT) Date: Thu, 7 May 2026 13:12:35 -0700 From: Bobby Eshleman To: Stefano Garzarella Cc: Paolo Abeni , Arseniy Krasnov , Bobby Eshleman , stefanha@redhat.com, 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 Subject: Re: [PATCH] vsock/virtio: fix vsockmon info leak in non-linear tap copy Message-ID: References: <20260430071110.380509-1-sunyiqixm@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, May 05, 2026 at 02:44:16PM +0200, Stefano Garzarella wrote: > CCing Arseniy and Bobby. > > On Tue, May 05, 2026 at 12:26:21PM +0200, Paolo Abeni wrote: > > 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. > > Yep, I just checked and vhost-vsock is the only place where we call > virtio_transport_deliver_tap_pkt() wiht an offset != 0, but I agree that we > should also fix it. > > Looking better in net/vmw_vsock/virtio_transport_common.c I think this is a > regression, indeed we have this comment in virtio_transport_build_skb(): > > /* A packet could be split to fit the RX buffer, so we can retrieve > * the payload length from the header and the buffer pointer taking > * care of the offset in the original packet. > */ > pkt_hdr = virtio_vsock_hdr(pkt); > > Before commit 71dc9ec9ac7d ("virtio/vsock: replace virtio_vsock_pkt with > sk_buff") we read the payload lenght from the header that is always set to > the right value before delivering the packet to the tap. > > From that commit, we don't to consider the offset anymore since we started > to use `len` from the skb, so IMO we should go back to what we did before > it, I mean: > > payload_len = le32_to_cpu(pkt->hdr.len); > > @Bobby do you remember why we did that change? Or if you see any issue going > back to what we did initially? I think this was just one that made it through the cracks. I vaguely recall a few other instances where I assumed skb->len could stand-in for hdr.len, but it didn't hold. Using hdr.len like the original looks correct to me. Best, Bobby