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.129.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 C6FC024E4B5 for ; Fri, 8 May 2026 16:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778258664; cv=none; b=HX5QkJs6rTWveCmLcACiEHSbJsUzAAo5hQXL+3lFmvb3KWc4VpSaD0KjEXocUszKC7QLKlYRng+raWeOIavp7WInHdN/X2IPPsoOTFCTL7sTMXKQ8uyi6xcr6YhPy35pLx6Kq6vcbHMUXEPl2TiHU3UTEQSCp8c+IzGkcZRNkWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778258664; c=relaxed/simple; bh=GmB8OB8MBui7lDml76JA2BxvhthP+WnYVp2rivY7tPg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tK4ln3NTFybrX++4XNRCzwqu9WRUDkPp9Nfkn8A/C/TDji5QF00GwVzWNqTaQDEB4kntBp3cChtJA1fjhmondpDysBcxDfaHtVx9a3IJJQGWKs8r6vv/HTi6P+voGNoCapG+fPOoFt+8SHNnZOsTXRwzFJwmlaNudhUl0t2s51c= 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=a/qN1xS3; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=hK7ds4ln; arc=none smtp.client-ip=170.10.129.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="a/qN1xS3"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="hK7ds4ln" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778258661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eRysknO3j16TQFAanFHTedpULbyeYuuxZEHDUwxrXrA=; b=a/qN1xS3LEFLt8I4Ut0VGFe/cvJiXVMj2O+8KQW3BXj1iAVRye8Z8KjgfqXsz79XA7jJKw xCcCrZA21Q/8dQR++KShFpnYcLdTe9PP5FbF3g+Dk+w8i/IE4YOPKrCIe1Vz9mEkucvxUc L7uIFwX9tZ9Gz3UufYnMkl9XnZe74P4= 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-227-P_VM3er8NfWj9XbbYcKFVw-1; Fri, 08 May 2026 12:44:20 -0400 X-MC-Unique: P_VM3er8NfWj9XbbYcKFVw-1 X-Mimecast-MFC-AGG-ID: P_VM3er8NfWj9XbbYcKFVw_1778258659 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-43d7730e9e3so1403869f8f.2 for ; Fri, 08 May 2026 09:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778258659; x=1778863459; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eRysknO3j16TQFAanFHTedpULbyeYuuxZEHDUwxrXrA=; b=hK7ds4lnX3OcvmzD2Vkc4iPHJHNCMQ2lktxIgk/GOgqWz5HciWmwyOm+AQc51eWDKe 20lwObNhGzMoYDD1MrIWfaAkEIwksrFsaRq3LAFAJNUXuef0Ph6P7gie5lM+hGrxDtKc z9M8GTicYeVGv2zcy1+Jpc1UGdJXxCSY9axnWEeHqBzVyYete2vccG0o5lsCz45Vuw4U T2JU6fnY92nTARSv4KZ6xuWuS/YJIERJNznC9/gl8TBQCUdKfW0jfsSswWlprNxwiJ5t h6SuJyEkKhA4AyTK4DpmLkGOk0nbtCu/cGmC7q7WadDlYuf5zAmVShvO6RYjWHpphSDb elCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778258659; x=1778863459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eRysknO3j16TQFAanFHTedpULbyeYuuxZEHDUwxrXrA=; b=oysSzFPWcP0p5h5rMk5utiXo7toEbxp8As3VYIaVmVF2BE/Ba7b1/IP8mEfOmuYxUT MBM0zmr2CsOVusx3eDY+G7ZBPnyiPkjidL7gPInoN2UgkJpLicqEj1UyGC6A6AXJhCYl D/TOcpYqWkz5wsTH3d4lljIzfhbrcukgNzdfCHD9NJq1/vNIHNCYDRQSksJp800oUaXJ d38ExoidDFkdwe2LzrHfWW1r38aCs82C9R7q15obOH6maxcOFL1ZG9cnzweaiMyyDcgD uRHOcYZsJwRWgd8GP0ZUoocywNS3eOQO817LAg7KDiqZf5M0VxHoidwT/zJmebYK+m0Z t9AQ== X-Forwarded-Encrypted: i=1; AFNElJ9+/0DU+JbHcHxjotPecBOaD4lhZxWVxyoQ87FZNONtiUcJyRDHzci/418CGTi8E26W+z0Ozk8Z9sn5Jyc=@vger.kernel.org X-Gm-Message-State: AOJu0YyYATQyiaHAwuGOEj0UG+uEDNmxIPLzFL14FzaG3N2Q7qz8Ynm9 ijPrvkDykEzr1LyWFQBQFFGlStO9fMuz+P8oYPdKPn9UwxtWSfgpTaklHFpk4P9WFO/Z41/YRkT v1VR01a/FxeJoEjKXm8c2ij6FcK3ntololU3fkWXmZgdKaixquDCd97ZeCVzcqmKHpA== X-Gm-Gg: Acq92OHs/BeW2CuvamPwqeJWsW51cfGB6Ts1nhxa5b5C4aub3Bq048adBVsdWBdN5e8 6c5UPRMfvNTUPm3nQKcMmQ+oqKKXj60+hDSC0orKn5PERSN0VZ/8WvtMt5B3xjtkgCKTE6m8dxq 26SSLHNQbcuMgTXCtnac+Sp6L7NXdgEQeS5rWvLOYm6Bs1oq7s4O2e+pXFTc56pPeYjLYOQCjTb vKkwd3akVmUWO6zpe7qdkYZXweATeIQTZxCTTfZDLhfvOf3bcJlislxZD1fezV4hzSVd+EDbKuD ImembGG/dVvgOquzr+PuhL6H3N2rtB08O/96ikTDIH4sKamOlAUyl+coXfKGsA+ZloHAimiFNDu BQT19kY3bY2nI+EBQcvdk1u9HElXQ/KxrIp9fzZ9FXJoUQvCv7zIsaVJTp53sePq5pXyl0J5xQ/ n/ X-Received: by 2002:a05:6000:420c:b0:43d:7508:c9c9 with SMTP id ffacd0b85a97d-4515c5752d8mr21832384f8f.27.1778258659234; Fri, 08 May 2026 09:44:19 -0700 (PDT) X-Received: by 2002:a05:6000:420c:b0:43d:7508:c9c9 with SMTP id ffacd0b85a97d-4515c5752d8mr21832302f8f.27.1778258658503; Fri, 08 May 2026 09:44:18 -0700 (PDT) Received: from stex1.redhat.corp (host-87-11-6-2.retail.telecomitalia.it. [87.11.6.2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-454916df968sm5477523f8f.25.2026.05.08.09.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2026 09:44:17 -0700 (PDT) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: Yiqi Sun , Stefano Garzarella , linux-kernel@vger.kernel.org, Xuan Zhuo , "Michael S. Tsirkin" , Stefan Hajnoczi , kvm@vger.kernel.org, Simon Horman , Bobby Eshleman , Jason Wang , Jakub Kicinski , "David S. Miller" , virtualization@lists.linux.dev, Eric Dumazet , Paolo Abeni , Arseniy Krasnov , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Bobby Eshleman Subject: [PATCH net 1/2] vsock/virtio: fix length and offset in tap skb for split packets Date: Fri, 8 May 2026 18:44:10 +0200 Message-ID: <20260508164411.261440-2-sgarzare@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260508164411.261440-1-sgarzare@redhat.com> References: <20260508164411.261440-1-sgarzare@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Stefano Garzarella virtio_transport_build_skb() builds a new skb to be delivered to the vsockmon tap device. To build the new skb, it uses the original skb data length as payload length, but as the comment notes, the original packet stored in the skb may have been split in multiple packets, so we need to use the length in the header, which is correctly updated before the packet is delivered to the tap, and the offset for the data. This was also similar to what we did before commit 71dc9ec9ac7d ("virtio/vsock: replace virtio_vsock_pkt with sk_buff") where we probably missed something during the skb conversion. Also update the comment above, which was left stale by the skb conversion and still mentioned a buffer pointer that no longer exists. Fixes: 71dc9ec9ac7d ("virtio/vsock: replace virtio_vsock_pkt with sk_buff") Signed-off-by: Stefano Garzarella --- net/vmw_vsock/virtio_transport_common.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 9b8014516f4f..a678d5d75704 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -166,12 +166,12 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque) struct sk_buff *skb; size_t payload_len; - /* 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. + /* A packet could be split to fit the RX buffer, so we use + * the payload length from the header, which has been updated + * by the sender to reflect the fragment size. */ pkt_hdr = virtio_vsock_hdr(pkt); - payload_len = pkt->len; + payload_len = le32_to_cpu(pkt_hdr->len); skb = alloc_skb(sizeof(*hdr) + sizeof(*pkt_hdr) + payload_len, GFP_ATOMIC); @@ -219,7 +219,8 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque) virtio_transport_copy_nonlinear_skb(pkt, data, payload_len); } else { - skb_put_data(skb, pkt->data, payload_len); + skb_put_data(skb, pkt->data + VIRTIO_VSOCK_SKB_CB(pkt)->offset, + payload_len); } } -- 2.54.0