MrChromebox / scripts

Scripts for setup/install/firmware update for ChromeOS devices
The Unlicense
568 stars 165 forks source link

`flashrom` and `cbfstool` provided by shell scripts aren't compatible with Musl. #412

Open GamePlayer-8 opened 3 months ago

GamePlayer-8 commented 3 months ago

Good afternoon,

There's an issue with latest scripts, leading to error:

MrChromebox Firmware Utility Script starting up

Downloading supporting files...

Downloading required tools...

Getting device/system info...

Flashrom is unable to read current firmware; cannot continue:

./functions.sh: line 456: /tmp/flashrom: cannot execute: required file not found

You may need to add 'iomem=relaxed' to your kernel parameters,
or trying running from a Live USB with a more permissive kernel (eg, Ubuntu 23.04+).

See https://www.flashrom.org/FAQ for more info.

The same error occurs with cbfstool, but gbb_utility runs fine. The system is Alpine Linux v3.20.

MrChromebox commented 3 months ago

not sure there's much I can do there, other than recommend you live boot another distro to update

GamePlayer-8 commented 3 months ago

I may suggest using staticx for turning the dynamic binary into a static one without the need of recompiling it. Not sure if that would work in that case, but the command execution needs to be done on the LibC under what the dynamic binary was compiled.

larshint commented 2 months ago

flashrom and cbfstool compile fine on musl systems, so it is possible to just modify the scripts to not use distributed binaries.

Anyway, I just tested staticx (interesting project, I wasn't aware of it). It works. Compilation took place in Linux Mint (glibc-based), tested in Gentoo (musl-based).

Reproducible steps (Linux Mint):

Install staticx:

# apt-get install pip patchelf
$ pip install staticx

Compile flashrom\cbfstool as described here.

Bundle all dependencies into one executable file:

$ ~/.local/bin/staticx <glibc-linked file> <static file name>

While this works, bundling can cause license issues.

Dependencies of flashrom:

$ lddtree flashrom
glibcflashrom => ./glibcflashrom (interpreter => /lib64/ld-linux-x86-64.so.2)
    libpci.so.3 => /lib/x86_64-linux-gnu/libpci.so.3
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1
        libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1
            ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6

Dependencies of cbfstool:

$ lddtree glibccbfstool
glibccbfstool => ./glibccbfstool (interpreter => /lib64/ld-linux-x86-64.so.2)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2

Each license of each dependency must be analyzed and included with all requirements. It is also worth noting that the licenses may not be compatible. Since this project does not control these dependencies, they may change over time. And each time it needs to be analyzed. Plus the libraries may have vulnerabilities, if they are statically linked, there will be no updates. In my opinion, the risk is high.