diff --git a/backport-libbpf-Fix-an-error-in-64bit-relocation-value-comput.patch b/backport-libbpf-Fix-an-error-in-64bit-relocation-value-comput.patch new file mode 100644 index 0000000000000000000000000000000000000000..b8c9897ca2bdbb05b67aaef3119dbe21e1013069 --- /dev/null +++ b/backport-libbpf-Fix-an-error-in-64bit-relocation-value-comput.patch @@ -0,0 +1,47 @@ +From 0167a883554df812013ae1778724943ed0c8a069 Mon Sep 17 00:00:00 2001 +From: Yonghong Song +Date: Mon, 6 Jun 2022 23:26:10 -0700 +Subject: [PATCH] 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 +Acked-by: Dave Marchevsky +Signed-off-by: Yonghong Song +Link: https://lore.kernel.org/r/20220607062610.3717378-1-yhs@fb.com +Signed-off-by: Alexei Starovoitov +Conflict:NA +Reference:https://github.com/libbpf/libbpf/commit/0167a883554df812013ae1778724943ed0c8a069 +--- + src/relo_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/relo_core.c b/src/relo_core.c +index ba4453d..a9216b6 100644 +--- a/src/relo_core.c ++++ b/src/relo_core.c +@@ -1027,7 +1027,7 @@ int bpf_core_patch_insn(const char *prog_name, struct bpf_insn *insn, + return -EINVAL; + } + +- imm = insn[0].imm + ((__u64)insn[1].imm << 32); ++ imm = (__u32)insn[0].imm | ((__u64)insn[1].imm << 32); + if (res->validate && imm != orig_val) { + pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDIMM64) value: got %llu, exp %u -> %u\n", + prog_name, relo_idx, +-- +2.33.0 + diff --git a/libbpf.spec b/libbpf.spec index 6417736649240101f29343f24e6a9eef7fd3f41b..4d49b22a3f0ff6c1915d8bb68da38b68d903bbde 100644 --- a/libbpf.spec +++ b/libbpf.spec @@ -4,7 +4,7 @@ Name: %{githubname} Version: %{githubver} -Release: 13 +Release: 14 Summary: Libbpf library License: LGPLv2 or BSD @@ -42,7 +42,7 @@ Patch0025: backport-libbpf-Fix-NULL-pointer-dereference-in_bpf_object__c.pa Patch0026: backport-libbpf-Fix-str_has_sfxs-return-value.patch Patch0027: backport-libbpf-Initialize-err-in-probe_map_create.patch Patch0028: backport-libbpf-Modify-the-function-name-in-libbpf.c-to-match.patch - +Patch0029: backport-libbpf-Fix-an-error-in-64bit-relocation-value-comput.patch # This package supersedes libbpf from kernel-tools, # which has default Epoch: 0. By having Epoch: 1 # this libbpf will take over smoothly @@ -94,6 +94,10 @@ developing applications that use %{name} %{_libdir}/libbpf.a %changelog +* Thu Jun 20 2024 xiesongyang - 2:0.8.1-14 +- backport patch from upstream: + backport-libbpf-Fix-an-error-in-64bit-relocation-value-comput.patch + * Sun Apr 28 2024 jinzhiguang - 2:0.8.1-13 - backport patch from upstream: backport-libbpf-Modify-the-function-name-in-libbpf.c-to-match.patch