OSDN Git Service
(root)
/
uclinux-h8
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f941ead
)
bpf: Fixes possible race in update_prog_stats() for 32bit arches
author
Eric Dumazet
<edumazet@google.com>
Tue, 26 Oct 2021 21:41:32 +0000
(14:41 -0700)
committer
Alexei Starovoitov
<ast@kernel.org>
Wed, 27 Oct 2021 18:13:52 +0000
(11:13 -0700)
It seems update_prog_stats() suffers from same issue fixed
in the prior patch:
As it can run while interrupts are enabled, it could
be re-entered and the u64_stats syncp could be mangled.
Fixes:
fec56f5890d9
("bpf: Introduce BPF trampoline")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link:
https://lore.kernel.org/bpf/20211026214133.3114279-3-eric.dumazet@gmail.com
kernel/bpf/trampoline.c
patch
|
blob
|
history
diff --git
a/kernel/bpf/trampoline.c
b/kernel/bpf/trampoline.c
index
39eaaff
..
e5963de
100644
(file)
--- a/
kernel/bpf/trampoline.c
+++ b/
kernel/bpf/trampoline.c
@@
-586,11
+586,13
@@
static void notrace update_prog_stats(struct bpf_prog *prog,
* Hence check that 'start' is valid.
*/
start > NO_START_TIME) {
+ unsigned long flags;
+
stats = this_cpu_ptr(prog->stats);
-
u64_stats_update_begin
(&stats->syncp);
+
flags = u64_stats_update_begin_irqsave
(&stats->syncp);
stats->cnt++;
stats->nsecs += sched_clock() - start;
- u64_stats_update_end
(&stats->syncp
);
+ u64_stats_update_end
_irqrestore(&stats->syncp, flags
);
}
}