summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-kernel/libbpf/files/0001-libbpf-check-for-empty-BTF-data-section-in-btf_parse.patch43
-rw-r--r--meta-oe/recipes-kernel/libbpf/libbpf_1.5.0.bb4
2 files changed, 46 insertions, 1 deletions
diff --git a/meta-oe/recipes-kernel/libbpf/files/0001-libbpf-check-for-empty-BTF-data-section-in-btf_parse.patch b/meta-oe/recipes-kernel/libbpf/files/0001-libbpf-check-for-empty-BTF-data-section-in-btf_parse.patch
new file mode 100644
index 0000000000..873995b644
--- /dev/null
+++ b/meta-oe/recipes-kernel/libbpf/files/0001-libbpf-check-for-empty-BTF-data-section-in-btf_parse.patch
@@ -0,0 +1,43 @@
1From ff2eb6e134ebfc225b97b46182af3cc58ed481f6 Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Thu, 10 Apr 2025 11:50:04 +0800
4Subject: [PATCH] libbpf: check for empty BTF data section in btf_parse_elf
5
6A valid ELF file may contain a SHT_NOBITS .BTF section. This case is
7not handled correctly in btf_parse_elf, which leads to a segfault.
8
9Add a null check for a buffer returned by elf_getdata() before
10proceeding with its processing.
11
12Bug report: https://github.com/libbpf/libbpf/issues/894
13
14Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
15Acked-by: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
16
17Upstream-Status: Backport [https://github.com/kernel-patches/bpf-rc/commit/b02b669fd9398d246c8c9ae901c0d8f5bb36a588]
18
19Signed-off-by: Changqing Li <changqing.li@windriver.com>
20---
21 btf.c | 6 ++++++
22 1 file changed, 6 insertions(+)
23
24diff --git a/btf.c b/btf.c
25index e9673c0e..21d38dcf 100644
26--- a/btf.c
27+++ b/btf.c
28@@ -1199,6 +1199,12 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf,
29 goto done;
30 }
31
32+ if (!secs.btf_data->d_buf) {
33+ pr_warn("BTF data is empty in %s\n", path);
34+ err = -ENODATA;
35+ goto done;
36+ }
37+
38 if (secs.btf_base_data) {
39 dist_base_btf = btf_new(secs.btf_base_data->d_buf, secs.btf_base_data->d_size,
40 NULL);
41--
422.34.1
43
diff --git a/meta-oe/recipes-kernel/libbpf/libbpf_1.5.0.bb b/meta-oe/recipes-kernel/libbpf/libbpf_1.5.0.bb
index 5f92939274..58bb7bca09 100644
--- a/meta-oe/recipes-kernel/libbpf/libbpf_1.5.0.bb
+++ b/meta-oe/recipes-kernel/libbpf/libbpf_1.5.0.bb
@@ -8,7 +8,9 @@ LIC_FILES_CHKSUM = "file://../LICENSE.LGPL-2.1;md5=b370887980db5dd40659b50909238
8 8
9DEPENDS = "zlib elfutils" 9DEPENDS = "zlib elfutils"
10 10
11SRC_URI = "git://github.com/libbpf/libbpf.git;protocol=https;branch=master" 11SRC_URI = "git://github.com/libbpf/libbpf.git;protocol=https;branch=master \
12 file://0001-libbpf-check-for-empty-BTF-data-section-in-btf_parse.patch \
13"
12SRCREV = "09b9e83102eb8ab9e540d36b4559c55f3bcdb95d" 14SRCREV = "09b9e83102eb8ab9e540d36b4559c55f3bcdb95d"
13 15
14PACKAGE_ARCH = "${MACHINE_ARCH}" 16PACKAGE_ARCH = "${MACHINE_ARCH}"