All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next,v1 1/6] netfilter: nf_tables: honor EINTR in ruleset validation from commit/abort path
Date: Thu, 15 May 2025 11:56:57 +0200	[thread overview]
Message-ID: <aCW6abGEveAcF1q3@orbyte.nwl.cc> (raw)
In-Reply-To: <20250514214216.828862-2-pablo@netfilter.org>

On Wed, May 14, 2025 at 11:42:11PM +0200, Pablo Neira Ayuso wrote:
> Do not return EAGAIN to replay the transaction if table validation
> reports EINTR. Abort the transaction and report EINTR error instead.
> 
> Fixes: 169384fbe851 ("netfilter: nf_tables: allow loop termination for pending fatal signal")
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
>  net/netfilter/nf_tables_api.c | 28 ++++++++++++++++++++++------
>  1 file changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index b28f6730e26d..d5de843ee773 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -9885,6 +9885,7 @@ static int nf_tables_validate(struct net *net)
>  {
>  	struct nftables_pernet *nft_net = nft_pernet(net);
>  	struct nft_table *table;
> +	int err;
>  
>  	list_for_each_entry(table, &nft_net->tables, list) {
>  		switch (table->validate_state) {
> @@ -9894,15 +9895,24 @@ static int nf_tables_validate(struct net *net)
>  			nft_validate_state_update(table, NFT_VALIDATE_DO);
>  			fallthrough;
>  		case NFT_VALIDATE_DO:
> -			if (nft_table_validate(net, table) < 0)
> -				return -EAGAIN;
> +			err = nft_table_validate(net, table);
> +			if (err < 0) {
> +				if (err == EINTR)

This should be -EINTR here, I guess.

Cheers, Phil

> +					goto err_eintr;
>  
> +				return -EAGAIN;
> +			}
>  			nft_validate_state_update(table, NFT_VALIDATE_SKIP);
>  			break;
>  		}
>  	}
>  
>  	return 0;
> +err_eintr:
> +	list_for_each_entry(table, &nft_net->tables, list)
> +		nft_validate_state_update(table, NFT_VALIDATE_SKIP);
> +
> +	return -EINTR;
>  }
>  
>  /* a drop policy has to be deferred until all rules have been activated,
> @@ -10710,7 +10720,11 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
>  	}
>  
>  	/* 0. Validate ruleset, otherwise roll back for error reporting. */
> -	if (nf_tables_validate(net) < 0) {
> +	err = nf_tables_validate(net);
> +	if (err < 0) {
> +		if (err == -EINTR)
> +			return -EINTR;
> +
>  		nft_net->validate_state = NFT_VALIDATE_DO;
>  		return -EAGAIN;
>  	}
> @@ -11054,9 +11068,11 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
>  	};
>  	int err = 0;
>  
> -	if (action == NFNL_ABORT_VALIDATE &&
> -	    nf_tables_validate(net) < 0)
> -		err = -EAGAIN;
> +	if (action == NFNL_ABORT_VALIDATE) {
> +		err = nf_tables_validate(net);
> +		if (err < 0 && err != -EINTR)
> +			err = -EAGAIN;
> +	}
>  
>  	list_for_each_entry_safe_reverse(trans, next, &nft_net->commit_list,
>  					 list) {
> -- 
> 2.30.2
> 
> 
> 

  reply	other threads:[~2025-05-15  9:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14 21:42 [PATCH nf-next,v1 0/6] revisiting nf_tables ruleset validation Pablo Neira Ayuso
2025-05-14 21:42 ` [PATCH nf-next,v1 1/6] netfilter: nf_tables: honor EINTR in ruleset validation from commit/abort path Pablo Neira Ayuso
2025-05-15  9:56   ` Phil Sutter [this message]
2025-05-14 21:42 ` [PATCH nf-next,v1 2/6] netfilter: nf_tables: honor validation state in preparation phase Pablo Neira Ayuso
2025-05-14 21:42 ` [PATCH nf-next,v1 3/6] netfilter: nf_tables: add infrastructure for chain validation on updates Pablo Neira Ayuso
2025-05-14 21:42 ` [PATCH nf-next,v1 4/6] netfilter: nf_tables: add new binding infrastructure Pablo Neira Ayuso
2025-05-15 12:32   ` Phil Sutter
2025-05-14 21:42 ` [PATCH nf-next,v1 5/6] netfilter: nf_tables: use " Pablo Neira Ayuso
2025-05-15 12:34   ` Phil Sutter
2025-05-14 21:42 ` [PATCH nf-next,v1 6/6] netfilter: nf_tables: add support for validating incremental ruleset updates Pablo Neira Ayuso
2025-05-15 12:05   ` Phil Sutter
2025-05-15  6:03 ` [PATCH nf-next,v1 0/6] revisiting nf_tables ruleset validation Florian Westphal
2025-05-19 15:10   ` Pablo Neira Ayuso
2025-05-20 10:42     ` Florian Westphal
2025-05-20 11:29       ` 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=aCW6abGEveAcF1q3@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.