Skip to content

Commit 11ff728

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: ebtables: reject non-bridge targets
the ebtables evaluation loop expects targets to return positive values (jumps), or negative values (absolute verdicts). This is completely different from what xtables does. In xtables, targets are expected to return the standard netfilter verdicts, i.e. NF_DROP, NF_ACCEPT, etc. ebtables will consider these as jumps. Therefore reject any target found due to unspec fallback. v2: also reject watchers. ebtables ignores their return value, so a target that assumes skb ownership (and returns NF_STOLEN) causes use-after-free. The only watchers in the 'ebtables' front-end are log and nflog; both have AF_BRIDGE specific wrappers on kernel side. Reported-by: [email protected] Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 9e8c8da commit 11ff728

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

net/bridge/netfilter/ebtables.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct xt_tgchk_param *par,
396396
watcher = xt_request_find_target(NFPROTO_BRIDGE, w->u.name, 0);
397397
if (IS_ERR(watcher))
398398
return PTR_ERR(watcher);
399+
400+
if (watcher->family != NFPROTO_BRIDGE) {
401+
module_put(watcher->me);
402+
return -ENOENT;
403+
}
404+
399405
w->u.watcher = watcher;
400406

401407
par->target = watcher;
@@ -715,6 +721,13 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
715721
goto cleanup_watchers;
716722
}
717723

724+
/* Reject UNSPEC, xtables verdicts/return values are incompatible */
725+
if (target->family != NFPROTO_BRIDGE) {
726+
module_put(target->me);
727+
ret = -ENOENT;
728+
goto cleanup_watchers;
729+
}
730+
718731
t->u.target = target;
719732
if (t->u.target == &ebt_standard_target) {
720733
if (gap < sizeof(struct ebt_standard_target)) {

0 commit comments

Comments
 (0)