backport patches from upstream:backport-libbpf-Fix-an-error-in-64bit-relocation-value-comput.patch

Signed-off-by: superCharge-xsy <xiesongyang@huawei.com>
(cherry picked from commit 767848cdce2c8335a84af7d2a2cabe4ceeb7b2de)
This commit is contained in:
superCharge-xsy 2024-06-20 22:29:09 +08:00 committed by openeuler-sync-bot
parent 18044d588a
commit f58bd2f4a7
2 changed files with 53 additions and 2 deletions

View File

@ -0,0 +1,47 @@
From 0167a883554df812013ae1778724943ed0c8a069 Mon Sep 17 00:00:00 2001
From: Yonghong Song <yhs@fb.com>
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 <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>
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

View File

@ -4,7 +4,7 @@
Name: %{githubname} Name: %{githubname}
Version: %{githubver} Version: %{githubver}
Release: 13 Release: 14
Summary: Libbpf library Summary: Libbpf library
License: LGPLv2 or BSD 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 Patch0026: backport-libbpf-Fix-str_has_sfxs-return-value.patch
Patch0027: backport-libbpf-Initialize-err-in-probe_map_create.patch Patch0027: backport-libbpf-Initialize-err-in-probe_map_create.patch
Patch0028: backport-libbpf-Modify-the-function-name-in-libbpf.c-to-match.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, # This package supersedes libbpf from kernel-tools,
# which has default Epoch: 0. By having Epoch: 1 # which has default Epoch: 0. By having Epoch: 1
# this libbpf will take over smoothly # this libbpf will take over smoothly
@ -94,6 +94,10 @@ developing applications that use %{name}
%{_libdir}/libbpf.a %{_libdir}/libbpf.a
%changelog %changelog
* Thu Jun 20 2024 xiesongyang <xiesongyang@huawei.com> - 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 <jinzhiguang@kylinos.cn> - 2:0.8.1-13 * Sun Apr 28 2024 jinzhiguang <jinzhiguang@kylinos.cn> - 2:0.8.1-13
- backport patch from upstream: - backport patch from upstream:
backport-libbpf-Modify-the-function-name-in-libbpf.c-to-match.patch backport-libbpf-Modify-the-function-name-in-libbpf.c-to-match.patch