diff options
-rw-r--r-- | main/qemu/0001-elfload-load-PIE-executables-to-right-address.patch | 89 | ||||
-rw-r--r-- | main/qemu/APKBUILD | 6 |
2 files changed, 94 insertions, 1 deletions
diff --git a/main/qemu/0001-elfload-load-PIE-executables-to-right-address.patch b/main/qemu/0001-elfload-load-PIE-executables-to-right-address.patch new file mode 100644 index 000000000..1cf0c2bd1 --- /dev/null +++ b/main/qemu/0001-elfload-load-PIE-executables-to-right-address.patch @@ -0,0 +1,89 @@ +From 6818f32f74981d9bccec8afbab37c42b50ab58be Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi> +Date: Thu, 4 Jul 2013 15:50:36 +0300 +Subject: [RFC PATCH] elfload: load PIE executables to right address +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +PIE images are ET_DYN images. Check first for pinterp_name to make +sure the main executable always is loaded to correct place. + +See below for current behaviour of PIE executables: + +Reserved 0x7f000000 bytes of guest address space +host mmap_min_addr=0x1000 +guest_base 0x7f7cb41d5000 +start end size prot +0037f400-003fe400 0007f000 r-x +003fe400-003ff400 00001000 --- +003ff400-003fe400 fffff000 rw- +003fe400-003ff400 00001000 --- +003ff400-003ffc00 00000800 rw- +003ffc00-003fec00 fffff000 r-x +003fec00-003ffc00 00001000 --- +003ffc00-0007f000 ffc7f400 rw- +start_brk 0x00000000 +end_code 0x7eff7ac0 +start_code 0x7eff7000 +start_data 0x7efffac0 +end_data 0x7efffc18 +start_stack 0x7eff6dc8 +brk 0x7efffc34 +entry 0x7e799b30 +00000000-00005000 ---p 00000000 00:00 0 +00005000-00015000 rw-p 00000000 00:00 0 +00015000-7e77d000 ---p 00000000 00:00 0 +7e77d000-7e7ec000 r-xp 00000000 68:03 14326298 /lib/libc.so +7e7ec000-7e7f3000 ---p 00000000 00:00 0 +7e7f3000-7e7f4000 rw-p 0006e000 68:03 14326298 /lib/libc.so +7e7f4000-7e7f6000 rw-p 00000000 00:00 0 +7e7f6000-7e7f7000 ---p 00000000 00:00 0 +7e7f7000-7eff7000 rw-p 00000000 00:00 0 +7eff7000-7eff8000 r-xp 00000000 68:03 9731305 /usr/bin/brk +7eff8000-7efff000 ---p 00000000 00:00 0 +7e7f7000-7eff7000 rw-p 00000000 00:00 0 [stack] + +Showing how the main binary got loaded to wrong place. + +Signed-off-by: Timo Teräs <timo.teras@iki.fi> +--- +I assume pinterp_name is only ever set for the main executable. +Quick grep would indicate that this is indeed the case. + + linux-user/elfload.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index ddef23e..d6e00cd 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -1660,7 +1660,12 @@ static void load_elf_image(const char *image_name, int image_fd, + } + + load_addr = loaddr; +- if (ehdr->e_type == ET_DYN) { ++ if (pinterp_name != NULL) { ++ /* This is the main executable. Make sure that the low ++ address does not conflict with MMAP_MIN_ADDR or the ++ QEMU application itself. */ ++ probe_guest_base(image_name, loaddr, hiaddr); ++ } else if (ehdr->e_type == ET_DYN) { + /* The image indicates that it can be loaded anywhere. Find a + location that can hold the memory space required. If the + image is pre-linked, LOADDR will be non-zero. Since we do +@@ -1672,11 +1677,6 @@ static void load_elf_image(const char *image_name, int image_fd, + if (load_addr == -1) { + goto exit_perror; + } +- } else if (pinterp_name != NULL) { +- /* This is the main executable. Make sure that the low +- address does not conflict with MMAP_MIN_ADDR or the +- QEMU application itself. */ +- probe_guest_base(image_name, loaddr, hiaddr); + } + load_bias = load_addr - loaddr; + +-- +1.8.3.2 + diff --git a/main/qemu/APKBUILD b/main/qemu/APKBUILD index f33e69f14..7d3477065 100644 --- a/main/qemu/APKBUILD +++ b/main/qemu/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=qemu pkgver=1.5.1 -pkgrel=2 +pkgrel=3 pkgdesc="QEMU is a generic machine emulator and virtualizer" url="http://qemu.org/" arch="all" @@ -71,6 +71,7 @@ $pkgname-img $pkgname-guest-agent:guest " source="http://wiki.qemu-project.org/download/qemu-$pkgver.tar.bz2 + 0001-elfload-load-PIE-executables-to-right-address.patch qemu-guest-agent.confd qemu-guest-agent.initd 80-kvm.rules" @@ -223,14 +224,17 @@ guest() { } md5sums="b56e73bdcfdb214d5c68e13111aca96f qemu-1.5.1.tar.bz2 +672727bb1d8c8ab7b5def65dd1793c33 0001-elfload-load-PIE-executables-to-right-address.patch 1663bc6977f6886a58394155b1bf3676 qemu-guest-agent.confd 2035cd781ea810e94bda250c609d8d90 qemu-guest-agent.initd 66660f143235201249dc0648b39b86ee 80-kvm.rules" sha256sums="4c15a1ee2f387983eb5c1497f66bf567c34d14ba48517148f6eafef8ae09e3e8 qemu-1.5.1.tar.bz2 +af35304b165622a53f7557b59ffd8da5030f5fd444e669c862f9410131f3b987 0001-elfload-load-PIE-executables-to-right-address.patch d84e53a94584f37f3bd1b21f44077b5de0d07094c6729f26ae20ab1f7b9cc298 qemu-guest-agent.confd 982fa8ba67c728405305e4cf5a36a41a780b3d1f388ebd6377e7964c271a1c92 qemu-guest-agent.initd 37f666f1cdb7d8a62171de69b531681dcb0fba74236729dac8b6c019232eba84 80-kvm.rules" sha512sums="ea28434f786bd36d99f7908380f9dcd18def36899d001170edb9c1e6c341d81fab64d7d13b9028b01cb479ecb35f62975fe928767ac585267dd4ef7ffeb7b823 qemu-1.5.1.tar.bz2 +405008589cad1c8b609eca004d520bf944366e8525f85a19fc6e283c95b84b6c2429822ba064675823ab69f1406a57377266a65021623d1cd581e7db000134fd 0001-elfload-load-PIE-executables-to-right-address.patch d90c034cae3f9097466854ed1a9f32ab4b02089fcdf7320e8f4da13b2b1ff65067233f48809911485e4431d7ec1a22448b934121bc9522a2dc489009e87e2b1f qemu-guest-agent.confd 761b4e2397569dae45ae3bb9e46e28746275297f629af9e9065525497fd26a48b65d8abcf4282727afd35309e338967acf6a1b14c3169577bdc16c1f42e618b3 qemu-guest-agent.initd 9b7a89b20fcf737832cb7b4d5dc7d8301dd88169cbe5339eda69fbb51c2e537d8cb9ec7cf37600899e734209e63410d50d0821bce97e401421db39c294d97be2 80-kvm.rules" |