netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets
authorFlorian Westphal <fw@strlen.de>
Mon, 19 Feb 2018 00:24:15 +0000 (01:24 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 31 May 2018 23:30:00 +0000 (00:30 +0100)
commitdccc6e2c9b486b99b6ec356e14f7de58832b3833
treebfb9ab4f92652d9d83861817164ee3fb12ac3b4b
parentdfd9f20a2db71ca01033040ecf69d5c0e67db629
netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets

commit b71812168571fa55e44cdd0254471331b9c4c4c6 upstream.

We need to make sure the offsets are not out of range of the
total size.
Also check that they are in ascending order.

The WARN_ON triggered by syzkaller (it sets panic_on_warn) is
changed to also bail out, no point in continuing parsing.

Briefly tested with simple ruleset of
-A INPUT --limit 1/s' --log
plus jump to custom chains using 32bit ebtables binary.

Reported-by: <syzbot+845a53d13171abf8bf29@syzkaller.appspotmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/bridge/netfilter/ebtables.c