If a pcap file given to the pcap PMD had a super jumbo frame
there would be a silent truncation and also the driver was not
checking for excessive number of mbuf segments.

Bugzilla ID: 2129
Fixes: 6db141c91e1f ("pcap: support jumbo frames")
Cc: [email protected]

Reported-by: Anthropic OSS scanner (ANT-2026-VD4V3KPV)
Signed-off-by: Stephen Hemminger <[email protected]>
---
 drivers/net/pcap/pcap_ethdev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index b89f4a0c2e..fb18f0932b 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -226,7 +226,7 @@ queue_missed_stat_get(struct rte_eth_dev *dev, unsigned int 
qid)
 
 static int
 eth_pcap_rx_jumbo(struct rte_mempool *mb_pool, struct rte_mbuf *mbuf,
-               const u_char *data, uint16_t data_len)
+               const u_char *data, uint32_t data_len)
 {
        /* Copy the first segment. */
        uint16_t len = rte_pktmbuf_tailroom(mbuf);
@@ -237,9 +237,12 @@ eth_pcap_rx_jumbo(struct rte_mempool *mb_pool, struct 
rte_mbuf *mbuf,
        data += len;
 
        while (data_len > 0) {
+               /* Avoid excessively long chain */
+               if (mbuf->nb_segs + 1 > RTE_MBUF_MAX_NB_SEGS)
+                       return -1;
+
                /* Allocate next mbuf and point to that. */
                m->next = rte_pktmbuf_alloc(mb_pool);
-
                if (unlikely(!m->next))
                        return -1;
 
-- 
2.53.0

Reply via email to