Skip to contentSkip to conversation

net/sched: act_pedit: require matching IPv4 L4 protocol

PATCH Superseded Samuel Moelius 2 participants 2 messages Jun 7 – Jun 9

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/sched: act_pedit: require matching IPv4 L4 protocol

The extended IPv4 L4 header mode in act_pedit can select TCP or UDP header fields without confirming that the IPv4 protocol field matches the selected transport header.

That lets a rule written for TCP or UDP modify unrelated payload bytes in a packet carrying a different protocol.

Verify that the IPv4 header is long enough, that the protocol matches the selected TCP or UDP header, and that the packet is not a non-initial fragment before applying TCP or UDP extended header edits.

Assisted-by Codex:gpt-5.5-cyber-preview

---
Changes in v2
- Add check of iph->frag_off & htons(IP_OFFSET)

 net/sched/act_pedit.c | 4 ++++
 1 file changed, 4 insertions(+)
net/sched/act_pedit.c +4 -0
index bc20f08a2789..2730accbc56a 100644
@@ -17,6 +17,7 @@
 #include <linux/ipv6.h>
 #include <linux/slab.h>
 #include <net/ipv6.h>
+#include <net/ip.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <linux/tc_act/tc_pedit.h>
@@ -341,6 +342,9 @@ static int pedit_l4_skb_offset(struct sk_buff *skb, int *hoffset, const int head
 
 		if (!iph)
 			goto out;
+		if (iph->ihl < 5 || iph->protocol != header_type ||
+		    (iph->frag_off & htons(IP_OFFSET)))
+			goto out;
 		*hoffset = noff + iph->ihl * 4;
 		ret = 0;
 		break;
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 10 lines · On Sun, 7 Jun 2026 19:35:46 +0000 Samuel Moelius wrote:

The extended IPv4 L4 header mode in act_pedit can select TCP or UDP header fields without confirming that the IPv4 protocol field matches the selected transport header.

That lets a rule written for TCP or UDP modify unrelated payload bytes in a packet carrying a different protocol.

Verify that the IPv4 header is long enough, that the protocol matches the selected TCP or UDP header, and that the packet is not a non-initial fragment before applying TCP or UDP extended header edits.

This is a hardening patch?

It doesn't apply to either networking tree cleanly, please rebase on net (if it's a fix) and net-next (if it's hardening) and repost

Signature · 1 line
pw-bot: cr