[PATCH] NETFILTER: Missed and reordered checks in {arp,ip,ip6}_tables
authorPatrick McHardy <kaber@trash.net>
Tue, 21 Nov 2006 10:34:39 +0000 (11:34 +0100)
committerChris Wright <chrisw@sous-sol.org>
Sat, 2 Dec 2006 00:12:35 +0000 (16:12 -0800)
commitfec748200becfd75894a643fe907fc9795bd07bf
tree01ccc2a424a818b2b1928eb78ae5cba1bd7d7ff6
parent76f0a94ed26ea5c768a57c8456ae4ffcce288c70
[PATCH] NETFILTER: Missed and reordered checks in {arp,ip,ip6}_tables

Backport fix for missing ruleset validation in {arp,ip,ip6}_tables
and a fix on top which fixes a regression in the first patch.

There is a number of issues in parsing user-provided table in
translate_table(). Malicious user with CAP_NET_ADMIN may crash system by
passing special-crafted table to the *_tables.

The first issue is that mark_source_chains() function is called before entry
content checks. In case of standard target, mark_source_chains() function
uses t->verdict field in order to determine new position. But the check, that
this field leads no further, than the table end, is in check_entry(), which
is called later, than mark_source_chains().

The second issue, that there is no check that target_offset points inside
entry. If so, *_ITERATE_MATCH macro will follow further, than the entry
ends. As a result, we'll have oops or memory disclosure.

And the third issue, that there is no check that the target is completely
inside entry. Results are the same, as in previous issue.

Upstream commit 590bdf7fd2292b47c428111cb1360e312eff207e introduced a
regression in match/target hook validation. mark_source_chains builds
a bitmask for each rule representing the hooks it can be reached from,
which is then used by the matches and targets to make sure they are
only called from valid hooks. The patch moved the match/target specific
validation before the mark_source_chains call, at which point the mask
is always zero.

This patch returns back to the old order and moves the standard checks
to mark_source_chains. This allows to get rid of a special case for
standard targets as a nice side-effect.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c