From: Kuniyuki Iwashima <kuniyu@google.com>
To: Alexander Lobakin <aleksander.lobakin@intel.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Madhu Chittim <madhu.chittim@intel.com>,
Phani Burra <phani.r.burra@intel.com>,
Sridhar Samudrala <sridhar.samudrala@intel.com>,
Brian Vazquez <brianvv@google.com>,
David Decotigny <decot@google.com>, Li Li <boolli@google.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
intel-wired-lan@lists.osuosl.org
Subject: [PATCH v1 iwl-net 2/2] idpf: Linearise headers and fix segments calculation in idpf_rx_rsc().
Date: Sat, 5 Dec 2026 21:43:10 +0900 [thread overview]
Message-ID: <20261205124319.2264197-3-kuniyu@google.com> (raw)
In-Reply-To: <20261205124319.2264197-1-kuniyu@google.com>
idpf_rx_rsc() accesses ip_hdr(), ipv6_hdr(), and tcp_hdr() directly
without ensuring the L3 and L4 headers are pulled into the linear data
area, which can fail when idpf_rx_hsplit_wa() only copies ETH_HLEN.
It also computes rsc_segments from skb->data_len instead of the TCP
payload length, omitting bytes in the linear head and miscounting when
TCP options are present.
Let's pull the IP and TCP headers (including TCP options) in
idpf_rx_rsc() and compute rsc_segments from the TCP payload length.
Fixes: 3a8845af66ed ("idpf: add RX splitq napi poll support")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 37 ++++++++++++---------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index c4fc046b041a..555a87f45e32 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -3393,10 +3393,10 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb,
const struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc,
struct libeth_rx_pt decoded)
{
+ u16 l3_start = 0, l4_start;
u16 rsc_segments, rsc_seg_len;
- u16 l3_start = 0;
bool ipv4, ipv6;
- int len;
+ u32 thlen, len;
if (unlikely(libeth_rx_pt_get_ip_ver(decoded) ==
LIBETH_RX_PT_OUTER_L2))
@@ -3412,34 +3412,41 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb,
if (unlikely(!(ipv4 ^ ipv6)))
return -EINVAL;
- rsc_segments = DIV_ROUND_UP(skb->data_len, rsc_seg_len);
-
- NAPI_GRO_CB(skb)->count = rsc_segments;
- skb_shinfo(skb)->gso_size = rsc_seg_len;
-
if (unlikely(eth_type_vlan(skb->protocol)))
l3_start = VLAN_HLEN;
+ l4_start = l3_start + (ipv4 ? sizeof(struct iphdr) :
+ sizeof(struct ipv6hdr));
+ if (unlikely(!pskb_may_pull(skb, l4_start + sizeof(struct tcphdr))))
+ return -EINVAL;
+
skb_set_network_header(skb, l3_start);
+ skb_set_transport_header(skb, l4_start);
+
+ thlen = tcp_hdrlen(skb);
+ if (unlikely(thlen < sizeof(struct tcphdr) ||
+ !pskb_may_pull(skb, l4_start + thlen)))
+ return -EINVAL;
+
+ len = skb->len - l4_start;
+ if (unlikely(len <= thlen))
+ return -EINVAL;
+
+ rsc_segments = DIV_ROUND_UP(len - thlen, rsc_seg_len);
+
+ NAPI_GRO_CB(skb)->count = rsc_segments;
+ skb_shinfo(skb)->gso_size = rsc_seg_len;
if (ipv4) {
struct iphdr *ipv4h = ip_hdr(skb);
skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
-
- /* Reset and set transport header offset in skb */
- skb_set_transport_header(skb, l3_start + sizeof(struct iphdr));
- len = skb->len - skb_transport_offset(skb);
-
- /* Compute the TCP pseudo header checksum*/
tcp_hdr(skb)->check =
~tcp_v4_check(len, ipv4h->saddr, ipv4h->daddr, 0);
} else {
struct ipv6hdr *ipv6h = ipv6_hdr(skb);
skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
- skb_set_transport_header(skb, l3_start + sizeof(struct ipv6hdr));
- len = skb->len - skb_transport_offset(skb);
tcp_hdr(skb)->check =
~tcp_v6_check(len, &ipv6h->saddr, &ipv6h->daddr, 0);
}
--
2.56.1.915.g69d5ec7298-goog
prev parent reply other threads:[~2026-12-05 12:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 12:43 [PATCH v1 iwl-net 0/2] idpf: Fix Rx header split overflow edge cases Kuniyuki Iwashima
2026-12-05 12:43 ` [PATCH v1 iwl-net 1/2] idpf: Avoid double recycle on empty packet in idpf_rx_hsplit_wa() Kuniyuki Iwashima
2026-12-05 13:07 ` sashiko-bot
2026-12-05 12:43 ` Kuniyuki Iwashima [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=20261205124319.2264197-3-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=aleksander.lobakin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=boolli@google.com \
--cc=brianvv@google.com \
--cc=decot@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuni1840@gmail.com \
--cc=madhu.chittim@intel.com \
--cc=phani.r.burra@intel.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sridhar.samudrala@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.