Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nf_nat: mask out non-verdict bits when checking return value

Same as previous change: we need to mask out the non-verdict bits, as
upcoming patches may embed an errno value in NF_STOLEN verdicts too.

NF_DROP could already do this, but not all called functions do this.

Checks that only test ret vs NF_ACCEPT are fine, the 'errno parts'
are always 0 for those.

Signed-off-by: Florian Westphal <fw@strlen.de>

+3 -2
+3 -2
net/netfilter/nf_nat_proto.c
··· 999 999 nf_nat_ipv6_in(void *priv, struct sk_buff *skb, 1000 1000 const struct nf_hook_state *state) 1001 1001 { 1002 - unsigned int ret; 1002 + unsigned int ret, verdict; 1003 1003 struct in6_addr daddr = ipv6_hdr(skb)->daddr; 1004 1004 1005 1005 ret = nf_nat_ipv6_fn(priv, skb, state); 1006 - if (ret != NF_DROP && ret != NF_STOLEN && 1006 + verdict = ret & NF_VERDICT_MASK; 1007 + if (verdict != NF_DROP && verdict != NF_STOLEN && 1007 1008 ipv6_addr_cmp(&daddr, &ipv6_hdr(skb)->daddr)) 1008 1009 skb_dst_drop(skb); 1009 1010