Debian Bug report logs - #754336
qemu-mips-static doesn't recognize broken ELF headers

version graph

Package: qemu-user-static; Maintainer for qemu-user-static is Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>; Source for qemu-user-static is src:qemu (PTS, buildd, popcon).

Reported by: "lcellier@lycee-joliverie.fr" <lcellier@lycee-joliverie.fr>

Date: Thu, 10 Jul 2014 02:30:02 UTC

Severity: normal

Tags: upstream

Found in version qemu/2.0.0+dfsg-6

Fixed in version 2.1+dfsg-1

Done: Michael Tokarev <mjt@tls.msk.ru>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>:
Bug#754336; Package qemu-user-static. (Thu, 10 Jul 2014 02:30:07 GMT) (full text, mbox, link).


Acknowledgement sent to "lcellier@lycee-joliverie.fr" <lcellier@lycee-joliverie.fr>:
New Bug report received and forwarded. Copy sent to Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>. (Thu, 10 Jul 2014 02:30:07 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: "lcellier@lycee-joliverie.fr" <lcellier@lycee-joliverie.fr>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: qemu-mips-static doesn't recognize ELF header correctly
Date: Thu, 10 Jul 2014 04:15:17 +0200
[Message part 1 (text/plain, inline)]
Package: qemu-user-static
Version: 2.0.0+dfsg-6+b1
Severity: important
Tags: upstream

Hello,

I can't run some mips32 binaries with qemu:

root@localhost:/tmp# chroot /tmp/temp/ /usr/bin/qemu-mips-static /bin/dmesg
/lib/ld-uClibc.so.0: Invalid ELF image for this architecture
root@localhost:/tmp# chroot /tmp/temp/ /usr/bin/qemu-mips-static /bin/ash
/bin/ash: Invalid ELF image for this architecture
root@localhost:/tmp# chroot /tmp/temp/ /usr/bin/qemu-mips-static /bin/busybox
/bin/busybox: Invalid ELF image for this architecture

The file command report some problems with the elf archives


note: /bin/dmesg is program I added by compiling it. qemu-mips-static run it on
my build rootfs (which come from a distro and is different than the target)
It also run on the real hardware:
root@localhost:/tmp# file /tmp/temp/bin/dmesg
/tmp/temp/bin/dmesg: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1,
dynamically linked (uses shared libs), not stripped


root@localhost:/tmp# file /tmp/temp/lib/ld-uClibc-0.9.33.2.so
/tmp/temp/lib/ld-uClibc-0.9.33.2.so: ELF 32-bit MSB shared object, MIPS, MIPS32
version 1 (SYSV), dynamically linked, corrupted section header size
root@localhost:/tmp# file /tmp/temp/bin/busybox
/tmp/temp/bin/busybox: ELF 32-bit MSB executable, MIPS, MIPS32 version 1
(SYSV), dynamically linked (uses shared libs), corrupted section header size

But when I copy the rootfs to my real hardware everything work correctly. I'm
also stuck with that rootfs because It contain vendor's scripts and proprietary
binaries for controlling the Linux kernel binary drivers.
In the meantime, I'm stuck because I can't test new compiled programs with
qemu, so I need to put it on my ADSL router and it reboot it each time.



-- System Information:
Debian Release: jessie/sid
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.7.3-alt330-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to fr_FR.utf8)
Shell: /bin/sh linked to /bin/dash

qemu-user-static depends on no packages.

Versions of packages qemu-user-static recommends:
ii  binfmt-support  2.1.4-1

Versions of packages qemu-user-static suggests:
ii  sudo  1.8.9p5-1

