* [PATCH] net/sched: act_nat: only rewrite IPv4 packets
@ 2026-06-03 18:04 Samuel Moelius
0 siblings, 0 replies; only message in thread
From: Samuel Moelius @ 2026-06-03 18:04 UTC (permalink / raw)
To: Jamal Hadi Salim
Cc: Samuel Moelius, Jiri Pirko, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, open list:TC subsystem,
open list
act_nat can process packets whose protocol is not IPv4 and then
interpret the payload as an IPv4 header. Non-IPv4 packets may be
modified based on unrelated bytes at the network header offset.
The action is documented as IPv4 NAT and should leave other protocols
alone.
Check the packet protocol before parsing and rewriting the IPv4 header.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
net/sched/act_nat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
index abb332dee836..34d6ba2d4143 100644
--- a/net/sched/act_nat.c
+++ b/net/sched/act_nat.c
@@ -142,6 +142,9 @@ TC_INDIRECT_SCOPE int tcf_nat_act(struct sk_buff *skb,
egress = parms->flags & TCA_NAT_FLAG_EGRESS;
noff = skb_network_offset(skb);
+ if (skb_protocol(skb, true) != htons(ETH_P_IP))
+ goto out;
+
if (!pskb_may_pull(skb, sizeof(*iph) + noff))
goto drop;
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-03 18:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 18:04 [PATCH] net/sched: act_nat: only rewrite IPv4 packets Samuel Moelius
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox