Bug 213809 - [linux] Cannot run musl binaries e.g., from Alpine Linux
Summary: [linux] Cannot run musl binaries e.g., from Alpine Linux
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: Dmitry Chagin
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-10-26 13:59 UTC by Yonas Yanfa
Modified: 2017-07-15 08:29 UTC (History)
3 users (show)

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


Attachments
Add ELF brand recognition for musl Linux x86_64 binaries (1.16 KB, patch)
2017-05-26 14:23 UTC, Val Packett
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yonas Yanfa 2016-10-26 13:59:18 UTC
This is the output I see:

$ docker run --rm -it alpine sh
ELF binary type "0" not known.
ELF binary type "0" not known.
jail: exec sh: Exec format error
jail: sh: failed
Comment 1 Val Packett 2017-05-26 14:23:09 UTC
Created attachment 182934 [details]
Add ELF brand recognition for musl Linux x86_64 binaries

This isn't a Docker problem, you'd get the same if you just extracted Alpine's rootfs and ran `jail -c path=$(pwd) mount.devfs ip4=inherit command=/bin/sh` there.

When a binary isn't recognized, you can run brandelf(1) on it.

However this would be terrible for actually doing work in a Linux jail — you install a package within Linux and the binary does not work and you have to brandelf it…

So here's a patch that makes FreeBSD recognize these binaries.
Comment 2 Yonas Yanfa 2017-05-26 23:07:37 UTC
Thanks Greg!
Comment 3 Yonas Yanfa 2017-05-28 04:48:50 UTC
The patch works for me!
Comment 4 Dmitry Chagin freebsd_committer freebsd_triage 2017-07-02 19:13:24 UTC
What about x86 binaries?
Comment 5 Val Packett 2017-07-02 21:11:35 UTC
I have tried adding a similar section to the 32-bit thing but it didn't work, I probably messed something up. Who cares about 32-bit Linux containers anyway? :)
Comment 6 Yonas Yanfa 2017-07-02 23:58:58 UTC
(In reply to Greg V from comment #5)

I believe Docker on FreeBSD require 64-bit, so 32-bit support probably isn't worth worrying about.
Comment 7 Val Packett 2017-07-02 23:59:58 UTC
(In reply to Yonas Yanfa from comment #6)
Yeah. It's not all about Docker though.
Comment 8 Yonas Yanfa 2017-07-03 00:12:56 UTC
(In reply to Greg V from comment #7)

True. This issue has been open for a little while (7 months). Why don't we commit the patch we have now, and when we're able to figure out how to get 32-bit working, we can commit that later?
Comment 9 commit-hook freebsd_committer freebsd_triage 2017-07-03 10:25:53 UTC
A commit references this bug:

Author: dchagin
Date: Mon Jul  3 10:24:49 UTC 2017
New revision: 320595
URL: https://svnweb.freebsd.org/changeset/base/320595

Log:
  Add support for musl consumers to the Linuxulator.

  PR:		213809
  Submitted by:	Yonas Yanfa
  Reported by:	Yonas Yanfa
  MFC after:	1 week
  Relnotes:	yes

Changes:
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/i386/linux/linux_sysvec.c
Comment 10 commit-hook freebsd_committer freebsd_triage 2017-07-15 08:27:43 UTC
A commit references this bug:

Author: dchagin
Date: Sat Jul 15 08:27:23 UTC 2017
New revision: 321007
URL: https://svnweb.freebsd.org/changeset/base/321007

Log:
  MFC r320595:

  Add support for musl consumers to the Linuxulator.

  PR:		213809
  Submitted by:	Yonas Yanfa (for amd64)
  Reported by:	Yonas Yanfa
  Relnotes:	yes

Changes:
_U  stable/11/
  stable/11/sys/amd64/linux/linux_sysvec.c
  stable/11/sys/amd64/linux32/linux32_sysvec.c
  stable/11/sys/i386/linux/linux_sysvec.c
Comment 11 Dmitry Chagin freebsd_committer freebsd_triage 2017-07-15 08:29:50 UTC
Thanks