[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#864198: unblock: upx-ucl/3.91-4



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock version 3.91-4 of package upx-ucl.

This version fixes crashes occurring while executing compressed i386 
position-indpendent executables, for example the following commands 
on i386 system:
  cp /usr/bin/vim .; upx ./vim; ./vim
  cp /usr/bin/mutt .; upx ./mutt; ./mutt
end with segmentation faults in stretch, while they work as expected 
in jessie. This is related to some changes in binutils output.  (Also 
note that vim is PIE in both jessie and stretch, while mutt wasn't
PIE in jessie).

This is the issue I wrote about a week ago in #863537 while requesting 
unblock for previous upload that addressed crashes of amd64 executables,
and it has been fixed in a pretty same way as the amd64 one.


Comparing upx-ucl_3.91-3.dsc upx-ucl_3.91-4.dsc
diff -Nru upx-ucl-3.91/debian/changelog upx-ucl-3.91/debian/changelog
--- upx-ucl-3.91/debian/changelog	2017-05-20 09:16:37.000000000 +0200
+++ upx-ucl-3.91/debian/changelog	2017-05-31 21:50:25.000000000 +0200
@@ -1,3 +1,12 @@
+upx-ucl (3.91-4) unstable; urgency=medium
+
+  * Introduce Check-DT_REL-i386.patch to fix segmentation faults occurring
+    while executing upx-compressed i386 position-independent binaries. The
+    patch is strongly based on the one added previously for amd64 binaries,
+    and was reported to upstream in https://github.com/upx/upx/issues/106.
+
+ -- Robert Luberda <robert@debian.org>  Wed, 31 May 2017 21:50:25 +0200
+
 upx-ucl (3.91-3) unstable; urgency=medium
 
   * Add Check-DT_RELA.patch based on upstream's commit d688a05ac7 to
diff -Nru upx-ucl-3.91/debian/patches/Check-DT_REL-i386.patch upx-ucl-3.91/debian/patches/Check-DT_REL-i386.patch
--- upx-ucl-3.91/debian/patches/Check-DT_REL-i386.patch	1970-01-01 01:00:00.000000000 +0100
+++ upx-ucl-3.91/debian/patches/Check-DT_REL-i386.patch	2017-05-31 21:50:25.000000000 +0200
@@ -0,0 +1,66 @@
+From: Robert Luberda <robert@debian.org>
+Date: Sun, 28 May 2017 12:27:11 +0200
+Subject: DT_JMPREL is missing on i386 as well; check DT_REL
+
+Apply the changes from commit d688a05ac78517bcba09bae0f60bc76f3aa51ddb
+to PackLinuxElf32::canPack(), however check DT_REL instread of DT_RELA.
+This fixes crashes while running position independent i386 executables
+compressed with upx.
+
+The patch was sent to upstream in https://github.com/upx/upx/issues/106,
+and eventually got applied in a sligthly modified form in commit
+https://github.com/upx/upx/commit/ee18fe9bbab4955191e68a0982196f1b6f3e5c7d
+(the differences include extractions of duplicated code into functions,
+and introduction of DT_1_PIE checks that depend on  code not yet
+available in upx 3.91).
+---
+ src/p_elf_enum.h |  1 +
+ src/p_lx_elf.cpp | 16 ++++++++++++++++
+ 2 files changed, 17 insertions(+)
+
+diff --git a/src/p_elf_enum.h b/src/p_elf_enum.h
+index 5a4f602..121d04d 100644
+--- a/src/p_elf_enum.h
++++ b/src/p_elf_enum.h
+@@ -150,6 +150,7 @@
+         DT_RELAENT  =  9,       /* Size of one RELA relocation */
+         DT_INIT     = 12,       /* Address of init function */
+         DT_REL      = 17,       /* Relocations which contain no addend */
++        DT_RELSZ   =  18,       /* Total size of Rel relocs */
+         DT_RELENT   = 19,       /* Size of one Rel relocation */
+         DT_STRSZ    = 10,       /* Sizeof string table */
+         DT_PLTREL   = 20,       /* Type of reloc in PLT */
+diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp
+index 6f95c0b..ab00666 100644
+--- a/src/p_lx_elf.cpp
++++ b/src/p_lx_elf.cpp
+@@ -1359,6 +1359,8 @@ bool PackLinuxElf32::canPack()
+         // defined symbols, and there might be no DT_HASH.
+ 
+         Elf32_Rel const *
++        rel= (Elf32_Rel const *)elf_find_dynamic(Elf32_Dyn::DT_REL);
++        Elf32_Rel const *
+         jmprel=     (Elf32_Rel const *)elf_find_dynamic(Elf32_Dyn::DT_JMPREL);
+         for (   int sz = elf_unsigned_dynamic(Elf32_Dyn::DT_PLTRELSZ);
+                 0 < sz;
+@@ -1372,6 +1374,20 @@ bool PackLinuxElf32::canPack()
+                 goto proceed;
+         }
+ 
++        // 2017-05-28 DT_JMPREL is no more (binutils-2.26.1)?
++        // Check the general case, too.
++        for (   int sz = elf_unsigned_dynamic(Elf32_Dyn::DT_RELSZ);
++                0 < sz;
++                (sz -= sizeof(Elf32_Rel)), ++rel
++        ) {
++            unsigned const symnum = get_te32(&rel->r_info) >> 8;
++            char const *const symnam = get_te32(&dynsym[symnum].st_name) + dynstr;
++            if (0==strcmp(symnam, "__libc_start_main")
++            ||  0==strcmp(symnam, "__uClibc_main")
++            ||  0==strcmp(symnam, "__uClibc_start_main"))
++                goto proceed;
++        }
++
+         // Heuristic HACK for shared libraries (compare Darwin (MacOS) Dylib.)
+         // If there is an existing DT_INIT, and if everything that the dynamic
+         // linker ld-linux needs to perform relocations before calling DT_INIT
diff -Nru upx-ucl-3.91/debian/patches/series upx-ucl-3.91/debian/patches/series
--- upx-ucl-3.91/debian/patches/series	2017-05-20 09:16:37.000000000 +0200
+++ upx-ucl-3.91/debian/patches/series	2017-05-31 21:50:25.000000000 +0200
@@ -3,3 +3,4 @@
 02-Lzma-support.patch
 03-FTBFS-GCC6.patch
 Check-DT_RELA.patch
+Check-DT_REL-i386.patch

unblock upx-ucl/3.91-4

Thanks,
robert

-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (990, 'testing'), (200, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=pl_PL.UTF-8, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8), LANGUAGE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)


Reply to: