]> git.karo-electronics.de Git - karo-tx-linux.git/commit
netfilter: NF_HOOK_COND has wrong conditional
authorEric Paris <eparis@redhat.com>
Fri, 12 Nov 2010 07:26:06 +0000 (08:26 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Dec 2010 21:32:52 +0000 (13:32 -0800)
commitd033ce761865fec8580d394b1c13d60010cebead
treef82c5dc5a32dbf618c962a3b7196a8b352f53ca0
parent259821741e7e4c5f349bd2d91df715e4a5c79f88
netfilter: NF_HOOK_COND has wrong conditional

commit ac5aa2e3332ec04889074afdbd1479424d0227a5 upstream.

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>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/linux/netfilter.h