diff options
Diffstat (limited to 'meta-oe/recipes-kernel/libbpf/files/0001-libbpf-check-for-empty-BTF-data-section-in-btf_parse.patch')
-rw-r--r-- | meta-oe/recipes-kernel/libbpf/files/0001-libbpf-check-for-empty-BTF-data-section-in-btf_parse.patch | 43 |
1 files changed, 43 insertions, 0 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 @@ | |||
1 | From ff2eb6e134ebfc225b97b46182af3cc58ed481f6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Changqing Li <changqing.li@windriver.com> | ||
3 | Date: Thu, 10 Apr 2025 11:50:04 +0800 | ||
4 | Subject: [PATCH] libbpf: check for empty BTF data section in btf_parse_elf | ||
5 | |||
6 | A valid ELF file may contain a SHT_NOBITS .BTF section. This case is | ||
7 | not handled correctly in btf_parse_elf, which leads to a segfault. | ||
8 | |||
9 | Add a null check for a buffer returned by elf_getdata() before | ||
10 | proceeding with its processing. | ||
11 | |||
12 | Bug report: https://github.com/libbpf/libbpf/issues/894 | ||
13 | |||
14 | Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> | ||
15 | Acked-by: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com> | ||
16 | |||
17 | Upstream-Status: Backport [https://github.com/kernel-patches/bpf-rc/commit/b02b669fd9398d246c8c9ae901c0d8f5bb36a588] | ||
18 | |||
19 | Signed-off-by: Changqing Li <changqing.li@windriver.com> | ||
20 | --- | ||
21 | btf.c | 6 ++++++ | ||
22 | 1 file changed, 6 insertions(+) | ||
23 | |||
24 | diff --git a/btf.c b/btf.c | ||
25 | index 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 | -- | ||
42 | 2.34.1 | ||
43 | |||