]> git.droids-corp.org - dpdk.git/commitdiff
examples/l3fwd: fix buffer overflow in Tx
authorRahul Bhansali <rbhansali@marvell.com>
Tue, 11 Jan 2022 12:50:05 +0000 (18:20 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 15 Mar 2022 00:14:56 +0000 (01:14 +0100)
This patch fixes the stack buffer overflow error reported
from AddressSanitizer.
Function send_packetsx4() tries to access out of bound data
from rte_mbuf and fill it into TX buffer even in the case
where no pending packets (len = 0).
Performance impact:- No

ASAN error report:-
==819==ERROR: AddressSanitizer: stack-buffer-overflow on address
0xffffe2c0dcf0 at pc 0x0000005e791c bp 0xffffe2c0d7e0 sp 0xffffe2c0d800
READ of size 8 at 0xffffe2c0dcf0 thread T0
 #0 0x5e7918 in send_packetsx4 ../examples/l3fwd/l3fwd_common.h:251
 #1 0x5e7918 in send_packets_multi ../examples/l3fwd/l3fwd_neon.h:226

Fixes: 96ff445371e0 ("examples/l3fwd: reorganise and optimize LPM code path")
Cc: stable@dpdk.org
Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
examples/l3fwd/l3fwd_common.h

index cbaab79f5bf8f0bb2a7dc2c3e7e7b0981657dcf4..8e4c27218fef87d6154cd6538f686ab6bc18b0f8 100644 (file)
@@ -236,6 +236,9 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, struct rte_mbuf *m[],
 
                /* copy rest of the packets into the TX buffer. */
                len = num - n;
+               if (len == 0)
+                       goto exit;
+
                j = 0;
                switch (len % FWDSTEP) {
                while (j < len) {
@@ -258,6 +261,7 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, struct rte_mbuf *m[],
                }
        }
 
+exit:
        qconf->tx_mbufs[port].len = len;
 }