summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2018-08-16 10:38:22 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-16 22:40:27 +0100
commit1faa551931e061367bb5ba8047dfa7badf726aff (patch)
treee2f4dc5ecdf93ff422207408ba9b0f9c434e678d /meta
parent0f327c393f613dabf4535a71638e47e57b21c521 (diff)
downloadpoky-1faa551931e061367bb5ba8047dfa7badf726aff.tar.gz
elfutils: check data_list.data.d.d_buf before free it
[YOCTO #12791] The one which actually saves the data is data_list.data.d.d_buf, so check it before free rawdata_base. This can fix a segmentation fault when prelink libqb_1.0.3: prelink: /usr/lib/libqb.so.0.18.2: Symbol section index outside of section numbers The segmentation fault happens when prelink call elf_end(). Fixed: MACHINE="qemux86-64" IMAGE_INSTALL_append = " libqb" #libqp is from meta-openembedded $ bitbake core-image-minimal Segmention fault (From OE-Core rev: 560154e8525dce4beb8199ffc0d7c964da9d665a) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/elfutils/elfutils_0.172.bb1
-rw-r--r--meta/recipes-devtools/elfutils/files/0001-libelf-elf_end.c-check-data_list.data.d.d_buf-before.patch39
2 files changed, 40 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/elfutils_0.172.bb b/meta/recipes-devtools/elfutils/elfutils_0.172.bb
index 9d02211d49..1cdff40a86 100644
--- a/meta/recipes-devtools/elfutils/elfutils_0.172.bb
+++ b/meta/recipes-devtools/elfutils/elfutils_0.172.bb
@@ -16,6 +16,7 @@ SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \
16 file://0006-Fix-build-on-aarch64-musl.patch \ 16 file://0006-Fix-build-on-aarch64-musl.patch \
17 file://0007-Fix-control-path-where-we-have-str-as-uninitialized-.patch \ 17 file://0007-Fix-control-path-where-we-have-str-as-uninitialized-.patch \
18 file://0001-libasm-may-link-with-libbz2-if-found.patch \ 18 file://0001-libasm-may-link-with-libbz2-if-found.patch \
19 file://0001-libelf-elf_end.c-check-data_list.data.d.d_buf-before.patch \
19 file://debian/0001-hppa_backend.patch \ 20 file://debian/0001-hppa_backend.patch \
20 file://debian/0001-arm_backend.patch \ 21 file://debian/0001-arm_backend.patch \
21 file://debian/0001-mips_backend.patch \ 22 file://debian/0001-mips_backend.patch \
diff --git a/meta/recipes-devtools/elfutils/files/0001-libelf-elf_end.c-check-data_list.data.d.d_buf-before.patch b/meta/recipes-devtools/elfutils/files/0001-libelf-elf_end.c-check-data_list.data.d.d_buf-before.patch
new file mode 100644
index 0000000000..8b03c0ea6b
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/0001-libelf-elf_end.c-check-data_list.data.d.d_buf-before.patch
@@ -0,0 +1,39 @@
1From d68822e93c57c3fbb77b93eada5986d2240157c2 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Thu, 16 Aug 2018 09:58:26 +0800
4Subject: [PATCH] libelf/elf_end.c: check data_list.data.d.d_buf before free it
5
6The one which actually saves the data is data_list.data.d.d_buf, so check it
7before free rawdata_base.
8
9This can fix a segmentation fault when prelink libqb_1.0.3:
10prelink: /usr/lib/libqb.so.0.18.2: Symbol section index outside of section numbers
11
12The segmentation fault happens when prelink call elf_end().
13
14Upstream-Status: Submitted [https://sourceware.org/ml/elfutils-devel/2018-q3/msg00065.html]
15
16Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
17---
18 libelf/elf_end.c | 3 ++-
19 1 file changed, 2 insertions(+), 1 deletion(-)
20
21diff --git a/libelf/elf_end.c b/libelf/elf_end.c
22index 160f0b8..5388e80 100644
23--- a/libelf/elf_end.c
24+++ b/libelf/elf_end.c
25@@ -165,9 +165,10 @@ elf_end (Elf *elf)
26
27 /* The section data is allocated if we couldn't mmap
28 the file. Or if we had to decompress. */
29- if (elf->map_address == NULL
30+ if ((elf->map_address == NULL
31 || scn->rawdata_base == scn->zdata_base
32 || (scn->flags & ELF_F_MALLOCED) != 0)
33+ && (scn->data_list.data.d.d_buf != NULL))
34 free (scn->rawdata_base);
35
36 /* Free the list of data buffers for the section.
37--
382.7.4
39