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 AB01B3537C0 for ; Fri, 8 May 2026 15:58:52 +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=1778255937; cv=none; b=ckOCQXmm8DOLpWEBl6RAvc3Mb5A6IEi20kLTn2HJ+l5NMI60ONKG/JTgVIoaXJWHTdCnHsOCrOD64nWiHv3u4NIc4ksJpFmIj99tFDyjZfVo0V6mDgKV4wL9A4gAPZamVJ+mwBtg6ZaN5xHtQp3Tex9tPQe4wZglw5udo+CHHMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778255937; c=relaxed/simple; bh=4F7maXO0a9FkT9euxBuc8PxcpOM2bW3TZJpMRTTqC3w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mt8UAuvs2o5L6iXmPJE3nHjwMxYO/SKDYfW6Sc8Bo05yNAHMhmZ9gt9kklhkJIRqSvM9JDpj3Ds98pORzm0AePEPDsuMgsoVa68ex7viPgj6D27/lp0AcOKr6H73NOtA/HCVpoqZ5CpY+uAA9GzVtn/qSFXBcIDBabKlZzjgGbM= 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=YzvUgbr7; 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="YzvUgbr7"; 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=1778255929; 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=YzvUgbr7oOL7kNHXFkflXdraEvyM5AwgBrrWC23MfbZXtg3XTqy17DivbbWw5D7q08KJGB hhrFFUudUfAX0Dh/6wmB/3J1O05sIfoUZJPCiSUtKvJkYc+eXuMYdvVkNLfUmYpL+GfAna NwSrB5fzdwDGJ7K85ZA5GMD6IyKyf3g= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-F_SAkHPeM7WOpvWAMapSFg-1; Fri, 08 May 2026 11:58:48 -0400 X-MC-Unique: F_SAkHPeM7WOpvWAMapSFg-1 X-Mimecast-MFC-AGG-ID: F_SAkHPeM7WOpvWAMapSFg_1778255927 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-43d7b7bacddso1321971f8f.0 for ; Fri, 08 May 2026 08:58:48 -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=SzsuCWjvfO+A9Daz+F/tgyAQFZKeXy96Qs8ICPTD6vTe9smN5pO3AQnvO8uu3FtcfP qNP+oIuX04OluJscZpzRxQ368hUedXnkcQGKcfEa81IbKmBcV5U9PFAsBzGgFuh67vij NCYnEEs6IT5GPk5iwedaz+W8oM1NZSI3sL52gMdgSFsU3B5eFxT3xdlmtWqo7rSYwfiq lp+aO8EsfoGzck7WWsiYiq9RjB/5HEAd46A9NXCIxSUd+GiakN0m/bFuZv9AzmXWYL5M Eh/sTvlYAycUq08kUAhfwNx9eWMiYOawc0GfvxgU15MsMA/8X75obS7SJCwz2iZHANn2 nKnA== X-Forwarded-Encrypted: i=1; AFNElJ9p95FNAO3Lyri74NOVqkpdVx1gD2n9JRMVvtgW5kCv4CpmjD8g9mEYGgQxdVdrpIYMFjk0oY1w26Tz+rE=@vger.kernel.org X-Gm-Message-State: AOJu0YyBpg6nH/EGwsu6j5IQQPI2Ea6nj1LKAl1JX/ZEmtqQKFrZ7lj6 Hrt+0N1nvE7kzC0/u2uDJN/ZXcHuczagFzVOURy5XC6oReBjI0wO+dYfKU0umQYKrB1YN+d4Xj7 pN3PjquKoReDAQHcY7j7Wr4lL241lTYHNiQiQ9BCamhNNlGSCNk0tL3tvEYRuz9LdTXEsUyRv4g == X-Gm-Gg: Acq92OFrpbqjVqof6WWxigHXXNF80UQmWYnwm5VgH/X9/Lx20IvS1YQo15EVpwwZdGf cQeX56BIt6cFTC0f0dmD9rI3JjhkMQ5+THWuzCRL+9nCThhI8zWqvqNoICrTBBvFfiZcy9ymJHZ bOLi2uAR/pGgPkUbld1u3FgMg61PY4b+lHzVFcYCARCZ7uC8YGiWBbryWVqeAXu9qlwiu/8qYmP iyDz8cpkKYwQaH8dCOZ3KHALM2tcO/WFPLOcVys3pKFzrOQfEqiv8NYgpeT+qy6qIxqlqYonA2K OXM9P6qQlyXAY4+kZMDUnMxU7jkpOyLDZrR/6l3+MKcpPt0MIy8tPgjeIA0zeq/2kzTxxciO0E0 QS/lNbjZ9uxNIBOfxsxwNVm2kCGeE0+u0XPeniJY1McmkC678Stb7HMil85GGf8/ot4IP+1lfyA == X-Received: by 2002:a5d:588b:0:b0:43d:71f4:7ed4 with SMTP id ffacd0b85a97d-4515b525075mr22331111f8f.15.1778255926224; 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: linux-kernel@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