Skip to contentSkip to conversation

netfilter: ebtables: Fix extension lookup with identical name

PATCH Applied Phil Sutter 3 participants 3 messages Apr 11, 2016 – Apr 12, 2016

Subsystems (3)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 netfilter: ebtables: Fix extension lookup with identical name

If a requested extension exists as module and is not loaded, ebt_check_match() might accidentally use an NFPROTO_UNSPEC one with same name and fail.

Reproduced with limit match: Given xt_limit and ebt_limit both built as module, the following would fail:

  modprobe xt_limit
  ebtables -I INPUT --limit 1/s -j ACCEPT

The fix is to make ebt_check_match() distrust a found NFPROTO_UNSPEC extension and retry after requesting an appropriate module.

Cc Florian Westphal <[email protected]>
---
 net/bridge/netfilter/ebtables.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/bridge/netfilter/ebtables.c +5 -1
index 8570bc7744c25..5a61f35412a05 100644
@@ -370,7 +370,11 @@ ebt_check_match(struct ebt_entry_match *m, struct xt_mtchk_param *par,
 	    left - sizeof(struct ebt_entry_match) < m->match_size)
 		return -EINVAL;
 
-	match = xt_request_find_match(NFPROTO_BRIDGE, m->u.name, 0);
+	match = xt_find_match(NFPROTO_BRIDGE, m->u.name, 0);
+	if (IS_ERR(match) || match->family != NFPROTO_BRIDGE) {
+		request_module("ebt_%s", m->u.name);
+		match = xt_find_match(NFPROTO_BRIDGE, m->u.name, 0);
+	}
 	if (IS_ERR(match))
 		return PTR_ERR(match);
 	m->u.match = match;
Signature · 1 line
2.8.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Phil Sutter

If a requested extension exists as module and is not loaded, ebt_check_match() might accidentally use an NFPROTO_UNSPEC one with same name and fail.

Reproduced with limit match: Given xt_limit and ebt_limit both built as module, the following would fail:

Quoted 7 lines
  modprobe xt_limit
  ebtables -I INPUT --limit 1/s -j ACCEPT

The fix is to make ebt_check_match() distrust a found NFPROTO_UNSPEC extension and retry after requesting an appropriate module.

Cc Florian Westphal <[email protected]>

Thanks for handling this.

maintainer Applied
#2 lore raw
In reply to Phil Sutter
Quoted 4 lines · Phil Sutter

If a requested extension exists as module and is not loaded, ebt_check_match() might accidentally use an NFPROTO_UNSPEC one with same name and fail.

Quoted 8 lines

Reproduced with limit match: Given xt_limit and ebt_limit both built as module, the following would fail:

  modprobe xt_limit
  ebtables -I INPUT --limit 1/s -j ACCEPT

The fix is to make ebt_check_match() distrust a found NFPROTO_UNSPEC extension and retry after requesting an appropriate module.

Applied, thanks.