igmp: limit igmpv3_newpack() packet size to IP_MAX_MTU
Subsystems (3)
PATCH 1/1 igmp: limit igmpv3_newpack() packet size to IP_MAX_MTU
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.
--- net/ipv4/igmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/igmp.c +2 -1
@@ -353,8 +353,9 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu)struct flowi4 fl4;int hlen =LL_RESERVED_SPACE (dev);int tlen = dev->needed_tailroom; -unsigned int size = mtu; +unsigned int size; + size =min (mtu,IP_MAX_MTU );while (1 ) { skb =alloc_skb (size + hlen + tlen,GFP_ATOMIC | __GFP_NOWARN);
Signature · 1 line
2.42.0.283.g2d96d420d3-goog
Quoted 8 lines · Eric Dumazet
This is a follow up of commit
915d975b2ffa("net: deal with integer overflows inkmalloc_reserve()") based on David Laight feedback.Back in 2010, I failed to realize malicious users could set
dev->mtuto arbitrary values. This mtu has been since limited to0x7fffffffbut regardless of how bigdev->mtuis, it makes no sense forigmpv3_newpack()to allocate more thanIP_MAX_MTUand risk various skb fields overflows.
Quoted 5 lines
Fixes 57e1ab6eaddc ("igmp: refine skb allocations")Signed-off-by Eric Dumazet <[email protected]>Reported-by David Laight <[email protected]>Cc Kyle Zeng <[email protected]>
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Tue, 5 Sep 2023 04:23:38 +0000 you wrote:
This is a follow up of commit
915d975b2ffa("net: deal with integer overflows inkmalloc_reserve()") based on David Laight feedback.Back in 2010, I failed to realize malicious users could set
dev->mtuto arbitrary values. This mtu has been since limited to0x7fffffffbut regardless of how bigdev->mtuis, it makes no sense forigmpv3_newpack()to allocate more thanIP_MAX_MTUand risk various skb fields overflows.[...]
Here is the summary with links:
- [net] igmp: limit igmpv3_newpack() packet size to IP_MAX_MTU
https://git.kernel.org/netdev/net/c/c3b704d4a4a2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html