-- no debconf information
[partial rootfs.tar.7z (application/x-7z-compressed, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>:
Bug#754336; Package qemu-user-static. (Thu, 10 Jul 2014 07:33:08 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Tokarev <mjt@tls.msk.ru>:
Extra info received and forwarded to list. Copy sent to Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>. (Thu, 10 Jul 2014 07:33:08 GMT) (full text, mbox, link).


Message #10 received at 754336@bugs.debian.org (full text, mbox, reply):

From: Michael Tokarev <mjt@tls.msk.ru>
To: "lcellier@lycee-joliverie.fr" <lcellier@lycee-joliverie.fr>, 754336@bugs.debian.org
Subject: Re: Bug#754336: qemu-mips-static doesn't recognize ELF header correctly
Date: Thu, 10 Jul 2014 09:29:19 +0200
Control: severity -1 minor

10.07.2014 04:15, lcellier@lycee-joliverie.fr wrote:
> Package: qemu-user-static
> Version: 2.0.0+dfsg-6+b1
> Severity: important
> Tags: upstream
>
> Hello,
>
> I can't run some mips32 binaries with qemu:
>
> root@localhost:/tmp# chroot /tmp/temp/ /usr/bin/qemu-mips-static /bin/dmesg
> /lib/ld-uClibc.so.0: Invalid ELF image for this architecture

I checked your image, and noticed that only the binaries which are
reported as having a corrupted section header produce this error
message.

I'm in no way an expert in mips or file format issues like this. So
unless you talk with upstream directly, there's little chance I can
do anything with it. More, your case is unique, because it is the
first time we hit such a situation, it must be something in your
device or uclibc (and maybe kernel as well). Google can't find any
similar cases either.

And since it is apparently a situation unique to this (kind of)
device, I'm lowering the severity of this bugreport.

Thanks,

/mjt



Severity set to 'minor' from 'important' Request was from Michael Tokarev <mjt@tls.msk.ru> to 754336-submit@bugs.debian.org. (Thu, 10 Jul 2014 07:33:08 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>:
Bug#754336; Package qemu-user-static. (Thu, 10 Jul 2014 11:45:04 GMT) (full text, mbox, link).


Acknowledgement sent to 754336@bugs.debian.org:
Extra info received and forwarded to list. Copy sent to Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>. (Thu, 10 Jul 2014 11:45:04 GMT) (full text, mbox, link).


Message #17 received at 754336@bugs.debian.org (full text, mbox, reply):

From: Cellier <lcellier@lycee-joliverie.fr>
To: 754336@bugs.debian.org, Michael Tokarev <mjt@tls.msk.ru>
Subject: qemu-mips-static doesn't recognize ELF header correctly
Date: Thu, 10 Jul 2014 13:33:16 +0200
> I checked your image, and noticed that only the binaries which are
> reported as having a corrupted section header produce this error
> message.
> first time we hit such a situation, it must be something in your
> device or uclibc (and maybe kernel as well). Google can't find any
> similar cases either.
>
> And since it is apparently a situation unique to this (kind of)
> device, I'm lowering the severity of this bugreport.
>
> Thanks,
>
> /mjt
No really...


The bcm6358 is part of the the bcm63xx series.
Those SoC are used in most professional router/consumer modems. It is
used in all consumer modems in France (with every models from ISP).

While the kernel contain proprietary drivers it's source code have been
released by the manufacturer at http://www.efixo.net/gpl/ . Except some
.ko delivered as binary, there is nothing in particular. the µClibc
version is definitely unpatched.


A complete toolchain for building a very older flash image is available
at http://www.efixo.net/



The Neufox is one of consumer ADSL modem which use an SoC from the 
broadcom bcm63xx family.

regards..





Information forwarded to debian-bugs-dist@lists.debian.org, Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>:
Bug#754336; Package qemu-user-static. (Sun, 13 Jul 2014 13:21:16 GMT) (full text, mbox, link).


Acknowledgement sent to Cellier <lcellier@lycee-joliverie.fr>:
Extra info received and forwarded to list. Copy sent to Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>. (Sun, 13 Jul 2014 13:21:16 GMT) (full text, mbox, link).


Message #22 received at 754336@bugs.debian.org (full text, mbox, reply):

From: Cellier <lcellier@lycee-joliverie.fr>
To: 754336@bugs.debian.org
Subject: setting priority...
Date: Sun, 13 Jul 2014 15:19:31 +0200
Control: severity -1 normal

It appear many binaries from other distributions are affected by the 
same bug.
It also affect all mips32 binaries packages created by the Openwrt 
distribution (see 
http://downloads.openwrt.org/kamikaze/8.09.2/ifxmips/packages/ and 
http://downloads.openwrt.org/backfire/ and 
http://downloads.openwrt.org/snapshots/trunk/ ).

So, I'm changing the priority, since it appear a wide number of systems 
are affected.



Severity set to 'normal' from 'minor' Request was from Cellier <lcellier@lycee-joliverie.fr> to 754336-submit@bugs.debian.org. (Sun, 13 Jul 2014 13:21:16 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>:
Bug#754336; Package qemu-user-static. (Sat, 02 Aug 2014 10:21:04 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Tokarev <mjt@tls.msk.ru>:
Extra info received and forwarded to list. Copy sent to Debian QEMU Team <pkg-qemu-devel@lists.alioth.debian.org>. (Sat, 02 Aug 2014 10:21:04 GMT) (full text, mbox, link).


Message #29 received at 754336@bugs.debian.org (full text, mbox, reply):

From: Michael Tokarev <mjt@tls.msk.ru>
To: 754336@bugs.debian.org, "lcellier@lycee-joliverie.fr" <lcellier@lycee-joliverie.fr>
Subject: Re: Bug#754336: qemu-mips-static doesn't recognize ELF header correctly
Date: Sat, 02 Aug 2014 14:17:06 +0400
Control: retitle -1 qemu-mips-static doesn't recognize broken ELF headers

I'm retitling this bugreport to reflect reality.  Qemu implements its own
ELF parser, and it looks like it is a bit stricter than the one in linux
kernel.  I'm not sure whenever to treat it as a bug or a feature.  And
these binaries are indeed broken.  Qemu can be made less strict ofcourse.

I'm also forwarding this upstream, let's see what upstream will say...

Thanks,

/mjt



Changed Bug title to 'qemu-mips-static doesn't recognize broken ELF headers' from 'qemu-mips-static doesn't recognize ELF header correctly' Request was from Michael Tokarev <mjt@tls.msk.ru> to 754336-submit@bugs.debian.org. (Sat, 02 Aug 2014 10:21:05 GMT) (full text, mbox, link).


Reply sent to Michael Tokarev <mjt@tls.msk.ru>, 754336@bugs.debian.org:
You have taken responsibility. (Fri, 22 Aug 2014 11:03:05 GMT) (full text, mbox, link).


Notification sent to "lcellier@lycee-joliverie.fr" <lcellier@lycee-joliverie.fr>:
Bug acknowledged by developer. (Fri, 22 Aug 2014 11:03:05 GMT) (full text, mbox, link).


Message #36 received at 754336-done@bugs.debian.org (full text, mbox, reply):

From: Michael Tokarev <mjt@tls.msk.ru>
To: 754336-done@bugs.debian.org, "lcellier@lycee-joliverie.fr" <lcellier@lycee-joliverie.fr>
Subject: Re: Bug#754336: qemu-mips-static doesn't recognize ELF header correctly
Date: Fri, 22 Aug 2014 14:58:21 +0400
Version: 2.1+dfsg-1

This has been fixed upstream by this commit:

commit d3606f07440ee2c2bebea2b9932938e08b66d90b
Author: Craig Heffner <cheffner@tacnetsol.com>
Date:   Mon Dec 5 14:14:27 2011 -0500

    User mode support for Linux ELF files with no section header

    In user mode Linux, Qemu currently refuses to load ELF files that do not
    contain section headers (ehdr->e_shentsize == 0). Since section headers are not
    required in order to load an ELF file, simply removing the e_shentsize check in
    elf_check_ehdr() allows ELF binaries with no section headers to be run properly
    in user mode:

    Signed-off-by: Craig Heffner <cheffner@tacnetsol.com>
    Signed-off-by: Riku Voipio <riku.voipio@linaro.org>

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index c123244..1248eda 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1292,7 +1292,6 @@ static bool elf_check_ehdr(struct elfhdr *ehdr)
     return (elf_check_arch(ehdr->e_machine)
             && ehdr->e_ehsize == sizeof(struct elfhdr)
             && ehdr->e_phentsize == sizeof(struct elf_phdr)
-            && ehdr->e_shentsize == sizeof(struct elf_shdr)
             && (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN));
 }



this commit is included in 2.1 upstream version (it was applied past 2.0).

Thanks,

/mjt



Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Sat, 20 Sep 2014 07:29:45 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Fri Nov 24 18:20:57 2023; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.