* [PATCH 1/2] netfilter: NF_HOOK_COND has wrong conditional
2010-11-12 15:19 [PATCH 0/2] netfilter: netfilter fixes kaber
@ 2010-11-12 15:19 ` kaber
2010-11-12 15:19 ` [PATCH 2/2] netfilter: ipv6: fix overlap check for fragments kaber
2010-11-12 19:07 ` [PATCH 0/2] netfilter: netfilter fixes David Miller
2 siblings, 0 replies; 4+ messages in thread
From: kaber @ 2010-11-12 15:19 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, netdev, Eric Paris, stable, Patrick McHardy
From: Eric Paris <eparis@redhat.com>
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).
Signed-off-by: Eric Paris <eparis@redhat.com>
Cc: stable@kernel.org
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
include/linux/netfilter.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 89341c3..03317c8 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -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;
}
--
1.7.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] netfilter: ipv6: fix overlap check for fragments
2010-11-12 15:19 [PATCH 0/2] netfilter: netfilter fixes kaber
2010-11-12 15:19 ` [PATCH 1/2] netfilter: NF_HOOK_COND has wrong conditional kaber
@ 2010-11-12 15:19 ` kaber
2010-11-12 19:07 ` [PATCH 0/2] netfilter: netfilter fixes David Miller
2 siblings, 0 replies; 4+ messages in thread
From: kaber @ 2010-11-12 15:19 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, netdev, Shan Wei, Patrick McHardy
From: Shan Wei <shanwei@cn.fujitsu.com>
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.
Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 3a3f129..79d43aa 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -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. */
--
1.7.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread