Files
BearddOddity d8611d83d4 kernel: setting the end of file or allocation on a read-only handle is denied
NT's I/O manager refuses FileEndOfFileInformation and
FileAllocationInformation on a handle opened without FILE_WRITE_DATA, with
STATUS_ACCESS_DENIED, before the file system sees the call. A title that
opens a save with GENERIC_READ to load it and then calls XAPI SetEndOfFile
at the end of what it read reached the host SetEndOfFile, which failed with
err=5, logged "SetEndOfFile failed" once per file, and returned
STATUS_UNSUCCESSFUL. Allocation on such a handle returned success on
Windows and STATUS_UNSUCCESSFUL on POSIX.

All three paths (Win32 end-of-file, Win32 allocation, POSIX end-of-file and
allocation) now answer STATUS_ACCESS_DENIED for a read-only handle without
calling the host. When the granted access cannot be read, the host call
still decides. A genuine host failure now reports the granted access and
the file's path, and ERROR_ACCESS_DENIED maps to STATUS_ACCESS_DENIED.

Test: kernel_fatx_overwrite opens a 3588-byte file to read, reads it, and
sets its end of file and allocation: both STATUS_ACCESS_DENIED and the file
keeps its bytes.

Verified: kernel_fatx_overwrite, kernel_file_status, kernel_file_relative,
kernel_regressions and kernel_path pass on Windows (MSVC) and
kernel_fatx_overwrite passes on Linux x86-64 (gcc). Without this change the
new checks fail on both (status 0xC0000001 / 0).

Blast radius: NtSetInformationFile for these two information classes on a
handle without write access. A title that relied on the old success for
allocation on a read-only handle now sees the denial NT gives.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 04:22:15 -05:00
..