From: Showta Ishizaki <zakinko@snowrabbit.org>
To: "Michael S. Tsirkin" <mst@redhat.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Jason Wang <jasowangio@gmail.com>,
netdev@vger.kernel.org
Cc: "Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"Simon Horman" <horms@kernel.org>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Richard Weinberger" <richard@nod.at>,
"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
"Johannes Berg" <johannes@sipsolutions.net>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Chris Arges" <carges@cloudflare.com>,
"Paulos Yibelo" <habte.yibelo@gmail.com>,
"Björn Töpel" <bjorn@kernel.org>,
virtualization@lists.linux.dev, linux-um@lists.infradead.org,
linux-doc@vger.kernel.org,
"Showta Ishizaki" <zakinko@snowrabbit.org>
Subject: [PATCH RFC net v9 2/6] um: vector: trim skbs before verifying the header
Date: Wed, 02 Dec 2026 13:00:00 +0900 [thread overview]
Message-ID: <20261202.rfcv9.41657.2.zakinko@snowrabbit.org> (raw)
In-Reply-To: <20261202.rfcv9.41657.0.zakinko@snowrabbit.org>
From: "Michael S. Tsirkin" <mst@redhat.com>
The vector receive path over-allocates the skb and only trims it
to the received length after the transport header is verified.
A follow up patch will complete the packet checksum in software within
virtio_net_hdr_to_skb so we need the packet trimmed (otherwise the
checksum would be computed incorrectly over the unreceived tail of the
buffer).
Trim first, so the import sees the packet as it was received.
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Showta Ishizaki <zakinko@snowrabbit.org>
---
arch/um/drivers/vector_kern.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index e902e78c5ff6..828bd61995b8 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -873,6 +873,7 @@ static int vector_legacy_rx(struct vector_private *vp)
if (skb != NULL) {
if (pkt_len > vp->header_size) {
+ pskb_trim(skb, pkt_len - vp->rx_header_size);
if (vp->header_size > 0) {
header_check = vp->verify_header(
vp->header_rxbuffer, skb, vp);
@@ -887,7 +888,6 @@ static int vector_legacy_rx(struct vector_private *vp)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
}
- pskb_trim(skb, pkt_len - vp->rx_header_size);
skb->protocol = eth_type_trans(skb, skb->dev);
vp->dev->stats.rx_bytes += skb->len;
vp->dev->stats.rx_packets++;
@@ -989,6 +989,8 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
for (i = 0; i < packet_count; i++) {
skb = (*skbuff_vector);
if (mmsg_vector->msg_len > vp->header_size) {
+ pskb_trim(skb,
+ mmsg_vector->msg_len - vp->rx_header_size);
if (vp->header_size > 0) {
header_check = vp->verify_header(
mmsg_vector->msg_hdr.msg_iov->iov_base,
@@ -1013,8 +1015,6 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
}
- pskb_trim(skb,
- mmsg_vector->msg_len - vp->rx_header_size);
skb->protocol = eth_type_trans(skb, skb->dev);
/*
* We do not need to lock on updating stats here
--
2.54.0 (Apple Git-157)
prev parent reply other threads:[~2026-12-02 3:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 4:00 [PATCH RFC net v9 0/6] more virtio-net csum hardening Showta Ishizaki
2026-12-02 4:00 ` [PATCH RFC net v9 3/6] virtio_net: parse tunnel csum_start little-endian Showta Ishizaki
2026-12-02 4:00 ` [PATCH RFC net v9 1/6] net: account for ingress-resolved virtio net hdr state Showta Ishizaki
2026-12-02 4:00 ` [PATCH RFC net v9 6/6] net: add a sysctl to opt out of virtio net hdr checksum validation Showta Ishizaki
2026-12-02 4:00 ` [PATCH RFC net v9 5/6] net: virtio: compute the outer checksum of non-GSO tunnel packets Showta Ishizaki
2026-12-02 21:06 ` Chris Arges
2026-12-02 4:00 ` [PATCH RFC net v9 4/6] net: resolve uncommon partial checksums at ingress Showta Ishizaki
2026-12-02 4:00 ` Showta Ishizaki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202.rfcv9.41657.2.zakinko@snowrabbit.org \
--to=zakinko@snowrabbit.org \
--cc=andrew+netdev@lunn.ch \
--cc=anton.ivanov@cambridgegreys.com \
--cc=bjorn@kernel.org \
--cc=carges@cloudflare.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=habte.yibelo@gmail.com \
--cc=horms@kernel.org \
--cc=jasowangio@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=richard@nod.at \
--cc=skhan@linuxfoundation.org \
--cc=virtualization@lists.linux.dev \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox