Skip to contentSkip to conversation

payload: return early if dependency is not a payload expression

PATCH In review Florian Westphal 2 participants 2 messages Feb 25, 2025 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 payload: return early if dependency is not a payload expression

if (dep->left->payload.base != PROTO_BASE_TRANSPORT_HDR)

is legal only after checking that ->left points to an EXPR_PAYLOAD expression. The dependency store can also contain EXPR_META, in this case we access a bogus part of the union.

The payload_may_dependency_kill_icmp helper can't handle a META dep either, so return early.

---
 src/payload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/payload.c +2 -1
index eadc92efc0d7..866cd9bc2b05 100644
@@ -893,7 +893,8 @@ static bool payload_may_dependency_kill(struct payload_dep_ctx *ctx,
 	if (expr->payload.base != PROTO_BASE_TRANSPORT_HDR)
 		return true;
 
-	if (dep->left->payload.base != PROTO_BASE_TRANSPORT_HDR)
+	if (dep->left->etype != EXPR_PAYLOAD ||
+	    dep->left->payload.base != PROTO_BASE_TRANSPORT_HDR)
 		return true;
 
 	if (dep->left->payload.desc == &proto_icmp)
Signature · 1 line
2.45.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Florian Westphal

if (dep->left->payload.base != PROTO_BASE_TRANSPORT_HDR)

is legal only after checking that ->left points to an EXPR_PAYLOAD expression. The dependency store can also contain EXPR_META, in this case we access a bogus part of the union.

The payload_may_dependency_kill_icmp helper can't handle a META dep either, so return early.

Fixes 533565244d88 ("payload: check icmp dependency before removing previous icmp expression")
Quoted 1 line

Thanks.