ip_frag: ensure minimum v4 fragmentation length
authorAaron Conole <aconole@redhat.com>
Mon, 20 Apr 2020 19:25:21 +0000 (15:25 -0400)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 25 Apr 2020 13:15:23 +0000 (15:15 +0200)
Do a formal parameter check of mtu length, as well as
checking the the various inputs for validity.  If any
aren't acceptable, we bail.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
lib/librte_ip_frag/rte_ipv4_fragmentation.c

index 9e9f986..e9de335 100644 (file)
@@ -8,6 +8,7 @@
 #include <rte_memcpy.h>
 #include <rte_mempool.h>
 #include <rte_debug.h>
+#include <rte_ether.h>
 
 #include "ip_frag_common.h"
 
@@ -76,6 +77,15 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
        uint16_t fragment_offset, flag_offset, frag_size;
        uint16_t frag_bytes_remaining;
 
+       /*
+        * Formal parameter checking.
+        */
+       if (unlikely(pkt_in == NULL) || unlikely(pkts_out == NULL) ||
+           unlikely(nb_pkts_out == 0) ||
+           unlikely(pool_direct == NULL) || unlikely(pool_indirect == NULL) ||
+           unlikely(mtu_size < RTE_ETHER_MIN_MTU))
+               return -EINVAL;
+
        /*
         * Ensure the IP payload length of all fragments is aligned to a
         * multiple of 8 bytes as per RFC791 section 2.3.