mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs()
skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is reserved as the "not set" value. skb_set_transport_header() silently truncates an offset that does not fit. ipv6_mc_check_exthdrs() stores the offset returned by ipv6_skip_exthdr(), which depends on the extension headers found in the packet. Should the value be truncated, ipv6_mc_check_icmpv6() and ipv6_mc_check_mld_msg() would then validate and parse the MLD message at the wrong place. Since commit3744b0964d("ipv6: Implement limits on extension header parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers (24576 bytes), so this needs a large skb->data - skb->head on top of it, for instance after several nested decapsulations, each of them possibly pulling its own extension header chain. No reproducer was written, this is hardening. Use skb_set_transport_header_careful() and treat such a packet as broken (-EINVAL). Fixes:9afd85c9e4("net: Export IGMP/MLD message validation code") Cc: [email protected] Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Justin Iurman <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
This commit is contained in:
committed by
Paolo Abeni
parent
050f2adb60
commit
425b1fe50b
@@ -56,7 +56,8 @@ static int ipv6_mc_check_exthdrs(struct sk_buff *skb)
|
||||
if (nexthdr != IPPROTO_ICMPV6)
|
||||
return -ENOMSG;
|
||||
|
||||
skb_set_transport_header(skb, offset);
|
||||
if (!skb_set_transport_header_careful(skb, offset))
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user