]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Return proper address for non-zero offsets in insn array
authorAnton Protopopov <a.s.protopopov@gmail.com>
Sun, 11 Jan 2026 15:30:45 +0000 (15:30 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 14 Jan 2026 03:35:47 +0000 (19:35 -0800)
The map_direct_value_addr() function of the instruction
array map incorrectly adds offset to the resulting address.
This is a bug, because later the resolve_pseudo_ldimm64()
function adds the offset. Fix it. Corresponding selftests
are added in a consequent commit.

Fixes: 493d9e0d6083 ("bpf, x86: add support for indirect jumps")
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-2-a.s.protopopov@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/bpf_insn_array.c

index c96630cb75bf7a0cc1f2ee060ad8459667d41946..37b43102953eebbc7b2e604517a2f557e31cd76f 100644 (file)
@@ -126,7 +126,7 @@ static int insn_array_map_direct_value_addr(const struct bpf_map *map, u64 *imm,
                return -EINVAL;
 
        /* from BPF's point of view, this map is a jump table */
-       *imm = (unsigned long)insn_array->ips + off;
+       *imm = (unsigned long)insn_array->ips;
 
        return 0;
 }