diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2022-11-21 02:56:10 +0530 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-11-20 15:38:28 -0800 |
commit | e181d3f143f7957a73c8365829249d8084602606 (patch) | |
tree | 0fed469c8031cfc1b2b14489c804b901f204eb0e /kernel/bpf/helpers.c | |
parent | efc1970d683fa7c53a2bc561d40436bf11a18dc0 (diff) |
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>
Diffstat (limited to 'kernel/bpf/helpers.c')
-rw-r--r-- | kernel/bpf/helpers.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 89a95f3d854c..3d4edd314450 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -1760,8 +1760,6 @@ void *bpf_obj_new_impl(u64 local_type_id__k, void *meta__ign) u64 size = local_type_id__k; void *p; - if (unlikely(!bpf_global_ma_set)) - return NULL; p = bpf_mem_alloc(&bpf_global_ma, size); if (!p) return NULL; |