netfilter: xtables: fix reentrancy
authorEric Dumazet <eric.dumazet@gmail.com>
Sun, 20 Mar 2011 14:40:06 +0000 (15:40 +0100)
committerBrad Figg <brad.figg@canonical.com>
Wed, 27 Apr 2011 18:41:19 +0000 (11:41 -0700)
commitec6128c5d5173a229fbc69f430d8d631b6fe8b67
tree03c3beb9ec11b072fed978416871f61a5df1987f
parent43bfce26feceddd6f8ce9037732b67e74e105c70
netfilter: xtables: fix reentrancy

BugLink: http://bugs.launchpad.net/bugs/761134

commit db856674ac69e31946e56085239757cca3f7655f upstream.

commit f3c5c1bfd4308 (make ip_tables reentrant) introduced a race in
handling the stackptr restore, at the end of ipt_do_table()

We should do it before the call to xt_info_rdunlock_bh(), or we allow
cpu preemption and another cpu overwrites stackptr of original one.

A second fix is to change the underflow test to check the origptr value
instead of 0 to detect underflow, or else we allow a jump from different
hooks.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c