netfilter: bitwise: fix reduce comparison
Subsystems (2)
PATCH 1/1 netfilter: bitwise: fix reduce comparison
The nft_bitwise_reduce function should compare the bitwise operation in expr with the tracked operation associated with the destination register of expr. However, instead being called on expr and track->regs[priv->dreg].selector, nft_expr_priv is called on expr twice, so nft_bitwise_reduce returns true even when the operations differ.
--- net/netfilter/nft_bitwise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_bitwise.c +1 -1
@@ -287,7 +287,7 @@ static bool nft_bitwise_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops == expr->ops &&
Signature · 1 line
2.35.1
PATCH v2 1/1 netfilter: bitwise: fix reduce comparisons
The nft_bitwise_reduce and nft_bitwise_fast_reduce functions should compare the bitwise operation in expr with the tracked operation associated with the destination register of expr. However, instead of being called on expr and track->regs[priv->dreg].selector, nft_expr_priv is called on expr twice, so both reduce functions return true even when the operations differ.
---
Since v1:
* fix nft_bitwise_fast_reduce as well as nft_bitwise_reduce.
net/netfilter/nft_bitwise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nft_bitwise.c +2 -2
@@ -287,7 +287,7 @@ static bool nft_bitwise_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops == expr->ops &&
@@ -434,7 +434,7 @@ static bool nft_bitwise_fast_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops == expr->ops &&
Signature · 1 line
2.35.1
Pablo Neira Ayuso
maintainerRe: [nf PATCH v2] netfilter: bitwise: fix reduce comparisons
Quoted 6 lines · Jeremy Sowden
The
nft_bitwise_reduceandnft_bitwise_fast_reducefunctions should compare the bitwise operation inexprwith the tracked operation associated with the destination register ofexpr. However, instead of being called onexprandtrack->regs[priv->dreg].selector,nft_expr_privis called onexprtwice, so both reduce functions return true even when the operations differ.
Good catch, applied thanks