Re: [PATCH] netfilter: nf_tables: Add __percpu annotation to *stats pointer in nf_tables_updchain()

From: Simon Horman
Date: Thu Aug 08 2024 - 11:29:35 EST


On Tue, Aug 06, 2024 at 12:26:58PM +0200, Uros Bizjak wrote:
> Compiling nf_tables_api.c results in several sparse warnings:
>
> nf_tables_api.c:2740:23: warning: incorrect type in assignment (different address spaces)
> nf_tables_api.c:2752:38: warning: incorrect type in assignment (different address spaces)
> nf_tables_api.c:2798:21: warning: incorrect type in argument 1 (different address spaces)
>
> Add __percpu annotation to *stats pointer to fix these warnings.
>
> Found by GCC's named address space checks.
>
> There were no changes in the resulting object files.
>
> Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> Cc: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
> Cc: Jozsef Kadlecsik <kadlec@xxxxxxxxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
> ---
> net/netfilter/nf_tables_api.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index 481ee78e77bc..805227131f10 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -2642,7 +2642,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
> struct nft_table *table = ctx->table;
> struct nft_chain *chain = ctx->chain;
> struct nft_chain_hook hook = {};
> - struct nft_stats *stats = NULL;
> + struct nft_stats __percpu *stats = NULL;
> struct nft_hook *h, *next;
> struct nf_hook_ops *ops;
> struct nft_trans *trans;

Thanks, I agree that users of this local variable expect it
to be annotated as __percpu.

Reviewed-by: Simon Horman <horms@xxxxxxxxxx>