From: Florian Westphal <fw@strlen.de>
To: Artem Savkov <asavkov@redhat.com>
Cc: Florian Westphal <fw@strlen.de>,
Pablo Neira Ayuso <pablo@netfilter.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] ebtables: fix race condition in frame_filter_net_init()
Date: Tue, 26 Sep 2017 14:42:11 +0200 [thread overview]
Message-ID: <20170926124211.GA14971@breakpoint.cc> (raw)
In-Reply-To: <20170926122938.11603-1-asavkov@redhat.com>
Artem Savkov <asavkov@redhat.com> wrote:
> It is possible for ebt_in_hook to be triggered before ebt_table is assigned
> resulting in a NULL-pointer dereference. Make sure hooks are
> registered as the last step.
Right, thanks for the patch.
> --- a/net/bridge/netfilter/ebtable_broute.c
> +++ b/net/bridge/netfilter/ebtable_broute.c
> @@ -65,7 +65,7 @@ static int ebt_broute(struct sk_buff *skb)
>
> static int __net_init broute_net_init(struct net *net)
> {
> - net->xt.broute_table = ebt_register_table(net, &broute_table, NULL);
> + net->xt.broute_table = ebt_register_table(net, &broute_table);
I wonder if it makes more sense to model this like the iptables version,
i.e. pass net->xt.table_name as last arg to ebt_register_table ...
> +int ebt_register_hooks(struct net *net, struct ebt_table *table,
> + const struct nf_hook_ops *ops)
> +{
> + int ret = nf_register_net_hooks(net, ops, hweight32(table->valid_hooks));
> +
> + if (ret)
> + __ebt_unregister_table(net, table);
> +
> + return ret;
> +}
... because this looks strange (unregister of table/not-so-obvious error
unwinding ...)
> @@ -1252,15 +1262,6 @@ ebt_register_table(struct net *net, const struct ebt_table *input_table,
> list_add(&table->list, &net->xt.tables[NFPROTO_BRIDGE]);
> mutex_unlock(&ebt_mutex);
... here one could then assign the net->xt.table_X pointer, and then do
the hook registration right after.
However i have no strong opinion here.
next prev parent reply other threads:[~2017-09-26 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-26 12:29 [PATCH] ebtables: fix race condition in frame_filter_net_init() Artem Savkov
2017-09-26 12:42 ` Florian Westphal [this message]
2017-09-26 14:34 ` Artem Savkov
2017-09-26 15:39 ` [PATCH v2] " Artem Savkov
2017-09-26 16:35 ` [PATCH v3] " Artem Savkov
2017-09-29 11:29 ` Pablo Neira Ayuso
2017-10-05 23:32 ` [ebtables] c70604d6de: BUG:unable_to_handle_kernel kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170926124211.GA14971@breakpoint.cc \
--to=fw@strlen.de \
--cc=asavkov@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).