diff options
| author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2024-08-20 09:54:31 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-08-29 17:30:45 +0200 |
| commit | 418e686a23b39dc9c43378a8c77aebef836e6794 (patch) | |
| tree | e3e8f5c753ba6068e774603a715f4044d97ff0c2 /net/netfilter | |
| parent | 75eb4a8c116301d6141b1184a04ed50480c43ae7 (diff) | |
| download | linux-418e686a23b39dc9c43378a8c77aebef836e6794.tar.gz linux-418e686a23b39dc9c43378a8c77aebef836e6794.tar.bz2 linux-418e686a23b39dc9c43378a8c77aebef836e6794.zip | |
netfilter: nft_counter: Synchronize nft_counter_reset() against reader.
[ Upstream commit a0b39e2dc7017ac667b70bdeee5293e410fab2fb ]
nft_counter_reset() resets the counter by subtracting the previously
retrieved value from the counter. This is a write operation on the
counter and as such it requires to be performed with a write sequence of
nft_counter_seq to serialize against its possible reader.
Update the packets/ bytes within write-sequence of nft_counter_seq.
Fixes: d84701ecbcd6a ("netfilter: nft_counter: rework atomic dump and reset")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/netfilter')
| -rw-r--r-- | net/netfilter/nft_counter.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/net/netfilter/nft_counter.c b/net/netfilter/nft_counter.c index 73e4d278d6c1..781d3a26f5df 100644 --- a/net/netfilter/nft_counter.c +++ b/net/netfilter/nft_counter.c @@ -107,11 +107,16 @@ static void nft_counter_reset(struct nft_counter_percpu_priv *priv, struct nft_counter *total) { struct nft_counter *this_cpu; + seqcount_t *myseq; local_bh_disable(); this_cpu = this_cpu_ptr(priv->counter); + myseq = this_cpu_ptr(&nft_counter_seq); + + write_seqcount_begin(myseq); this_cpu->packets -= total->packets; this_cpu->bytes -= total->bytes; + write_seqcount_end(myseq); local_bh_enable(); } |
