Files
linux/tools/lib/bpf
Yonghong Song b58b2b3a31 libbpf: Fix an error in 64bit relocation value computation
Currently, the 64bit relocation value in the instruction
is computed as follows:
  __u64 imm = insn[0].imm + ((__u64)insn[1].imm << 32)

Suppose insn[0].imm = -1 (0xffffffff) and insn[1].imm = 1.
With the above computation, insn[0].imm will first sign-extend
to 64bit -1 (0xffffffffFFFFFFFF) and then add 0x1FFFFFFFF,
producing incorrect value 0xFFFFFFFF. The correct value
should be 0x1FFFFFFFF.

Changing insn[0].imm to __u32 first will prevent 64bit sign
extension and fix the issue. Merging high and low 32bit values
also changed from '+' to '|' to be consistent with other
similar occurences in kernel and libbpf.

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20220607062610.3717378-1-yhs@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2022-06-07 10:20:42 -07:00
..
2022-05-19 09:03:31 -07:00
2022-05-19 09:03:31 -07:00
2022-06-03 14:53:33 -07:00
2022-06-03 14:53:33 -07:00
2022-06-03 14:53:33 -07:00
2022-06-03 14:53:33 -07:00
2022-06-03 14:53:33 -07:00
2021-10-01 22:54:38 +02:00
2022-03-07 22:13:00 -08:00
2021-11-01 18:12:44 -07:00