OSDN Git Service

bpf: Disallow bpf_obj_new_impl call when bpf_mem_alloc_init fails
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Sun, 20 Nov 2022 21:26:10 +0000 (02:56 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 20 Nov 2022 23:38:28 +0000 (15:38 -0800)
commite181d3f143f7957a73c8365829249d8084602606
tree0fed469c8031cfc1b2b14489c804b901f204eb0e
parentefc1970d683fa7c53a2bc561d40436bf11a18dc0
bpf: Disallow bpf_obj_new_impl call when bpf_mem_alloc_init fails

In the unlikely event that bpf_global_ma is not correctly initialized,
instead of checking the boolean everytime bpf_obj_new_impl is called,
simply check it while loading the program and return an error if
bpf_global_ma_set is false.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20221120212610.2361700-1-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/helpers.c
kernel/bpf/verifier.c