net: fix underflow for checksum of invalid IPv4 packets
authorBruce Richardson <bruce.richardson@intel.com>
Mon, 17 Dec 2018 15:50:04 +0000 (15:50 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 21 Dec 2018 15:22:41 +0000 (16:22 +0100)
commit8743d499a59c3d6a7c743861fd3baf06ed5fe763
tree1e684fcf213d13dad440ab0ad3d48bfe54c7105e
parent39e98c21be6cb84becbeeedd20428c32242249f5
net: fix underflow for checksum of invalid IPv4 packets

If we receive a packet with an invalid IP header, where the total packet
length is reported as less than the IP header length, we would end up
getting an underflow in the length subtraction.

This could cause us to checksum e.g. 4GB of data in the case where the
result of the subtraction was -1.

We fix this by having the function return 0 - an invalid sum - when
the length is less than the header length.

Fixes: af75078fece3 ("first public release")
Fixes: 6006818cfb26 ("net: new checksum functions")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
lib/librte_net/rte_ip.h