{{ message }}
Fix statx byte order on big-endian guests#1634
Open
retrocpugeek wants to merge 2 commits into
Open
Conversation
Statx32/Statx64 (and their StatxTimestamp structs) were defined only as
little-endian ctypes.Structure, and ql_syscall_statx used them regardless
of guest endianness. Every other stat-family struct already has an explicit
big-endian variant selected by ql.arch.endian; statx was the lone gap.
On a big-endian guest (e.g. MIPS/MIPS64 EB) this byte-swaps every statx
field. In particular stx_mode loses its S_IFDIR bit, so a directory looks
like a plain file and `busybox ls /` just echoes the argument instead of
listing the directory.
Add Statx{32,64}EB / StatxTimestamp{32,64}EB (ctypes.BigEndianStructure,
reusing the little-endian field layouts) and pick them when the guest is
big-endian. The little-endian path is byte-for-byte unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drives ql_syscall_statx on a big-endian MIPS context and checks that stx_mode, read back in the guest's byte order, still reports a directory (S_IFDIR). Before the fix the statx struct was emitted little-endian regardless of guest endianness, so the type bits were byte-swapped and a directory looked like a regular file. Self-contained (no rootfs binary, runs on stock unicorn). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Fixes
statxreturning a byte-swappedstruct statxon big-endian guests.ql_syscall_statxalways serialized the result with the little-endianStatx32/Statx64(ctypes.Structure), regardless of guest endianness. Every other stat-family struct instat.pyalready has a big-endian variant selected viaql.arch.endian;statxwas the only one missing it. On a big-endian guest this byte-swaps every field — most visiblystx_mode, which loses itsS_IFDIRbit, so a directory looks like a plain file (e.g.busybox ls /prints the path name instead of listing it). Modern glibc routesstat/fstatatthroughstatx, so this affects ordinary directory operations, not just directstatxcallers.Closes #1633.
How
Statx32EB/Statx64EB(andStatxTimestamp32EB/StatxTimestamp64EB) asctypes.BigEndianStructure, reusing the little-endian field layouts.ql_syscall_statxwhenql.arch.endian == QL_ENDIAN.EB.Test
test_elf.ELFTest.test_linux_statx_bigendiandrivesql_syscall_statxon a big-endian MIPS context and checks thatstx_mode, read back in the guest's byte order, still reports a directory. It is self-contained (no rootfs binary, runs on stock unicorn) and fails ondev(AssertionError), passes with this fix.Checklist