mirror of
https://github.com/dikeckaan/mu300-linux.git
synced 2026-12-06 00:03:00 +00:00
On some devices su runs the command on a pty, and the tty layer's ONLCR rewrites every LF as CRLF. exec-out exists to avoid exactly that translation, but the pty su allocates puts it back, so every binary read came back inflated by about one byte in 256 - silently, with no error anywhere. jizni reported it with a proof that leaves no room: `dd bs=1M count=64` cannot emit more than 67108864 bytes, and 67357842 arrived. For six firmware files the CRLF count in the corrupted copy equals the LF count in the good one exactly, and normalising the corrupted copy back makes it byte-identical. What it costs when it happens: the Wi-Fi firmware reaches /lib/firmware mangled, the driver loads without complaint and no phy is ever created - the install reports success, 5G works and there is simply no hotspot, with nothing in any log pointing at it. The boot image is built from a corrupted dump, so it is the wrong size and its header and AVB tail are wrong. The vendor tar fails to extract. The GPU closure dies in struct.unpack_from. The bootloader_control block is read from a shifted offset. Every binary read now goes through a file on the device and `adb pull`, which never touches a pty and is correct whether or not that device's su allocates one: install.sh (boot_a, the misc head, the six firmware files), uninstall.sh, backup-device.sh, collect-logs.sh, reset-password.sh, extract-subset.sh, extract_subset.py, pull_closure.py and both .ps1 scripts. install.sh also refuses to continue when a firmware file could not be read, which is what turns the worst case above into a loud failure instead of a device that boots without Wi-Fi. Secondary problems from the same report, all confirmed in the source: * install.ps1 piped into the `Python` helper, an advanced function with no pipeline-bound parameter - the binding fails, and its body would not forward $input to the child's stdin even if it bound. Calls the interpreter directly. * Python detection read only Get-Command's .Source, which is empty for the Microsoft Store's app-execution alias, so a working interpreter was "not found". Falls back to .Path. * extract_subset.py created the output directory before validating the archive, so a failed run left an empty directory that every later run then skipped. Validates first. * regdb-load's `sleep 0.3` is rejected by busybox sleep, so the wait loop spun instead of waiting. FINDINGS 9b gains the 32 GB variant: shrinking `userdata`, which is the last partition so nothing else moves and the boot chain stays valid, recovers 10 GiB and the installer then runs unmodified. Worth recording that this never reproduced here - the backups taken with backup-device.sh on the maintainer's device are all exact partition sizes - which is why it survived this long, and why the fix is written to be correct on both kinds of device rather than conditional on detecting one. Reported-by: jizni Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Z17MBkdHmZPvNPNSLxcHk