diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2020-02-24 17:01:32 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-02-25 03:12:19 +0300 |
commit | 94dacdbd5d2dfa2cffd308f128d78c99f855f5be (patch) | |
tree | 5413c0a6b7298c349c1024711df31692c91d1d8d /tools/perf/scripts/python/export-to-postgresql.py | |
parent | 8eece07c011f88da0ccf4127fca9a4e4faaf58ae (diff) | |
download | linux-94dacdbd5d2dfa2cffd308f128d78c99f855f5be.tar.xz |
bpf: Tighten the requirements for preallocated hash maps
The assumption that only programs attached to perf NMI events can deadlock
on memory allocators is wrong. Assume the following simplified callchain:
kmalloc() from regular non BPF context
cache empty
freelist empty
lock(zone->lock);
tracepoint or kprobe
BPF()
update_elem()
lock(bucket)
kmalloc()
cache empty
freelist empty
lock(zone->lock); <- DEADLOCK
There are other ways which do not involve locking to create wreckage:
kmalloc() from regular non BPF context
local_irq_save();
...
obj = slab_first();
kprobe()
BPF()
update_elem()
lock(bucket)
kmalloc()
local_irq_save();
...
obj = slab_first(); <- Same object as above ...
So preallocation _must_ be enforced for all variants of intrusive
instrumentation.
Unfortunately immediate enforcement would break backwards compatibility, so
for now such programs still are allowed to run, but a one time warning is
emitted in dmesg and the verifier emits a warning in the verifier log as
well so developers are made aware about this and can fix their programs
before the enforcement becomes mandatory.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200224145642.540542802@linutronix.de
Diffstat (limited to 'tools/perf/scripts/python/export-to-postgresql.py')
0 files changed, 0 insertions, 0 deletions