From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Veerasenareddy Burru <vburru@marvell.com>,
Sathesh Edara <sedara@marvell.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net 1/2] octeon_ep: fix skb frags overflow in the RX path
Date: Wed, 1 Jul 2026 19:28:24 +0800 [thread overview]
Message-ID: <20260701112825.1653044-2-maoyixie.tju@gmail.com> (raw)
In-Reply-To: <20260701112825.1653044-1-maoyixie.tju@gmail.com>
__octep_oq_process_rx() builds an skb for a multi-buffer packet by adding
one fragment per buffer_size chunk:
data_len = buff_info->len - oq->max_single_buffer_size;
while (data_len) {
...
skb_add_rx_frag(skb, shinfo->nr_frags, buff_info->page, 0,
buff_info->len, buff_info->len);
...
}
buff_info->len comes from the device response header
(be64_to_cpu(resp_hw->length)). Nothing bounds the fragment count against
MAX_SKB_FRAGS. data_len can be close to 65535. buffer_size defaults to
about 3776 on 4K pages, so a full packet yields about 18 fragments. That
is one more than the default MAX_SKB_FRAGS of 17, so skb_add_rx_frag()
writes past shinfo->frags[].
The driver now drops a packet that would need more fragments than the skb
can hold. octep_oq_drop_rx() consumes its descriptors, as on the build_skb
failure path. The same class was fixed in other RX paths, including
commit 5ffcb7b890f6 ("net: atlantic: fix fragment overflow handling in RX
path") and commit f0813bcd2d9d ("net: wwan: t7xx: fix potential skb->frags
overflow in RX path").
Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support")
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
drivers/net/ethernet/marvell/octeon_ep/octep_rx.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c
index e6ebc7e44a00c..4ee911b6c0107 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c
@@ -476,6 +476,12 @@ static int __octep_oq_process_rx(struct octep_device *oct,
skb_put(skb, oq->max_single_buffer_size);
shinfo = skb_shinfo(skb);
data_len = buff_info->len - oq->max_single_buffer_size;
+ if (DIV_ROUND_UP(data_len, oq->buffer_size) > MAX_SKB_FRAGS) {
+ dev_kfree_skb_any(skb);
+ octep_oq_drop_rx(oq, buff_info,
+ &read_idx, &desc_used);
+ continue;
+ }
while (data_len) {
buff_info = (struct octep_rx_buffer *)
&oq->buff_info[read_idx];
--
2.34.1
next prev parent reply other threads:[~2026-07-01 11:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 11:28 [PATCH net 0/2] octeon_ep, octeon_ep_vf: fix skb frags overflow in the RX path Maoyi Xie
2026-07-01 11:28 ` Maoyi Xie [this message]
2026-07-01 13:31 ` [PATCH net 1/2] octeon_ep: " Maciej Fijalkowski
2026-07-01 11:28 ` [PATCH net 2/2] octeon_ep_vf: " Maoyi Xie
2026-07-01 14:17 ` Maciej Fijalkowski
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=20260701112825.1653044-2-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sedara@marvell.com \
--cc=vburru@marvell.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