poweprc64/bpf: bpf arena broken after kmalloc_nolock() change
Hi,
On powerpc, bpf arena support was enabled by:
a2485d06cad3 ("powerpc64/bpf: Implement bpf_addr_space_cast instruction")
and the status of selftests was:
# ./test_progs -t arena #3/1 arena_atomics/add:OK #3/2 arena_atomics/sub:OK #3/3 arena_atomics/and:OK #3/4 arena_atomics/or:OK #3/5 arena_atomics/xor:OK #3/6 arena_atomics/cmpxchg:OK #3/7 arena_atomics/xchg:OK #3/8 arena_atomics/uaf:OK #3/9 arena_atomics/load_acquire:SKIP #3/10 arena_atomics/store_release:SKIP #3 arena_atomics:OK (SKIP: 2/10) #4/1 arena_htab/arena_htab_llvm:OK #4/2 arena_htab/arena_htab_asm:OK #4 arena_htab:OK #5/1 arena_list/arena_list_1:OK #5/2 arena_list/arena_list_1000:OK #5 arena_list:OK #6/1 arena_spin_lock/arena_spin_lock_1:SKIP #6/2 arena_spin_lock/arena_spin_lock_1000:SKIP #6/3 arena_spin_lock/arena_spin_lock_50000:SKIP #6 arena_spin_lock:SKIP #7/1 arena_strsearch/arena_strsearch:OK #7 arena_strsearch:OK #417 stream_arena_fault_address:SKIP tester_init:pass:tester_log_buf 0 nsec process_subtest:pass:obj_open_mem 0 nsec process_subtest:pass:specs_alloc 0 nsec #504/1 verifier_arena/basic_alloc1:OK #504/2 verifier_arena/basic_alloc2:OK #504/3 verifier_arena/basic_alloc3:OK #504/4 verifier_arena/basic_reserve1:OK #504/5 verifier_arena/basic_reserve2:OK #504/6 verifier_arena/reserve_twice:OK run_subtest:pass:obj_open_mem 0 nsec run_subtest:pass:unexpected_load_failure 0 nsec do_prog_test_run:pass:bpf_prog_test_run 0 nsec run_subtest:fail:1299 Unexpected retval: 4 != 0 #504/7 verifier_arena/reserve_invalid_region:FAIL #504/8 verifier_arena/iter_maps1:OK #504/9 verifier_arena/iter_maps2:OK #504/10 verifier_arena/iter_maps3:OK #504 verifier_arena:FAIL #505/1 verifier_arena_large/big_alloc1:OK #505/2 verifier_arena_large/access_reserved:OK #505/3 verifier_arena_large/request_partially_reserved:OK #505/4 verifier_arena_large/free_reserved:OK #505/5 verifier_arena_large/big_alloc2:OK #505 verifier_arena_large:OK
All error logs:
tester_init:pass:tester_log_buf 0 nsec
process_subtest:pass:obj_open_mem 0 nsec
process_subtest:pass:specs_alloc 0 nsec
run_subtest:pass:obj_open_mem 0 nsec
run_subtest:pass:unexpected_load_failure 0 nsec
do_prog_test_run:pass:bpf_prog_test_run 0 nsec
run_subtest:fail:1299 Unexpected retval: 4 != 0
#504/7 verifier_arena/reserve_invalid_region:FAIL
#504 verifier_arena:FAIL
Summary: 7/27 PASSED, 6 SKIPPED, 1 FAILED
After commit f8c67d8550ee("bpf: Use kmalloc_nolock() in range tree") all arena related selftests are failing for powerpc:
All error logs:
test_arena_atomics:pass:arena atomics skeleton open 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_atomics': -ENOMEM test_arena_atomics:fail:arena atomics skeleton load unexpected error: -12 (errno 12)
#3 arena_atomics:FAIL
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_htab': -ENOMEM test_arena_htab_llvm:fail:arena_htab__open_and_load unexpected error: -12
#4/1 arena_htab/arena_htab_llvm:FAIL
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_htab_asm': -ENOMEM test_arena_htab_asm:fail:arena_htab_asm__open_and_load unexpected error: -12
#4/2 arena_htab/arena_htab_asm:FAIL
#4 arena_htab:FAIL
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_list': -ENOMEM test_arena_list_add_del:fail:arena_list__open_and_load unexpected error: -12
#5/1 arena_list/arena_list_1:FAIL
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_list': -ENOMEM test_arena_list_add_del:fail:arena_list__open_and_load unexpected error: -12
#5/2 arena_list/arena_list_1000:FAIL
#5 arena_list:FAIL
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_spin_lock': -ENOMEM test_arena_spin_lock_size:fail:arena_spin_lock__open_and_load unexpected error: -12
#6/1 arena_spin_lock/arena_spin_lock_1:FAIL
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_spin_lock': -ENOMEM test_arena_spin_lock_size:fail:arena_spin_lock__open_and_load unexpected error: -12
#6/2 arena_spin_lock/arena_spin_lock_1000:FAIL
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_spin_lock': -ENOMEM test_arena_spin_lock_size:fail:arena_spin_lock__open_and_load unexpected error: -12
#6/3 arena_spin_lock/arena_spin_lock_50000:FAIL
#6 arena_spin_lock:FAIL
libbpf: map 'arena': failed to create: -ENOMEM
libbpf: failed to load BPF skeleton 'arena_strsearch': -ENOMEM test_arena_str:fail:arena_strsearch__open_and_load unexpected error: -12
#7/1 arena_strsearch/arena_strsearch:FAIL
#7 arena_strsearch:FAIL
tester_init:pass:tester_log_buf 0 nsec process_subtest:pass:obj_open_mem 0 nsec process_subtest:pass:specs_alloc 0 nsec
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#504/1 verifier_arena/basic_alloc1:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#504/2 verifier_arena/basic_alloc2:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#504/3 verifier_arena/basic_alloc3:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#504/4 verifier_arena/basic_reserve1:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#504/5 verifier_arena/basic_reserve2:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#504/6 verifier_arena/reserve_twice:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#504/7 verifier_arena/reserve_invalid_region:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#504/8 verifier_arena/iter_maps1:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:pass:unexpected_load_success 0 nsec
validate_msgs:fail:920 expect_msg
VERIFIER LOG:
=============
=============
EXPECTED SUBSTR: 'expected pointer to STRUCT bpf_map'
#504/9 verifier_arena/iter_maps2:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:pass:unexpected_load_success 0 nsec
validate_msgs:fail:920 expect_msg
VERIFIER LOG:
=============
=============
EXPECTED SUBSTR: 'untrusted_ptr_bpf_map'
#504/10 verifier_arena/iter_maps3:FAIL
#504 verifier_arena:FAIL
tester_init:pass:tester_log_buf 0 nsec process_subtest:pass:obj_open_mem 0 nsec process_subtest:pass:specs_alloc 0 nsec
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#505/1 verifier_arena_large/big_alloc1:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#505/2 verifier_arena_large/access_reserved:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#505/3 verifier_arena_large/request_partially_reserved:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM
=============
=============
#505/4 verifier_arena_large/free_reserved:FAIL
run_subtest:pass:obj_open_mem 0 nsec
libbpf: map 'arena': failed to create: -ENOMEM run_subtest:fail:unexpected_load_failure unexpected error: -12 (errno 12) VERIFIER LOG:
=============
=============
#505/5 verifier_arena_large/big_alloc2:FAIL
#505 verifier_arena_large:FAIL
Summary: 1/0 PASSED, 1 SKIPPED, 7 FAILED
This is because powerpc currently does not support 128-bit cmpxchg and in-turn kmalloc_nolock() but new range tree implementation unconditionally uses kmalloc_nolock().
Can use of kmalloc_nolock() be avoided for now or made conditional on availability of arch support for it? I’m ready to implement a patch aligned with your preferred course of action.
Thanks,
Saket
Quoted 9 lines · Saket Kumar Bhaskar
This is because powerpc currently does not support 128-bit cmpxchg and in-turn
kmalloc_nolock()but new range tree implementation unconditionally useskmalloc_nolock().Can use of
kmalloc_nolock()be avoided for now or made conditional on availability of arch support for it? I’m ready to implement a patch aligned with your preferred course of action.
we're going to use kmalloc_nolock() everywhere and will remove bpf_mem_alloc() completely.
So please implement __CMPXCHG_DOUBLE for ppc if possible or just wait and hope that Vlastimil will change slub to use sheaves unconditionally.
Then __CMPXCHG_DOUBLE won't be necessary, but sheaves-everywhere is not a 100% certainty. Hopefully it will work, but there is risk.