summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2013-10-21 19:37:22 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-10-30 13:39:08 +0000
commitcb5a224bd8511c083971d475e71097a459610a2d (patch)
treed67e1431007f45a26b6aff93d54c6e1dd9a422c5 /meta/recipes-devtools/rpm
parent8ceb14a352fa738e4a1df76673e13aef744fc7a8 (diff)
downloadpoky-cb5a224bd8511c083971d475e71097a459610a2d.tar.gz
debugedit: fix segment fault while file's bss offset have a large number
While ELF_C_RDWR_MMAP was used, elf_begin invoked mmap() to map file into memory. While the file's bss Offset has a large number, elf_update caculated file size by __elf64_updatenull_wrlock and the size was enlarged. In this situation, elf_update invoked ftruncate to enlarge the file, and memory size (elf->maximum_size) also was incorrectly updated. There was segment fault in elf_end which invoked munmap with the length is the enlarged file size, not the mmap's length. Before the above operations, invoke elf_begin/elf_update/elf_end with ELF_C_RDWR and ELF_F_LAYOUT set to enlarge the above file, it could make sure the file is safe for the following elf operations. [YOCTO #5356] https://bugzilla.redhat.com/show_bug.cgi?id=1019707 https://bugzilla.redhat.com/show_bug.cgi?id=1020842 (From OE-Core rev: 35c8b1ac7c3b1e4209b1e30d1dbd1a457286b97b) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/rpm')
-rw-r--r--meta/recipes-devtools/rpm/rpm/debugedit-valid-file-to-fix-segment-fault.patch67
-rw-r--r--meta/recipes-devtools/rpm/rpm_5.4.9.bb1
2 files changed, 68 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rpm/rpm/debugedit-valid-file-to-fix-segment-fault.patch b/meta/recipes-devtools/rpm/rpm/debugedit-valid-file-to-fix-segment-fault.patch
new file mode 100644
index 0000000000..2696cd3168
--- /dev/null
+++ b/meta/recipes-devtools/rpm/rpm/debugedit-valid-file-to-fix-segment-fault.patch
@@ -0,0 +1,67 @@
1debugedit: fix segment fault while file's bss offset have a large number
2
3While ELF_C_RDWR_MMAP was used, elf_begin invoked mmap() to map file
4into memory. While the file's bss Offset has a large number, elf_update
5caculated file size by __elf64_updatenull_wrlock and the size was
6enlarged.
7
8In this situation, elf_update invoked ftruncate to enlarge the file,
9and memory size (elf->maximum_size) also was incorrectly updated.
10There was segment fault in elf_end which invoked munmap with the
11length is the enlarged file size, not the mmap's length.
12
13Before the above operations, invoke elf_begin/elf_update/elf_end
14with ELF_C_RDWR and ELF_F_LAYOUT set to enlarge the above file, it
15could make sure the file is safe for the following elf operations.
16
17Upstream-Status: Pending
18Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
19---
20 tools/debugedit.c | 25 +++++++++++++++++++++++++
21 1 file changed, 25 insertions(+)
22
23diff --git a/tools/debugedit.c b/tools/debugedit.c
24--- a/tools/debugedit.c
25+++ b/tools/debugedit.c
26@@ -1512,6 +1512,28 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
27 }
28 }
29
30+/* It avoided the segment fault while file's bss offset have a large number.
31+ See https://bugzilla.redhat.com/show_bug.cgi?id=1019707
32+ https://bugzilla.redhat.com/show_bug.cgi?id=1020842 for detail. */
33+void valid_file(int fd)
34+{
35+ Elf *elf = elf_begin (fd, ELF_C_RDWR, NULL);
36+ if (elf == NULL)
37+ {
38+ error (1, 0, "elf_begin: %s", elf_errmsg (-1));
39+ return;
40+ }
41+
42+ elf_flagelf (elf, ELF_C_SET, ELF_F_LAYOUT);
43+
44+ if (elf_update (elf, ELF_C_WRITE) < 0)
45+ error (1, 0, "elf_update: %s", elf_errmsg (-1));
46+
47+ elf_end (elf);
48+
49+ return;
50+}
51+
52 int
53 main (int argc, char *argv[])
54 {
55@@ -1608,6 +1630,9 @@ main (int argc, char *argv[])
56 exit (1);
57 }
58
59+ /* Make sure the file is valid. */
60+ valid_file(fd);
61+
62 dso = fdopen_dso (fd, file);
63 if (dso == NULL)
64 exit (1);
65--
661.8.1.2
67
diff --git a/meta/recipes-devtools/rpm/rpm_5.4.9.bb b/meta/recipes-devtools/rpm/rpm_5.4.9.bb
index 5498541a50..4b95a906c9 100644
--- a/meta/recipes-devtools/rpm/rpm_5.4.9.bb
+++ b/meta/recipes-devtools/rpm/rpm_5.4.9.bb
@@ -86,6 +86,7 @@ SRC_URI = "http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex
86 file://rpm-platform2.patch \ 86 file://rpm-platform2.patch \
87 file://rpm-remove-sykcparse-decl.patch \ 87 file://rpm-remove-sykcparse-decl.patch \
88 file://debugedit-segv.patch \ 88 file://debugedit-segv.patch \
89 file://debugedit-valid-file-to-fix-segment-fault.patch \
89 file://rpm-platform-file-fix.patch \ 90 file://rpm-platform-file-fix.patch \
90 file://rpm-lsb-compatibility.patch \ 91 file://rpm-lsb-compatibility.patch \
91 " 92 "