From: Viktor Malik Date: Fri, 15 Nov 2024 08:25:48 +0000 (+0100) Subject: bpf: Do not alloc arena on unsupported arches X-Git-Tag: v6.13-rc1~136^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab4dc30c5322fc46d0db938d1c0bdd56d7adcea1;p=thirdparty%2Fkernel%2Flinux.git bpf: Do not alloc arena on unsupported arches Do not allocate BPF arena on arches that do not support it, instead return EOPNOTSUPP. This is useful to prevent bugs such as soft lockups while trying to free the arena which we have witnessed on ppc64le [1]. [1] https://lore.kernel.org/bpf/4afdcb50-13f2-4772-8db1-3fd02bd985b3@redhat.com/ Signed-off-by: Viktor Malik Link: https://lore.kernel.org/r/20241115082548.74972-1-vmalik@redhat.com Signed-off-by: Alexei Starovoitov --- diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c index 3e1dfe349ced1..945a5680f6a54 100644 --- a/kernel/bpf/arena.c +++ b/kernel/bpf/arena.c @@ -3,6 +3,7 @@ #include #include #include +#include "linux/filter.h" #include #include #include @@ -99,6 +100,9 @@ static struct bpf_map *arena_map_alloc(union bpf_attr *attr) u64 vm_range; int err = -ENOMEM; + if (!bpf_jit_supports_arena()) + return ERR_PTR(-EOPNOTSUPP); + if (attr->key_size || attr->value_size || attr->max_entries == 0 || /* BPF_F_MMAPABLE must be set */ !(attr->map_flags & BPF_F_MMAPABLE) ||