From: Florian Westphal <fw@strlen.de>
To: Dong Chenchen <dongchenchen2@huawei.com>
Cc: pablo@netfilter.org, kadlec@netfilter.org, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
fw@strlen.de, kuniyu@amazon.com, netfilter-devel@vger.kernel.org,
netdev@vger.kernel.org, yuehaibing@huawei.com
Subject: Re: [PATCH net] net: netfilter: Fix use-after-free in get_info()
Date: Tue, 22 Oct 2024 11:48:39 +0200 [thread overview]
Message-ID: <20241022094839.GA26371@breakpoint.cc> (raw)
In-Reply-To: <20241022085753.2069639-1-dongchenchen2@huawei.com>
Dong Chenchen <dongchenchen2@huawei.com> wrote:
> net/netfilter/x_tables.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> index da5d929c7c85..359c880ecb07 100644
> --- a/net/netfilter/x_tables.c
> +++ b/net/netfilter/x_tables.c
> @@ -1239,6 +1239,7 @@ struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
> struct module *owner = NULL;
> struct xt_template *tmpl;
> struct xt_table *t;
> + int err = -ENOENT;
>
> mutex_lock(&xt[af].mutex);
> list_for_each_entry(t, &xt_net->tables[af], list)
> @@ -1247,8 +1248,6 @@ struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
>
> /* Table doesn't exist in this netns, check larval list */
> list_for_each_entry(tmpl, &xt_templates[af], list) {
> - int err;
> -
> if (strcmp(tmpl->name, name))
> continue;
> if (!try_module_get(tmpl->me))
> @@ -1267,6 +1266,9 @@ struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
> break;
> }
>
> + if (err < 0)
> + goto out;
> +
> /* and once again: */
> list_for_each_entry(t, &xt_net->tables[af], list)
> if (strcmp(t->name, name) == 0)
Proabably also:
- if (strcmp(t->name, name) == 0)
+ if (strcmp(t->name, name) == 0 && owner == t->me)
next prev parent reply other threads:[~2024-10-22 9:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-22 8:57 [PATCH net] net: netfilter: Fix use-after-free in get_info() Dong Chenchen
2024-10-22 9:22 ` Yue Haibing
2024-10-22 9:48 ` Florian Westphal [this message]
2024-10-23 7:03 ` dongchenchen (A)
2024-10-22 15:33 ` Simon Horman
2024-10-23 6:32 ` dongchenchen (A)
2024-10-23 6:52 ` dongchenchen (A)
2024-10-23 17:16 ` Dan Carpenter
2024-10-24 1:57 ` dongchenchen (A)
-- strict thread matches above, loose matches on Subject: below --
2024-10-23 1:28 dongchenchen (A)
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=20241022094839.GA26371@breakpoint.cc \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=dongchenchen2@huawei.com \
--cc=edumazet@google.com \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=yuehaibing@huawei.com \
/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).