netfilter: ebtables: CONFIG_COMPAT: reject trailing data after last rule
authorFlorian Westphal <fw@strlen.de>
Sun, 5 May 2019 16:47:33 +0000 (18:47 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 9 May 2019 06:54:49 +0000 (08:54 +0200)
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 <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/bridge/netfilter/ebtables.c

index 3cad01ac64e4a2a5ebcafa394d04cc4415c7ddab..3a1b94b5c0e529610380e2c8711fd5c83542007d 100644 (file)
@@ -2158,7 +2158,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;
 }