* [PATCH net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP
@ 2026-02-03 19:25 Eric Dumazet
2026-02-03 19:36 ` David Ahern
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-02-03 19:25 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Willem de Bruijn, netdev, eric.dumazet,
Eric Dumazet, Yizhou Zhao, Ido Schimmel, David Ahern
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: 1da177e4c3f4 ("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>
---
Cc: Ido Schimmel <idosch@nvidia.com>
Cc: David Ahern <dsahern@kernel.org>
---
net/ipv4/icmp.c | 14 ++++++++++----
net/ipv6/icmp.c | 6 ++++++
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 4abbec2f47ef58242b686f411109494e40c8d752..4acbbc703e79807ba847a53954952f85dc325499 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -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)
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 9d37e7711bc2b8f12c5c2e24b76378c4f3bf401b..a77f3113ef23b6e42743600e7dab5b2e088cd5dd 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -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.
--
2.53.0.rc2.204.g2597b5adb4-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP
2026-02-03 19:25 [PATCH net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP Eric Dumazet
@ 2026-02-03 19:36 ` David Ahern
2026-02-04 7:18 ` Ido Schimmel
2026-02-05 21:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2026-02-03 19:36 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Willem de Bruijn, netdev, eric.dumazet, Yizhou Zhao,
Ido Schimmel
On 2/3/26 12:25 PM, Eric Dumazet wrote:
> 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: 1da177e4c3f4 ("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>
> ---
> Cc: Ido Schimmel <idosch@nvidia.com>
> Cc: David Ahern <dsahern@kernel.org>
> ---
> net/ipv4/icmp.c | 14 ++++++++++----
> net/ipv6/icmp.c | 6 ++++++
> 2 files changed, 16 insertions(+), 4 deletions(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP
2026-02-03 19:25 [PATCH net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP Eric Dumazet
2026-02-03 19:36 ` David Ahern
@ 2026-02-04 7:18 ` Ido Schimmel
2026-02-05 21:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2026-02-04 7:18 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Willem de Bruijn, netdev, eric.dumazet, Yizhou Zhao, David Ahern
On Tue, Feb 03, 2026 at 07:25:09PM +0000, Eric Dumazet wrote:
> 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: 1da177e4c3f4 ("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: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP
2026-02-03 19:25 [PATCH net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP Eric Dumazet
2026-02-03 19:36 ` David Ahern
2026-02-04 7:18 ` Ido Schimmel
@ 2026-02-05 21:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-05 21:00 UTC (permalink / raw)
To: Eric Dumazet
Cc: davem, kuba, pabeni, horms, willemb, netdev, eric.dumazet,
zhaoyz24, idosch, dsahern
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 3 Feb 2026 19:25:09 +0000 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP
https://git.kernel.org/netdev/net/c/c89477ad7944
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-05 21:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-03 19:25 [PATCH net] inet: RAW sockets using IPPROTO_RAW MUST drop incoming ICMP Eric Dumazet
2026-02-03 19:36 ` David Ahern
2026-02-04 7:18 ` Ido Schimmel
2026-02-05 21:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox