]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf: Return EACCES for incorrect access to insn array
authorAnton Protopopov <a.s.protopopov@gmail.com>
Sun, 11 Jan 2026 15:30:46 +0000 (15:30 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 14 Jan 2026 03:36:18 +0000 (19:36 -0800)
The insn_array_map_direct_value_addr() function currently returns
-EINVAL when the offset within the map is invalid. Change this to
return -EACCES, so that it is consistent with similar boundary access
checks in the verifier.

Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Link: https://lore.kernel.org/r/20260111153047.8388-3-a.s.protopopov@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/bpf_insn_array.c

index 37b43102953eebbc7b2e604517a2f557e31cd76f..c0286f25ca3c6173694ab5efa3cb79eb2c5faf07 100644 (file)
@@ -123,7 +123,7 @@ static int insn_array_map_direct_value_addr(const struct bpf_map *map, u64 *imm,
 
        if ((off % sizeof(long)) != 0 ||
            (off / sizeof(long)) >= map->max_entries)
-               return -EINVAL;
+               return -EACCES;
 
        /* from BPF's point of view, this map is a jump table */
        *imm = (unsigned long)insn_array->ips;