From 8aa6f1cde040bfbea19cadea55bf90be01284f2c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 17 Mar 2022 16:46:25 +0100 Subject: [PATCH] Revert "Revert "bpf: Fix possible race in inc_misses_counter"" This reverts commit bb592b68989c958d16d25f0be909eb977591fad3. It is no longer needed as we can modify the KABI at this point in time. Signed-off-by: Greg Kroah-Hartman Change-Id: I1467db884a714b1379d31d65e650efccbc17ac5c --- kernel/bpf/trampoline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index 6933a9bfee63..2660fbced9ad 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -541,11 +541,12 @@ static u64 notrace bpf_prog_start_time(void) static void notrace inc_misses_counter(struct bpf_prog *prog) { struct bpf_prog_stats *stats; + unsigned int flags; stats = this_cpu_ptr(prog->stats); - u64_stats_update_begin(&stats->syncp); + flags = u64_stats_update_begin_irqsave(&stats->syncp); u64_stats_inc(&stats->misses); - u64_stats_update_end(&stats->syncp); + u64_stats_update_end_irqrestore(&stats->syncp, flags); } /* The logic is similar to bpf_prog_run(), but with an explicit