You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Positional writes by path drop setuid/setgid/sticky when restoring the mode after the owner-write retry #972
When a write by path is refused for permission, the VM retries with the owner-write bit set, then restores the mode. The saved mode is st.Mode().Perm(), which strips setuid, setgid and sticky. The restore therefore clears those bits.
The stat, chmod, open and restore are four separate lookups of the path. If the path is swapped between them, the write or the restored mode can land on another file, or u+w can be left behind. Swapping in a FIFO blocks the O_WRONLY open forever. This needs write access to the directory, and the README already documents the path model.
Hardening: open first, then fstat the handle and compare it with os.SameFile. Use f.Chmod on the handle instead of os.Chmod on the path, and save the full Mode() & (ModePerm|ModeSetuid|ModeSetgid|ModeSticky).
Fix
Save and restore the full mode, including the special bits. Add a test row with 0o1444, and one with 0o4755 where the platform allows it.
Prior art: priorart "pwrite pread huge offset overflow slice bounds" at 2026-11-21 20:43 CET reported prior art; checked: priorart 'pwrite chmod setuid sticky mode restore': 155 hits, none on special-bit loss; nearest are the pwrite path changes themselves (#970, #949, #971)
Activity