From: Florian Westphal Date: Sun, 5 May 2019 16:47:33 +0000 (+0200) Subject: netfilter: ebtables: CONFIG_COMPAT: reject trailing data after last rule X-Git-Tag: v3.16.74~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c140ca37;p=thirdparty%2Fkernel%2Fstable.git netfilter: ebtables: CONFIG_COMPAT: reject trailing data after last rule commit 680f6af5337c98d116e4f127cea7845339dba8da upstream. If userspace provides a rule blob with trailing data after last target, we trigger a splat, then convert ruleset to 64bit format (with trailing data), then pass that to do_replace_finish() which then returns -EINVAL. Erroring out right away avoids the splat plus unneeded translation and error unwind. Fixes: 81e675c227ec ("netfilter: ebtables: add CONFIG_COMPAT support") Reported-by: Tetsuo Handa Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Ben Hutchings --- diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 75929f9bd4e6b..1596736ff268a 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -2139,7 +2139,9 @@ static int compat_copy_entries(unsigned char *data, unsigned int size_user, if (ret < 0) return ret; - WARN_ON(size_remaining); + if (size_remaining) + return -EINVAL; + return state->buf_kern_offset; }