netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: ebtables: Fix extension lookup with identical name
@ 2016-04-11 23:31 Phil Sutter
  2016-04-11 23:36 ` Florian Westphal
  2016-04-12 23:17 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Phil Sutter @ 2016-04-11 23:31 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Florian Westphal

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 <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 net/bridge/netfilter/ebtables.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 8570bc7744c25..5a61f35412a05 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -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;
-- 
2.8.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: ebtables: Fix extension lookup with identical name
  2016-04-11 23:31 [PATCH] netfilter: ebtables: Fix extension lookup with identical name Phil Sutter
@ 2016-04-11 23:36 ` Florian Westphal
  2016-04-12 23:17 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2016-04-11 23:36 UTC (permalink / raw)
  To: Phil Sutter; +Cc: Pablo Neira Ayuso, netfilter-devel, Florian Westphal

Phil Sutter <phil@nwl.cc> wrote:
> 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 <fw@strlen.de>

Acked-by: Florian Westphal <fw@strlen.de>

Thanks for handling this.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: ebtables: Fix extension lookup with identical name
  2016-04-11 23:31 [PATCH] netfilter: ebtables: Fix extension lookup with identical name Phil Sutter
  2016-04-11 23:36 ` Florian Westphal
@ 2016-04-12 23:17 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-04-12 23:17 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel, Florian Westphal

On Tue, Apr 12, 2016 at 01:31:14AM +0200, Phil Sutter wrote:
> 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.

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-12 23:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-11 23:31 [PATCH] netfilter: ebtables: Fix extension lookup with identical name Phil Sutter
2016-04-11 23:36 ` Florian Westphal
2016-04-12 23:17 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).