netfilter: xt_policy: fix strict mode inbound policy matching
Subsystems (2)
PATCH 1/1 netfilter: xt_policy: fix strict mode inbound policy matching
In reply to a message not in the archiveFrom: Jiexun Wang <[email protected]>
match_policy_in() walks sec_path entries from the last transform to the first one, but strict policy matching needs to consume info->pol[] in the same forward order as the rule layout.
Derive the strict-match policy position from the number of transforms already consumed so that multi-element inbound rules are matched consistently.
--- net/netfilter/xt_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_policy.c +1 -1
@@ -63,7 +63,7 @@ match_policy_in(const struct sk_buff *skb, const struct xt_policy_info *info,return 0 ;for (i = sp->len -1 ; i >=0 ; i--) { - pos = strict ? i - sp->len +1 :0 ; + pos = strict ? sp->len - i -1 :0 ;if (pos >= info->len)return 0 ; e = &info->pol[pos];
Signature · 1 line
2.34.1
Quoted 9 lines · Ren Wei
From: Jiexun Wang <[email protected]>
match_policy_in()walkssec_pathentries from the last transform to the first one, but strict policy matching needs to consume info->pol[] in the same forward order as the rule layout.Derive the strict-match policy position from the number of transforms already consumed so that multi-element inbound rules are matched consistently.
That hints that secpaths with len > 1 do not exist, or at least have never been used. This has always been broken.
For the patch