Skip to contentSkip to conversation

netfilter: ebtables: CONFIG_COMPAT: reject trailing data after last rule

PATCH Applied Florian Westphal 2 participants 2 messages May 5, 2019 – May 9, 2019

Subsystems (3)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: ebtables: CONFIG_COMPAT: reject trailing data after last rule

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")
---
 net/bridge/netfilter/ebtables.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/bridge/netfilter/ebtables.c +3 -1
index 3cad01ac64e4..3a1b94b5c0e5 100644
@@ -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;
 }
 
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Florian Westphal

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,

Applied, thanks Florian.