Skip to content

prevent out of bounds read with checksum

Bruce Richardson dpdk-dev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2net: fix underflow for checksum of invalid IPv4 packetslib/librte_net/rte_ip.h+8 -42 replies
2/2net/tap: add buffer overflow checks before checksumdrivers/net/tap/rte_eth_tap.c+14 -02 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchHemant AgrawalFerruh YigitKeith Wiles
1/2A-b A-b A-b
2/2R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/2] prevent out of bounds read with checksum

The functions for checksumming the packet payload don't perform bounds checks, and are used by the TAP driver which does not do any bounds checks on the incoming packet either. This means a packet received with an incorrect IP header can read beyond the end of the mbuf.

In the worst case, where the length is specified as being smaller than the IPv4 header, 32-bit wrap-around on subtraction occurs, meaning that approx 4GB of memory will be read.

To fix this, we can introduce a sanity check into the ipv4 function to ensure that underflow does not occur. Since the checksum function does not take the mbuf length as a parameter, we cannot check for overflow there, so we instead perform the checks in the TAP driver directly.

Ideally, in a future release, all checksum functions should be modified to take a max buffer length parameter to fix this issue globally.

NOTE: It appears that the dpaa driver also uses these functions, but from what I can see there, they are only used on TX, which means that there should be less need for parameter length checking, as the data does not come from an untrusted source. Perhaps maintainers, Hemant and Shreyansh, can confirm?

CC Hemant Agrawal <[email protected]>
CC Shreyansh Jain <[email protected]>

Bruce Richardson (2):
net: fix underflow for checksum of invalid IPv4 packets net/tap: add buffer overflow checks before checksum

 drivers/net/tap/rte_eth_tap.c | 14 ++++++++++++++
 lib/librte_net/rte_ip.h       | 12 ++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
Signature · 1 line
2.19.2