netfilter: netfilter fixes
Subsystems (3)
cover netfilter: netfilter fixes
Hi Dave,
The following two patches fix some netfilter bugs:
- missing parentheses in NF_HOOK_COND, breaking error propagation for dropped packets. From Eric Paris.
- incorrect checking for overlapping fragments in IPv6 conntrack reassembly. From Shan Wei
Please apply or pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git
Thanks!
PATCH 1/2 netfilter: NF_HOOK_COND has wrong conditional
From: Eric Paris <[email protected]>
The NF_HOOK_COND returns 0 when it shouldn't due to what I believe to be an error in the code as the order of operations is not what was intended. C will evalutate == before =. Which means ret is getting set to the bool result, rather than the return value of the function call. The code says
if (ret = function() == 1)
when it meant to say:
if ((ret = function()) == 1)
Normally the compiler would warn, but it doesn't notice it because its a actually complex conditional and so the wrong code is wrapped in an explict set of () [exactly what the compiler wants you to do if this was intentional]. Fixing this means that errors when netfilter denies a packet get propagated back up the stack rather than lost.
Problem introduced by commit 2249065f (netfilter: get rid of the grossness in netfilter.h).
--- include/linux/netfilter.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/netfilter.h +1 -1
@@ -215,7 +215,7 @@ NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sk_buff *skb,int ret;if (!cond || - (ret =nf_hook_thresh (pf, hook, skb, in, out, okfn,INT_MIN ) ==1 )) + ((ret =nf_hook_thresh (pf, hook, skb, in, out, okfn,INT_MIN )) ==1 )) ret =okfn (skb);return ret; }
Signature · 1 line
1.7.3.2
PATCH 2/2 netfilter: ipv6: fix overlap check for fragments
In reply to [email protected]From: Shan Wei <[email protected]>
The type of FRAG6_CB(prev)->offset is int, skb->len is *unsigned* int, and offset is int.
Without this patch, type conversion occurred to this expression, when (FRAG6_CB(prev)->offset + prev->len) is less than offset.
--- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv6/netfilter/nf_conntrack_reasm.c +1 -1
@@ -286,7 +286,7 @@ found:/* Check for overlap with preceding fragment. */ if (prev && - (NFCT_FRAG6_CB (prev)->offset + prev->len) - offset >0 ) + (NFCT_FRAG6_CB (prev)->offset + prev->len) > offset) goto discard_fq;/* Look for overlap with succeeding segment. */
Signature · 1 line
1.7.3.2
David Miller
maintainerFrom: [email protected]
Date: Fri, 12 Nov 2010 16:19:30 +0100
Quoted 7 lines
Hi Dave,
The following two patches fix some netfilter bugs:
- missing parentheses in
NF_HOOK_COND, breaking error propagation for dropped packets. From Eric Paris.
Quoted 6 lines
- incorrect checking for overlapping fragments in IPv6 conntrack reassembly. From Shan Wei
Please apply or pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git
Pulled, thanks Patrick.