summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/files/0002-libelf-Return-error-if-elf_compress_gnu-is-used-on-S.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/files/0002-libelf-Return-error-if-elf_compress_gnu-is-used-on-S.patch')
-rw-r--r--meta/recipes-devtools/elfutils/files/0002-libelf-Return-error-if-elf_compress_gnu-is-used-on-S.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/files/0002-libelf-Return-error-if-elf_compress_gnu-is-used-on-S.patch b/meta/recipes-devtools/elfutils/files/0002-libelf-Return-error-if-elf_compress_gnu-is-used-on-S.patch
new file mode 100644
index 0000000000..2465924acf
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/0002-libelf-Return-error-if-elf_compress_gnu-is-used-on-S.patch
@@ -0,0 +1,59 @@
1From d08572f7c9692c335afdb6f8dde48d77731209c3 Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mark@klomp.org>
3Date: Fri, 28 Sep 2018 10:45:56 +0800
4Subject: [PATCH 2/2] libelf: Return error if elf_compress_gnu is used on
5 SHF_COMPRESSED section.
6
7Compressing a section that is already compressed is fine, but useless.
8But it isn't possible to gnu compress (or decompress) a SHF_COMPRESSED
9section since there is no state kept that would tell if the section was
10first GNU compressed or first gabi compressed. Calling elf_compress_gnu
11on a section and then calling elf_compress on it to decompress it twice
12could cause a crash (the other way around is fine). Just disallow it.
13
14https://sourceware.org/bugzilla/show_bug.cgi?id=23528
15
16Signed-off-by: Mark Wielaard <mark@klomp.org>
17
18Upstream-Status: Backport [https://sourceware.org/git/?p=elfutils.git;a=commit;h=56b18521fb8d46d40fc090c0de9d11a08bc982fa]
19CVE: CVE-2018-16402
20Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
21---
22 libelf/elf_compress_gnu.c | 4 +++-
23 libelf/libelf.h | 5 +++++
24 2 files changed, 8 insertions(+), 1 deletion(-)
25
26diff --git a/libelf/elf_compress_gnu.c b/libelf/elf_compress_gnu.c
27index c35dc39..dfa7c57 100644
28--- a/libelf/elf_compress_gnu.c
29+++ b/libelf/elf_compress_gnu.c
30@@ -80,7 +80,9 @@ elf_compress_gnu (Elf_Scn *scn, int inflate, unsigned int flags)
31 sh_addralign = shdr->sh_addralign;
32 }
33
34- if ((sh_flags & SHF_ALLOC) != 0)
35+ /* Allocated sections, or sections that are already are compressed
36+ cannot (also) be GNU compressed. */
37+ if ((sh_flags & SHF_ALLOC) != 0 || (sh_flags & SHF_COMPRESSED))
38 {
39 __libelf_seterrno (ELF_E_INVALID_SECTION_FLAGS);
40 return -1;
41diff --git a/libelf/libelf.h b/libelf/libelf.h
42index 547c0f5..fa568f7 100644
43--- a/libelf/libelf.h
44+++ b/libelf/libelf.h
45@@ -366,6 +366,11 @@ extern Elf64_Chdr *elf64_getchdr (Elf_Scn *__scn);
46 It is an error to request compression for a section that already
47 has SHF_COMPRESSED set, or (for elf_compress) to request
48 decompression for an section that doesn't have SHF_COMPRESSED set.
49+ If a section has SHF_COMPRESSED set then calling elf_compress_gnu
50+ will result in an error. The section has to be decompressed first
51+ using elf_compress. Calling elf_compress on a section compressed
52+ with elf_compress_gnu is fine, but probably useless.
53+
54 It is always an error to call these functions on SHT_NOBITS
55 sections or if the section has the SHF_ALLOC flag set.
56 elf_compress_gnu will not check whether the section name starts
57--
582.7.4
59