netfilter: x_tables: don't move to non-existent next rule 13/154913/1
authorFlorian Westphal <fw@strlen.de>
Fri, 15 Jul 2016 19:08:15 +0000 (15:08 -0400)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 11 Oct 2017 11:16:03 +0000 (20:16 +0900)
commit83156abb73014d3e857ea7e2defb00c361d34355
treec0241238ee7ff6609be00b06f2bc4d44bf5fa135
parent80d19aafa9b53c1627f2c6532e1719746214620b
netfilter: x_tables: don't move to non-existent next rule

commit f24e230d257af1ad7476c6e81a8dc3127a74204e upstream.

Ben Hawkes says:

 In the mark_source_chains function (net/ipv4/netfilter/ip_tables.c) it
 is possible for a user-supplied ipt_entry structure to have a large
 next_offset field. This field is not bounds checked prior to writing a
 counter value at the supplied offset.

Base chains enforce absolute verdict.

User defined chains are supposed to end with an unconditional return,
xtables userspace adds them automatically.

But if such return is missing we will move to non-existent next rule.

CVE-2016-3134

Reported-by: Ben Hawkes <hawkes@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Chas Williams <3chas3@gmail.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
[sw0312.kim: cherry-pick from linux-3.10.y to fix CVE-2016-3134]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I7761470b085f73e78ce7aa0c02f5c377a100b6a4
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c