From nobody Sat Jun 13 07:49:52 2026 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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Michael S. Tsirkin Reviewed-by: Bobby Eshleman --- 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(voi= d *opaque) struct sk_buff *skb; size_t payload_len; =20 - /* 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 =3D virtio_vsock_hdr(pkt); - payload_len =3D pkt->len; + payload_len =3D le32_to_cpu(pkt_hdr->len); =20 skb =3D 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) =20 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); } } =20 --=20 2.54.0 From nobody Sat Jun 13 07:49:52 2026 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 B275440DFBF for ; Fri, 8 May 2026 16:44:30 +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=1778258672; cv=none; b=FXGFrC7PClWahuFkdpXw8F/XNcSaNW2ZmoYYCHOFgGGqRLa9txepxNpG5+PHtusra8EBSoUpAeoeb719WfrKGtcEBDRI3h9HvAWBgI2mN2ygHj/iD2J681uoqJNI+TuoABx6499Jvc+a3qjqY8jRtCWlte8h/gv4RbG1EFFFDg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778258672; c=relaxed/simple; bh=nI6jWfcws3jDGKtVHmRZ+UhUUSG86pLokLto4S1xK2Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNWdMf+Zz03yy+G+7BQIHr2kpx8VW8B6W5z+HBQQL2DZfNQ2DsxBcLmDnVIeIL6Y3j09lTxR+mjIQCY0mjGWdgHswCUQE0gdT9p8CpYOBJ0njlT8sRKl/7F1K0pdKHomFeERYdEIGzz0McWSuEa90vPUS3XQWvTHorW0AmyCZHE= 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=Lbd3ttdP; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=dDjXC8Xv; 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="Lbd3ttdP"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="dDjXC8Xv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778258669; 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=1SGD4ybYlVxcQvNSSgCT46FZDKdy4y6czHmnn+pucYo=; b=Lbd3ttdPX3Q4gHllhXwvL0HUZaC2EqzoyDRn456GtsS5uEO4K0teCc+zyR3BPM0M+58sv7 82Jnik7YvQ4vp/Bhi9SM72lS7Xi0WVVy4KKjPutK6t25ekhlb7jU6Iyaz77TWVe7FkTVNg WRTriHsGECILlnj4ZdO1BkzlqOl4HR8= 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-315-euZOhAo7NFeH1_yzhEKhCg-1; Fri, 08 May 2026 12:44:28 -0400 X-MC-Unique: euZOhAo7NFeH1_yzhEKhCg-1 X-Mimecast-MFC-AGG-ID: euZOhAo7NFeH1_yzhEKhCg_1778258667 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4497a0e3acaso1961435f8f.0 for ; Fri, 08 May 2026 09:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778258667; x=1778863467; 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=1SGD4ybYlVxcQvNSSgCT46FZDKdy4y6czHmnn+pucYo=; b=dDjXC8XvBEQGULjH6G0MmkOHxxPvLx+3PBfZt2Sk56dvFsJLb8v9GCgEmLK/1JrkCz F56nVsyU9+FZ+L1WcUyZz9VksSZ1itXkXo56DrcBnKNxDQUtTZJzAAo6RJb7f+iaq0Kj bWT9/J852PhyXVkL4jqFYlltcU4fCMGGRb2qfxxm73iOTHhGRNlKTZ2pogFIV7tIUsXB NKZxHh3qxUQar9DCIKPc8HC2k4Gb/69fb8MvNx96FNp5c8J0O5aNramQgtqBko4iaOJG lWJ1LtuB7IXW+jnBfXCZssmZ01NZXn1nVNzRQWN/8x4sf2y1D1sshzwNXno60a/nIMVG c7gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778258667; x=1778863467; 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=1SGD4ybYlVxcQvNSSgCT46FZDKdy4y6czHmnn+pucYo=; b=bKMJP/QT6Qp5CPUiNtJ8uGZjIzmKZxFr7OncbuF0ifLnHw87fmVJKHqFyAyQBPgOSU hexzaW9WKoX/fhw7kOpeAtvkvvh2I1kMIKBHgE7z+kXUp+RHKZVbl5p5OKn8MawdWY3+ oZJG3/sMQzxw584xeyumJEUc1uhUSXBMzPiPQTD38JG/jlsIkXBiUY8jy4dpVCPmt2Re mq3aNe/yLFMRofn7x0pQAwpcUZKLmaTt6iiLNdWRzZf5SC22XfWhtNyJrgUj4XOrYX/C ej3osTS8ROAxrQUubTmEA45Ag59EdRadBDcpz7uwUabhILRWlHUTZWhHSbcWJ4jD6YCe D/xA== X-Forwarded-Encrypted: i=1; AFNElJ/4DbZbNqezSJA0Drq0aS5GLeqeucEBU27zSC4nNeDN6ctmeySyQ6s+ZGzOyWmsLXySR9Vz3cXzdp/XM5E=@vger.kernel.org X-Gm-Message-State: AOJu0YyjQmIX4OSdw/9XWVLfMXHD5xPvs2i1EuEhifjfZxEVz7aJtm5b JXrHuQqwCwoCzJ7PE+Sgu+20zBjxV6oP46Ky71V4HW5IhUr9St/4GpcpWHdgN5NGzPv60lr+wCl wCd82FWxdySapfROSiihc3Zc55cOf0L3jJ/adx+v32gpYh/sYGIrARKIoi4gTCUw1IA== X-Gm-Gg: Acq92OEl5sBQD0962ZKNwshqj3HNwNZVaVNCN3kjQ0e0PQvcD1DnWADjKS/XrBp+ynk YXk56mMGqW6nwc+eRfeA4E8I1sGTdmqSVG7fBF4QrQ/dH4t2XOLitKc7iaDmfe1j004xRBdE0Gx Q4yF81iIGSbQdExYpgnd/xIhigV1haDvbTNCe/gJFfJG9C120nT5laqFi32Rm66OqQUbYjuHAgT GO9c4lTMD2AALGkeyArixC+jWjpDINM1Flg6hRJ8/gTD2gBpracAubEXYnNDL77yH94p/eytb8G FHMhu09baXty3FyClMVfv7gQtrkN0qMqcfKRreBFAOOK8HpqDwZ4ZZb0YoADoO64HoRiFurG8/c Rd+Rak4dQDbZ1UmRpPRuaJN3Qe+t6/3RuZ3adUbWPR+egGBtIb0cCgQEnG+NtFofYVw== X-Received: by 2002:a5d:5d08:0:b0:44e:1984:5f3e with SMTP id ffacd0b85a97d-4515d3dc343mr20223715f8f.31.1778258665036; Fri, 08 May 2026 09:44:25 -0700 (PDT) X-Received: by 2002:a5d:5d08:0:b0:44e:1984:5f3e with SMTP id ffacd0b85a97d-4515d3dc343mr20223444f8f.31.1778258662937; Fri, 08 May 2026 09:44:22 -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-4548e6a5b65sm5572801f8f.8.2026.05.08.09.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2026 09:44:22 -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 2/2] vsock/virtio: fix empty payload in tap skb for non-linear buffers Date: Fri, 8 May 2026 18:44:11 +0200 Message-ID: <20260508164411.261440-3-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella For non-linear skbs, virtio_transport_build_skb() goes through virtio_transport_copy_nonlinear_skb() to copy the original payload in the new skb to be delivered to the vsockmon tap device. This manually initializes an iov_iter but does not set iov_iter.count. Since the iov_iter is zero-initialized, the copy length is zero and no payload is actually copied to the monitor interface, leaving data un-initialized. Fix this by removing the linear vs non-linear split and using skb_copy_datagram_iter() with iov_iter_kvec() for all cases, as vhost-vsock already does. This handles both linear and non-linear skbs, properly initializes the iov_iter, and removes the now unused virtio_transport_copy_nonlinear_skb(). While touching this code, let's also check the return value of skb_copy_datagram_iter(), even though it's unlikely to fail. Fixes: 4b0bf10eb077 ("vsock/virtio: non-linear skb handling for tap") Reported-by: Yiqi Sun Signed-off-by: Stefano Garzarella Acked-by: Michael S. Tsirkin Reviewed-by: Bobby Eshleman --- net/vmw_vsock/virtio_transport_common.c | 40 ++++++++----------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio= _transport_common.c index a678d5d75704..989cc252d3d3 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -136,27 +136,6 @@ static void virtio_transport_init_hdr(struct sk_buff *= skb, hdr->fwd_cnt =3D cpu_to_le32(0); } =20 -static void virtio_transport_copy_nonlinear_skb(const struct sk_buff *skb, - void *dst, - size_t len) -{ - struct iov_iter iov_iter =3D { 0 }; - struct kvec kvec; - size_t to_copy; - - kvec.iov_base =3D dst; - kvec.iov_len =3D len; - - iov_iter.iter_type =3D ITER_KVEC; - iov_iter.kvec =3D &kvec; - iov_iter.nr_segs =3D 1; - - to_copy =3D min_t(size_t, len, skb->len); - - skb_copy_datagram_iter(skb, VIRTIO_VSOCK_SKB_CB(skb)->offset, - &iov_iter, to_copy); -} - /* Packet capture */ static struct sk_buff *virtio_transport_build_skb(void *opaque) { @@ -214,13 +193,18 @@ static struct sk_buff *virtio_transport_build_skb(voi= d *opaque) skb_put_data(skb, pkt_hdr, sizeof(*pkt_hdr)); =20 if (payload_len) { - if (skb_is_nonlinear(pkt)) { - void *data =3D skb_put(skb, payload_len); - - virtio_transport_copy_nonlinear_skb(pkt, data, payload_len); - } else { - skb_put_data(skb, pkt->data + VIRTIO_VSOCK_SKB_CB(pkt)->offset, - payload_len); + struct iov_iter iov_iter; + struct kvec kvec; + void *data =3D skb_put(skb, payload_len); + + kvec.iov_base =3D data; + kvec.iov_len =3D payload_len; + iov_iter_kvec(&iov_iter, ITER_DEST, &kvec, 1, payload_len); + + if (skb_copy_datagram_iter(pkt, VIRTIO_VSOCK_SKB_CB(pkt)->offset, + &iov_iter, payload_len)) { + kfree_skb(skb); + return NULL; } } =20 --=20 2.54.0