Skip to content

Commit a0b39e2

Browse files
Sebastian Andrzej Siewiorummakynes
authored andcommitted
netfilter: nft_counter: Synchronize nft_counter_reset() against reader.
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: d84701e ("netfilter: nft_counter: rework atomic dump and reset") Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Reviewed-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 1eacdd7 commit a0b39e2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/netfilter/nft_counter.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,16 @@ static void nft_counter_reset(struct nft_counter_percpu_priv *priv,
107107
struct nft_counter *total)
108108
{
109109
struct nft_counter *this_cpu;
110+
seqcount_t *myseq;
110111

111112
local_bh_disable();
112113
this_cpu = this_cpu_ptr(priv->counter);
114+
myseq = this_cpu_ptr(&nft_counter_seq);
115+
116+
write_seqcount_begin(myseq);
113117
this_cpu->packets -= total->packets;
114118
this_cpu->bytes -= total->bytes;
119+
write_seqcount_end(myseq);
115120
local_bh_enable();
116121
}
117122

0 commit comments

Comments
 (0)