netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf] netfilter: nf_tables: mark set as dead when deactivating anonymous set
Date: Mon, 4 Mar 2024 19:22:27 +0100	[thread overview]
Message-ID: <20240304182227.GB19146@breakpoint.cc> (raw)
In-Reply-To: <20240304175306.145996-1-pablo@netfilter.org>

Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> While the rhashtable set gc runs asynchronously, a race allows it to
> collect elements from an anonymous set while it is being released from
> the abort path. This also seems possible from the rule error path.
> 
> Mingi Cho originally reported this issue in a different path in 6.1.x
> with a pipapo set with low timeouts which is not possible upstream since
> 7395dfacfff6 ("netfilter: nf_tables: use timestamp to check for set
> element timeout").
> 
> Fix this by setting on the dead flag to signal set gc to skip anonymous
> sets from prepare_error, abort and commit paths.

This seems to contradict what patch is doing, the flag gets toggled for
all set types.

> Cc: stable@vger.kernel.org
> Fixes: 5f68718b34a5 ("netfilter: nf_tables: GC transaction API to avoid race with control plane")
> Reported-by: Mingi Cho <mgcho.minic@gmail.com>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
>  net/netfilter/nf_tables_api.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index ca54d4c23123..26d33ce3b682 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -5513,6 +5513,7 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,
>  			list_del_rcu(&binding->list);
>  
>  		nft_use_dec(&set->use);
> +		set->dead = 1;
>  		break;
>  	case NFT_TRANS_PREPARE:
>  		if (nft_set_is_anonymous(set)) {
> @@ -5534,6 +5535,7 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,
>  	default:
>  		nf_tables_unbind_set(ctx, set, binding,
>  				     phase == NFT_TRANS_COMMIT);
> +		set->dead = 1;

Shouldn't that be restricted to nf_tables_unbind_set() anonymous-set
branch?

  reply	other threads:[~2024-03-04 18:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 17:53 [PATCH nf] netfilter: nf_tables: mark set as dead when deactivating anonymous set Pablo Neira Ayuso
2024-03-04 18:22 ` Florian Westphal [this message]
2024-03-04 18:39   ` Pablo Neira Ayuso

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=20240304182227.GB19146@breakpoint.cc \
    --to=fw@strlen.de \
    --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).