Skip to content

Commit c3b704d

Browse files
edumazetdavem330
authored andcommitted
igmp: limit igmpv3_newpack() packet size to IP_MAX_MTU
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/d273628df80f45428e739274ab9ecb72@AcuMS.aculab.com/ Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: David Laight <David.Laight@ACULAB.COM> Cc: Kyle Zeng <zengyhkyle@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d3287e4 commit c3b704d

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
@@ -353,8 +353,9 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu)
353353
struct flowi4 fl4;
354354
int hlen = LL_RESERVED_SPACE(dev);
355355
int tlen = dev->needed_tailroom;
356-
unsigned int size = mtu;
356+
unsigned int size;
357357

358+
size = min(mtu, IP_MAX_MTU);
358359
while (1) {
359360
skb = alloc_skb(size + hlen + tlen,
360361
GFP_ATOMIC | __GFP_NOWARN);

0 commit comments

Comments
 (0)