Skip to content

Commit 766a7ad

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: ebtables: reject non-bridge targets
commit 11ff728 upstream. 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: syzbot+2b43f681169a2a0d306a@syzkaller.appspotmail.com Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b5199c6 commit 766a7ad

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎net/bridge/netfilter/ebtables.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,12 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct xt_tgchk_param *par,
398398
watcher = xt_request_find_target(NFPROTO_BRIDGE, w->u.name, 0);
399399
if (IS_ERR(watcher))
400400
return PTR_ERR(watcher);
401+
402+
if (watcher->family != NFPROTO_BRIDGE) {
403+
module_put(watcher->me);
404+
return -ENOENT;
405+
}
406+
401407
w->u.watcher = watcher;
402408

403409
par->target = watcher;
@@ -719,6 +725,13 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
719725
goto cleanup_watchers;
720726
}
721727

728+
/* Reject UNSPEC, xtables verdicts/return values are incompatible */
729+
if (target->family != NFPROTO_BRIDGE) {
730+
module_put(target->me);
731+
ret = -ENOENT;
732+
goto cleanup_watchers;
733+
}
734+
722735
t->u.target = target;
723736
if (t->u.target == &ebt_standard_target) {
724737
if (gap < sizeof(struct ebt_standard_target)) {

0 commit comments

Comments
 (0)