Openembedded Core Discussions
 help / color / mirror / Atom feed
From: "Adrian Bunk" <bunk@stusta.de>
To: openembedded-core@lists.openembedded.org
Subject: [OE-core][zeus][PATCH 09/19] patchelf: Add patch to address corrupt shared library issue
Date: Thu,  9 Jul 2020 00:07:51 +0300	[thread overview]
Message-ID: <20200708210801.5553-9-bunk@stusta.de> (raw)
In-Reply-To: <20200708210801.5553-1-bunk@stusta.de>

From: Richard Purdie <richard.purdie@linuxfoundation.org>

patchelf can corrupt shared libraries if the program headers don't
immediately follow the elf header. Add a patch submitted upstream
to address this.

(From OE-Core rev: faaf5f34332290708f3720a5488b3d1549d9e95a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit e7811c787bbe2f5d49b3506309499acc27189988)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
---
 .../patchelf/patchelf/fix-phdrs.patch         | 37 +++++++++++++++++++
 .../patchelf/patchelf_0.10.bb                 |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch

diff --git a/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch b/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch
new file mode 100644
index 0000000000..d087bd7855
--- /dev/null
+++ b/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch
@@ -0,0 +1,37 @@
+When running patchelf on some existing patchelf'd binaries to change to longer 
+RPATHS, ldd would report the binaries as invalid. The output of objdump -x on 
+those libraryies should show the top of the .dynamic section is getting trashed,
+something like:
+
+0x600000001 0x0000000000429000
+0x335000 0x0000000000335000
+0xc740 0x000000000000c740
+0x1000 0x0000000000009098
+SONAME libglib-2.0.so.0
+
+(which should be RPATH and DT_NEEDED entries)
+
+This was tracked down to the code which injects the PT_LOAD section.
+
+The issue is that if the program headers were previously relocated to the end 
+of the file which was how patchelf operated previously, the relocation code 
+wouldn't work properly on a second run as it now assumes they're located after 
+the elf header. This change forces them back to immediately follow the elf
+header which is where the code has made space for them.
+
+Upstream-Status: Submitted [https://github.com/NixOS/patchelf/pull/202]
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+RP 2020/6/2
+
+Index: git/src/patchelf.cc
+===================================================================
+--- git.orig/src/patchelf.cc
++++ git/src/patchelf.cc
+@@ -762,6 +762,7 @@ void ElfFile<ElfFileParamNames>::rewrite
+     }
+ 
+     /* Add a segment that maps the replaced sections into memory. */
++    wri(hdr->e_phoff, sizeof(Elf_Ehdr));
+     phdrs.resize(rdi(hdr->e_phnum) + 1);
+     wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1);
+     Elf_Phdr & phdr = phdrs[rdi(hdr->e_phnum) - 1];
diff --git a/meta/recipes-devtools/patchelf/patchelf_0.10.bb b/meta/recipes-devtools/patchelf/patchelf_0.10.bb
index cc983e033a..e4a604ec70 100644
--- a/meta/recipes-devtools/patchelf/patchelf_0.10.bb
+++ b/meta/recipes-devtools/patchelf/patchelf_0.10.bb
@@ -1,6 +1,7 @@
 SRC_URI = "https://nixos.org/releases/${BPN}/${BPN}-${PV}/${BPN}-${PV}.tar.bz2 \
            file://handle-read-only-files.patch \
            file://fix-adjusting-startPage.patch \
+           file://fix-phdrs.patch \
            "
 
 LICENSE = "GPLv3"
-- 
2.17.1


  parent reply	other threads:[~2020-07-08 21:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 21:07 [OE-core][zeus][PATCH 01/19] python3: Upgrade 3.7.7 -> 3.7.8 Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 02/19] timezone: upgrade 2019c -> 2020a Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 03/19] sqlite: backport CVE fix Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 04/19] gcr: depends on gnupg-native Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 05/19] file: add bzip2-replacement-native to DEPENDS to fix sstate issue Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 06/19] cve-check: Run it after do_fetch Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 07/19] libexif: fix CVE-2020-13114 Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 08/19] cve-check: include epoch in product version output Adrian Bunk
2020-07-08 21:07 ` Adrian Bunk [this message]
2020-07-08 21:07 ` [OE-core][zeus][PATCH 10/19] vim: _FORTIFY_SOURCE=2 be gone Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 11/19] wpa-supplicant: remove service templates from SYSTEMD_SERVICE Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 12/19] encodings: clear postinst script Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 13/19] mtd-utils: Fix return value of ubiformat Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 14/19] bind: update 9.11.5-P4 -> 9.11.13 Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 15/19] bind: update to 9.11.19 Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 16/19] perl: Fix host specific modules problems Adrian Bunk
2020-07-08 21:07 ` [OE-core][zeus][PATCH 17/19] dbus: fix CVE-2020-12049 Adrian Bunk
2020-07-08 21:08 ` [OE-core][zeus][PATCH 18/19] perl: fix CVE-2020-10543 & CVE-2020-10878 Adrian Bunk
2020-07-08 21:08 ` [OE-core][zeus][PATCH 19/19] wpa-supplicant: Security fix CVE-2020-12695 Adrian Bunk
2020-07-08 21:32 ` ✗ patchtest: failure for "[zeus] python3: Upgrade 3.7.7 ..." and 18 more Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200708210801.5553-9-bunk@stusta.de \
    --to=bunk@stusta.de \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox