Bug 209983 - [rc.d] emulators/qemu-user-static: incorrect ELF magic to run powerpc64 binaries
Summary: [rc.d] emulators/qemu-user-static: incorrect ELF magic to run powerpc64 binaries
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Sean Bruno
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-06-02 21:17 UTC by Jan Beich
Modified: 2016-06-14 14:40 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (sbruno)


Attachments
fix (1.12 KB, patch)
2016-06-02 21:17 UTC, Jan Beich
jbeich: maintainer-approval? (sbruno)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2016-06-02 21:17:57 UTC
Created attachment 170961 [details]
fix

rc.d/qemu_user_static assumes powerpc and powerpc64 have the same ELF magic which is actually false, at least on 11.0-CURRENT.

$ poudriere jail -cj head-powerpc64 -a powerpc.powerpc64 -m svn+https -v head
[...]

$ service qemu_user_static onestart

$ chroot /poudriere/jails/head-powerpc64 /rescue/date
chroot: /rescue/date: Exec format error

$ binmiscctl list
[...]
name: powerpc64
interpreter: /usr/local/bin/qemu-ppc64-static
flags: ENABLED USE_MASK
magic size: 20
magic offset: 0
magic: 0x7f 0x45 0x4c 0x46  0x01 0x02 0x01 0x00  0x00 0x00 0x00 0x00
       0x00 0x00 0x00 0x00  0x00 0x02 0x00 0x15
mask:  0xff 0xff 0xff 0xff  0xff 0xff 0xff 0x00  0xff 0xff 0xff 0xff
       0xff 0xff 0xff 0xff  0xff 0xfe 0xff 0xff
[...]

$ hd -n20 /poudriere/jails/head-powerpc64/rescue/date
00000000  7f 45 4c 46 02 02 01 09  00 00 00 00 00 00 00 00  |.ELF............|
00000010  00 02 00 15                                       |....|
00000014

$ poudriere jail -l | fgrep powerpc64
head-powerpc64 11.0-CURRENT r300425 powerpc.powerpc64 svn+https 2016-05-22 18:46:03 /poudriere/jails/head-powerpc64
Comment 1 Sean Bruno freebsd_committer 2016-06-02 23:42:30 UTC
(In reply to Jan Beich from comment #0)
Ok, does changing this allow the executable to run?
Comment 2 Jan Beich freebsd_committer 2016-06-11 17:53:58 UTC
If you don't trust me follow the steps to reproduce. I did QA my patch but cannot rule out possible environment poisoning: kernel patches, configuration, hardware, etc.
Comment 3 Sean Bruno freebsd_committer 2016-06-11 18:51:20 UTC
(In reply to Jan Beich from comment #2)
Oh ... no.  I was curious if this patch allows you to execute static binaries that *do* anything.  We've been trying to get ppc bsd-user working on and off for a while and haven't had much success.  If this works to get ppc64 binaries working, GREAT!  :-)
Comment 4 commit-hook freebsd_committer 2016-06-13 19:13:12 UTC
A commit references this bug:

Author: sbruno
Date: Mon Jun 13 19:12:50 UTC 2016
New revision: 416859
URL: https://svnweb.freebsd.org/changeset/ports/416859

Log:
  Use correct ELF magic to run powerpc64 binaries.

  PR:		209983
  Submitted by:	jbeich

Changes:
  head/emulators/qemu-sbruno/Makefile
  head/emulators/qemu-sbruno/files/qemu_user_static.in