net: deal with fragment-overlapping-two-holes case
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Mon, 17 Oct 2022 07:52:51 +0000 (09:52 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 28 Nov 2022 18:06:39 +0000 (13:06 -0500)
commit068696863980f86504934bdb1e4d0d6359b76092
tree95d094e506bcf1e1780fadf671968fcfae000dda
parent087648b5df8db0d4786ff86e61e7616ebc181cf4
net: deal with fragment-overlapping-two-holes case

With a suitable sequence of malicious packets, it's currently possible
to get a hole descriptor to contain arbitrary attacker-controlled
contents, and then with one more packet to use that as an arbitrary
write vector.

While one could possibly change the algorithm so we instead loop over
all holes, and in each hole puts as much of the current fragment as
belongs there (taking care to carefully update the hole list as
appropriate), it's not worth the complexity: In real, non-malicious
scenarios, one never gets overlapping fragments, and certainly not
fragments that would be supersets of one another.

So instead opt for this simple protection: Simply don't allow the
eventual memcpy() to write beyond the last_byte of the current hole.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
net/net.c