]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bpf: Fix extable fixup offset.
authorAlexei Starovoitov <ast@kernel.org>
Thu, 16 Dec 2021 02:38:30 +0000 (18:38 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 16 Dec 2021 20:18:26 +0000 (21:18 +0100)
The prog - start_of_ldx is the offset before the faulting ldx to the location
after it, so this will be used to adjust pt_regs->ip for jumping over it and
continuing, and with old temp it would have been fixed up to the wrong offset,
causing crash.

Fixes: 643d483d7b91 ("bpf: Emit explicit NULL pointer checks for PROBE_LDX instructions.")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
arch/x86/net/bpf_jit_comp.c

index 726700fabca6d4f263b3b45f659a736e4c7013e4..fa58681db45e4d7bda6eb95081fe64b36efc650a 100644 (file)
@@ -1305,7 +1305,7 @@ st:                       if (is_imm8(insn->off))
                                 * End result: x86 insn "mov rbx, qword ptr [rax+0x14]"
                                 * of 4 bytes will be ignored and rbx will be zero inited.
                                 */
-                               ex->fixup = (prog - temp) | (reg2pt_regs[dst_reg] << 8);
+                               ex->fixup = (prog - start_of_ldx) | (reg2pt_regs[dst_reg] << 8);
                        }
                        break;