netfilter: Can't fail and free after table replacement
authorThomas Graf <tgraf@suug.ch>
Fri, 4 Apr 2014 15:57:45 +0000 (17:57 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 9 Jun 2014 12:28:55 +0000 (13:28 +0100)
commita3bc0f8ea439762aa62d40a295157410498cbea7
tree3cd028fae93c7776589e5df0d5f971dd40e7c7d3
parent0969d3d5473ffc7d33c717a963d3232d5033ee6b
netfilter: Can't fail and free after table replacement

commit c58dd2dd443c26d856a168db108a0cd11c285bf3 upstream.

All xtables variants suffer from the defect that the copy_to_user()
to copy the counters to user memory may fail after the table has
already been exchanged and thus exposed. Return an error at this
point will result in freeing the already exposed table. Any
subsequent packet processing will result in a kernel panic.

We can't copy the counters before exposing the new tables as we
want provide the counter state after the old table has been
unhooked. Therefore convert this into a silent error.

Cc: Florian Westphal <fw@strlen.de>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/bridge/netfilter/ebtables.c
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c