summaryrefslogtreecommitdiffstats
path: root/kernel/trace/bpf_trace.c
diff options
context:
space:
mode:
authorArthur Fabre <afabre@cloudflare.com>2019-06-15 14:36:27 -0700
committerAlexei Starovoitov <ast@kernel.org>2019-06-15 14:37:56 -0700
commit85749218e3a6a1ab4fb3c698394f40f07b80be5e (patch)
tree61f01d7350ff99d3471130c216242310882a51b0 /kernel/trace/bpf_trace.c
parentfe8d9571dc50232b569242fac7ea6332a654f186 (diff)
downloadlinux-85749218e3a6a1ab4fb3c698394f40f07b80be5e.tar.bz2
bpf: Fix out of bounds memory access in bpf_sk_storage
bpf_sk_storage maps use multiple spin locks to reduce contention. The number of locks to use is determined by the number of possible CPUs. With only 1 possible CPU, bucket_log == 0, and 2^0 = 1 locks are used. When updating elements, the correct lock is determined with hash_ptr(). Calling hash_ptr() with 0 bits is undefined behavior, as it does: x >> (64 - bits) Using the value results in an out of bounds memory access. In my case, this manifested itself as a page fault when raw_spin_lock_bh() is called later, when running the self tests: ./tools/testing/selftests/bpf/test_verifier 773 775 [ 16.366342] BUG: unable to handle page fault for address: ffff8fe7a66f93f8 Force the minimum number of locks to two. Signed-off-by: Arthur Fabre <afabre@cloudflare.com> Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage") Acked-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/trace/bpf_trace.c')
0 files changed, 0 insertions, 0 deletions