diff options
author | Eric Dumazet <edumazet@google.com> | 2019-03-01 14:33:11 -0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-03-02 00:31:36 +0100 |
commit | 4b9113045b1745ec8512d6743680809edca6a74e (patch) | |
tree | 706174eff0c53e6717b2409c1767b43737f61faf | |
parent | 3860d38f28568803887f2566a4cfb71aba90feef (diff) |
bpf: fix u64_stats_init() usage in bpf_prog_alloc()
We need to iterate through all possible cpus.
Fixes: 492ecee892c2 ("bpf: enable program stats")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r-- | kernel/bpf/core.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 1c14c347f3cf..3f08c257858e 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -109,6 +109,7 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags) { gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO | gfp_extra_flags; struct bpf_prog *prog; + int cpu; prog = bpf_prog_alloc_no_stats(size, gfp_extra_flags); if (!prog) @@ -121,7 +122,12 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags) return NULL; } - u64_stats_init(&prog->aux->stats->syncp); + for_each_possible_cpu(cpu) { + struct bpf_prog_stats *pstats; + + pstats = per_cpu_ptr(prog->aux->stats, cpu); + u64_stats_init(&pstats->syncp); + } return prog; } EXPORT_SYMBOL_GPL(bpf_prog_alloc); |