igmp: limit igmpv3_newpack() packet size to IP_MAX_MTU

commit c3b704d4a4a265660e665df51b129e8425216ed1 upstream.

This is a follow up of commit 915d975b2ffa ("net: deal with integer
overflows in kmalloc_reserve()") based on David Laight feedback.

Back in 2010, I failed to realize malicious users could set dev->mtu
to arbitrary values. This mtu has been since limited to 0x7fffffff but
regardless of how big dev->mtu is, it makes no sense for igmpv3_newpack()
to allocate more than IP_MAX_MTU and risk various skb fields overflows.

BUG=b/306357801
TEST=presubmit
RELEASE_NOTE=Fixed CVE-2023-42752 in the Linux kernel.

cos-patch: security-moderate
Fixes: 57e1ab6eaddc ("igmp: refine skb allocations")
Link: https://lore.kernel.org/netdev/[email protected]/
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: David Laight <[email protected]>
Cc: Kyle Zeng <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Change-Id: I04ca8641dfe0d61b103a8ef941196ec9c837fb79
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/59734
Reviewed-by: Arnav Kansal <[email protected]>
Tested-by: Cusky Presubmit Bot <[email protected]>
1 file changed