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 902FC3C3C16 for ; Fri, 8 May 2026 15:58:51 +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=1778255939; cv=none; b=WdIzr3NhZTHCzj8ZiqIwBPxFX0o+WB2pvWFonyBXEDO6wmr/nq6xkEL/pyDJ+24ibgzJy7FyJ/hTeZJtYhCeuGVQeZgSszLhWqleT298c0sTRLZsE4h4FqQ1+q6MSlWL2auVa++r4R5sn/YA7js2aPxC3K+4Z4Nm366OnR9E+Rg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778255939; c=relaxed/simple; bh=4F7maXO0a9FkT9euxBuc8PxcpOM2bW3TZJpMRTTqC3w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Tk1Ecnu8guuxLdYyJGBWMeJlxq3chho3r/1eE5SyHLLS+YlBG5x8Dh1+JAqI09fY47MZbHOxJi+LKl83EhiaRgYV/nAo5adAWtH8QL2W0HIraKL7DuDkKgs9JBsX8oaI2C51V92mDw3rG1Kj7NjgjDUX/FCkJcMMmlGfTwJJp08= 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=KeIdlJhA; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=cWfezEw0; 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="KeIdlJhA"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="cWfezEw0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778255928; 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: in-reply-to:in-reply-to:references:references; bh=Gt9PkZ1udEZB7A5kTfc6cLitnqLtrOlHUOEwVlvJ/vE=; b=KeIdlJhAkmmL2OxiDOH+QrQbWfFLELhnVyhaVV4TM/ULJM/ePH6WfaFNKwUze8jZvrKcVU kg7vvHZYFn7Ir6omoK1Ez6+SodVXhKyKA7AXj0cadvmOG/Hfr5GqrnvLp31mxl3S6J88AM vH1uZwtGOj3GHgHTl/6e8paBqr7Cqvg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-mIl1bLR8NNuShr9gbfXuLg-1; Fri, 08 May 2026 11:58:47 -0400 X-MC-Unique: mIl1bLR8NNuShr9gbfXuLg-1 X-Mimecast-MFC-AGG-ID: mIl1bLR8NNuShr9gbfXuLg_1778255927 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-447f2ce5556so1271464f8f.2 for ; Fri, 08 May 2026 08:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778255926; x=1778860726; 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=Gt9PkZ1udEZB7A5kTfc6cLitnqLtrOlHUOEwVlvJ/vE=; b=cWfezEw0FCvu+CqDWzSBR2snnV9vd5blKlgtKebCOl5J8NJ/L9CWTG7A4n8zkj287B lGas1OdPtyjXgm2mFzfTcT9HVonoxyGx7Vr/3POpFcdTh9PLL7+w5GtcUEpV1lRp72YJ D27HP98xD3BvdyjTCbs48VE/PIqh/YEvPjYvvLgv3d/RkV3Kuf2DAbeIYGcZP2ULJBtN tRY2Qm+vdCLaFeeBFsIWz75Clf2Sk+Dy/YwGe15BPbtdzSNHtECDkkrJUtQQt5KGmCbN G5C+42PmzKb1kp06zNG423a6kXtP3sjJI13imUWzi5FbAD41JzpG2emXMiB+TBerpbPR iz2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778255926; x=1778860726; 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=Gt9PkZ1udEZB7A5kTfc6cLitnqLtrOlHUOEwVlvJ/vE=; b=TprLBk+TW63u9x390BkkOiBdUbNi9hF2Aze6QbjrDjkg2oCirEZCS24LwPZ8h7L+sV vvqfeQK/ad7XySGDQrTsXLnRpU39kX9PvNcb/qT76k5yDaPn70PwEjZ7PU5n1Xsdoldy Wog5uHK0Dev1Ape9XYx3tJC95VNut58hYwXTVPe6miUwHirdv5i0GFslDbb/RheqfvSi bS/5whR0OPD6PhnkVQJS6yJRON0VJgAGFhZHkJugmJI8siNDmD1TA2F8pqeG3wTD6WIh 84Qc7RGd27JGkWart8BGuemR8sAqr3bicxm4nirXYsvzkzY/6if1dffZhAyJm6BzevIs 3+hA== X-Forwarded-Encrypted: i=1; AFNElJ8bwgtMoVlBntwsa5k8egOLj5R+/B3BP8efCTZ1wM2mNN+C1DArKTqXSo7+rHuhi7oOXuI=@vger.kernel.org X-Gm-Message-State: AOJu0YyTQ42tm4S1oXcbEkjiY3IeVaWkcujG1s7nN4p//JPrifNDE6dj biDhPuZN8nTGNj/43hTTwCDA4/Mypt/j62B18yCgM9jQIIF8yyHmdD78P6pTAHvchauDsxd2JTj Tsh/oGaLNNiLC7xFiqLeqai1sw2dN9cWjE9skgjCpMgmeY02UKJdfSg== X-Gm-Gg: Acq92OFtmpvUP2T4icvwVv3uR9urETPTwgfzumGtGsZgXwL9cTxdBbF4HYCt2YduWP9 qvx+q8mIfzbAzHE74s8eZuj4Eg/fW3ATRB9wHdLbm52Rh982hxdTS/RNfH3AZFKRLtP2q5u0r8/ 66p+RlX9E9zN8w2iN2iAkXUEj0/drZRvjiMiiXqQWLpBmwYdQueQlcNws+ec/wj+WNuAUqUoKM3 rPQdyeGHfPXBI1+BMVkd9FafIqQfrTeCmSRCAqVeNPOls8cL7kJfNWPsp6FG/Z2XcbpXr1ESM7H 6ijFbpvBgyZs295Vjwusij60jSP4McOtH+27feFlIzvI0+lGiE0hFK7jt5tgm3Az4JmbAcwXgPH kecBUsJuz1NstTsW2c/0oQLId+pLsSqGPBZRCFznhhadvFVKphmPAR+c2MiHuL5XNojC+AisuJw == X-Received: by 2002:a5d:588b:0:b0:43d:71f4:7ed4 with SMTP id ffacd0b85a97d-4515b525075mr22331117f8f.15.1778255926232; Fri, 08 May 2026 08:58:46 -0700 (PDT) X-Received: by 2002:a5d:588b:0:b0:43d:71f4:7ed4 with SMTP id ffacd0b85a97d-4515b525075mr22331047f8f.15.1778255925539; Fri, 08 May 2026 08:58:45 -0700 (PDT) Received: from sgarzare-redhat (host-87-11-6-2.retail.telecomitalia.it. [87.11.6.2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4548ec6c79fsm5529634f8f.15.2026.05.08.08.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2026 08:58:44 -0700 (PDT) Date: Fri, 8 May 2026 17:58:23 +0200 From: Stefano Garzarella To: Bobby Eshleman 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: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: On Thu, May 07, 2026 at 01:12:35PM -0700, Bobby Eshleman wrote: >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. Thanks for confirming, I'll fix it. Stefano