mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 04:04:43 +01:00
inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP
Yizhou Zhao reported that simply having one RAW socket on protocol
IPPROTO_RAW (255) was dangerous.
socket(AF_INET, SOCK_RAW, 255);
A malicious incoming ICMP packet can set the protocol field to 255
and match this socket, leading to FNHE cache changes.
inner = IP(src="192.168.2.1", dst="8.8.8.8", proto=255)/Raw("TEST")
pkt = IP(src="192.168.1.1", dst="192.168.2.1")/ICMP(type=3, code=4, nexthopmtu=576)/inner
"man 7 raw" states:
A protocol of IPPROTO_RAW implies enabled IP_HDRINCL and is able
to send any IP protocol that is specified in the passed header.
Receiving of all IP protocols via IPPROTO_RAW is not possible
using raw sockets.
Make sure we drop these malicious packets.
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Link: https://lore.kernel.org/netdev/20251109134600.292125-1-zhaoyz24@mails.tsinghua.edu.cn/
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260203192509.682208-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
6a65c0cb0f
commit
c89477ad79
2 changed files with 16 additions and 4 deletions
|
|
@ -1031,16 +1031,22 @@ static void icmp_socket_deliver(struct sk_buff *skb, u32 info)
|
|||
/* Checkin full IP header plus 8 bytes of protocol to
|
||||
* avoid additional coding at protocol handlers.
|
||||
*/
|
||||
if (!pskb_may_pull(skb, iph->ihl * 4 + 8)) {
|
||||
__ICMP_INC_STATS(dev_net_rcu(skb->dev), ICMP_MIB_INERRORS);
|
||||
return;
|
||||
}
|
||||
if (!pskb_may_pull(skb, iph->ihl * 4 + 8))
|
||||
goto out;
|
||||
|
||||
/* IPPROTO_RAW sockets are not supposed to receive anything. */
|
||||
if (protocol == IPPROTO_RAW)
|
||||
goto out;
|
||||
|
||||
raw_icmp_error(skb, protocol, info);
|
||||
|
||||
ipprot = rcu_dereference(inet_protos[protocol]);
|
||||
if (ipprot && ipprot->err_handler)
|
||||
ipprot->err_handler(skb, info);
|
||||
return;
|
||||
|
||||
out:
|
||||
__ICMP_INC_STATS(dev_net_rcu(skb->dev), ICMP_MIB_INERRORS);
|
||||
}
|
||||
|
||||
static bool icmp_tag_validation(int proto)
|
||||
|
|
|
|||
|
|
@ -1066,6 +1066,12 @@ enum skb_drop_reason icmpv6_notify(struct sk_buff *skb, u8 type,
|
|||
if (reason != SKB_NOT_DROPPED_YET)
|
||||
goto out;
|
||||
|
||||
if (nexthdr == IPPROTO_RAW) {
|
||||
/* Add a more specific reason later ? */
|
||||
reason = SKB_DROP_REASON_NOT_SPECIFIED;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* BUGGG_FUTURE: we should try to parse exthdrs in this packet.
|
||||
Without this we will not able f.e. to make source routed
|
||||
pmtu discovery.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue