Skip to content

Use 32-bit UID/GID syscalls on arm, sparc, and x86 - #1716

Merged
sunfishcode merged 1 commit into
bytecodealliance:mainfrom
kmehltretter82:fix/32bit-uid-gid-syscalls
Oct 26, 2026
Merged

sunfishcode merged 1 commit into
bytecodealliance:mainfrom
kmehltretter82:fix/32bit-uid-gid-syscalls

Conversation

@kmehltretter82

Copy link
Copy Markdown
Contributor

On 32-bit Linux arm, sparc, and x86, the unsuffixed getgroups, setgroups, setuid, setgid, chown, and fchown syscalls take 16-bit UIDs and GIDs, while rustix uses 32-bit Uid and Gid values.

Calling the 16-bit syscalls truncates UIDs and GIDs at 65536 and causes getgroups and setgroups_thread to read and write pairs of 16-bit GIDs in each 32-bit Gid slot.

Use the *32 syscall variants for getgroups, setuid_thread, setgid_thread, setgroups_thread, chown, and fchown on arm, sparc, and x86 in both the linux_raw and libc backends, matching getuid and setresuid_thread.

Add a getgroups test comparing against libc.

On 32-bit Linux arm, sparc, and x86, the unsuffixed getgroups,
setgroups, setuid, setgid, chown, and fchown syscalls take 16-bit
UIDs and GIDs, while rustix uses 32-bit Uid and Gid values. Calling
the 16-bit syscalls truncates UIDs and GIDs at 65536 and causes
getgroups and setgroups_thread to read and write pairs of 16-bit GIDs
in each 32-bit Gid slot.

Use the *32 syscall variants for getgroups, setuid_thread,
setgid_thread, setgroups_thread, chown, and fchown on arm, sparc, and
x86 in both the linux_raw and libc backends, matching getuid and
setresuid_thread. Add a getgroups test comparing against libc.
@sunfishcode

Copy link
Copy Markdown
Member

Thanks!

@sunfishcode
sunfishcode merged commit 52d5db7 into bytecodealliance:main Oct 26, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants