Skip to content

Commit 3d54e99

Browse files
edumazetgregkh
authored andcommitted
igmp: limit igmpv3_newpack() packet size to IP_MAX_MTU
commit c3b704d upstream. This is a follow up of commit 915d975 ("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. Fixes: 57e1ab6 ("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]>
1 parent ec6ad9d commit 3d54e99

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ipv4/igmp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,9 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu)
355355
struct flowi4 fl4;
356356
int hlen = LL_RESERVED_SPACE(dev);
357357
int tlen = dev->needed_tailroom;
358-
unsigned int size = mtu;
358+
unsigned int size;
359359

360+
size = min(mtu, IP_MAX_MTU);
360361
while (1) {
361362
skb = alloc_skb(size + hlen + tlen,
362363
GFP_ATOMIC | __GFP_NOWARN);

0 commit comments

Comments
 (0)