A buffer of a counter write, satisfied counter and address waits (one
with a negative compare) and an address write is submitted and must
complete with the write done. The debt file records that a compare
recorded as mode 7 throws when the runner here executes it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
sceKernelCallIndirectBuffer, sceKernelCallIndirectBuffer2,
sceKernelCallIndirectBuffer3, sceKernelGiveDirectMemoryToMapper and
sceKernelMapperGetParam follow firmware 13.42's libkernel_sys: the
submit calls queue the buffer on the AMM queue, the direct memory call
keeps the library's 2 MiB checks and the parameter call copies the
size and the AMM address ranges. The kernel-side checks that are not
known throw.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The firmware accepts a range whose end wraps to zero and refuses the one
just below it, which lies past the map range; the test pins both.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Firmware 13.42 accepts a PRT range whose end wraps past the top of the
address space and records only bits 14 to 40 of the size. The writers
here do the same; the test pins it and the debt entry records it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
sceKernelWriteMapCommand2, sceKernelWriteUnmapToPrtCommand,
sceKernelWriteWriteAddressCommand, sceKernelWriteWriteCounterCommand,
sceKernelWriteWaitOnAddressCommand, sceKernelWriteWaitOnCounterCommand
and sceKernelWriteEventQueueOnCompletionCommand follow the checks of
firmware 13.42's libkernel and record this project's command layout.
Without the PRT flag, sceKernelWriteMapCommand2 is
sceKernelWriteMapCommand, as on the console. The debt files record where
the existing writers' checks differ from the firmware.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without AT_SYMLINK_FOLLOW, linkat of a symbolic link threw on Windows.
CreateHardLinkW links the link's own reparse point rather than its target,
dangling or not, so it gives FreeBSD's behaviour. NTFS cannot hard-link a
directory, so a symbolic link or junction to a directory still throws there.
guest_kernel_sys now runs the symbolic link linkat checks on Windows too.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
kldstat was a NotImplemented stub. It now follows FreeBSD 11.4's
sys_kldstat (sys/kern/kern_linker.c): only the version field is read
(EFAULT when that fails), and a version other than 1056
(struct kld_file_stat_1) or 2080 (struct kld_file_stat) is EINVAL.
No linker file is listed here, as for kldnext, so every file id then
gets ENOENT and the structure is never written.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
An anonymous shm descriptor is recognised as shared memory only on
Linux, where the memfd link name is matched; on Windows the anonymous
%TEMP% object is not registered in the shared-descriptor table, so the
descriptor is not recognised and fpathconf never reaches the EOPNOTSUPP
branch. A named descriptor is recognised on both platforms, so the
check now opens a named object and unlinks it, keeping the same branch
coverage without a Linux-only assumption.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
_fpathconf_nid_postfix only treated FIFOs and sockets as descriptors without
a vnode, so a kqueue or shm_open descriptor fell through to the UFS constants
(LINK_MAX 32767, NAME_MAX 255, PIPE_BUF 512). FreeBSD 11.4 kern_fpathconf
(kern_descrip.c:1411-1429) answers _PC_ASYNC_IO for every descriptor and
returns EOPNOTSUPP for a no-vnode descriptor that is not a pipe or socket.
Return EOPNOTSUPP for kqueue and shared-memory descriptors.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Follow FreeBSD 11.4 sys_kenv: KENV_GET, KENV_SET, KENV_UNSET and KENV_DUMP over
an in-memory kernel environment of at most 512 variables, with the 128-byte
name and value limits, ENOENT, EINVAL, ENAMETOOLONG and EFAULT.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
With symbolic links allowed on Windows, guest_kernel_sys failed at its
cleanup: MinGW's std::filesystem::remove reads links through stat, so a
dangling link looks absent and is left in place, and the check expecting
true fails. The two links are now removed with unlink_nid_postfix, which
also checks that guest unlink removes a live and a dangling link.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Windows branch only pinned that linkat throws for a symbolic link
without AT_SYMLINK_FOLLOW, an unsupported path. The POSIX checks of the
real behaviour and the argument and error checks stay.
Follow FreeBSD 11.4's sys_kldsym: EFAULT for an unreadable lookup
structure, EINVAL for a wrong version or command, EFAULT or
ENAMETOOLONG for the symbol name, ENOENT for a negative file id. Any
other lookup throws, as no kernel module is modelled. Adds
GuestCopyIn_nid_no_patch for the checked structure read.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
oneandonlydean's review of #8457 settled that the guest is modelled as
root, and FreeBSD 11's root keeps the privilege to change a file's
owner, so EPERM for another owner has no source until a console
measurement shows it. chown, lchown and fchownat go back to
RequireGuestOwner after the path lookup, as fchown does, and their debt
entry is main's again. The EPERM assertions go without throw assertions
in their place; the lookup error checks stay.
sigreturn applies FreeBSD 11's amd64 sys_sigreturn checks:
- EFAULT for a null context;
- EINVAL for unknown mc_flags, and for rflags bits outside
PSL_USERCHANGE that differ from the current flags;
- set_fpcontext's FPU format and ownership cases.
It then restores the context through the path setcontext uses, which
now lives in RestoreContext. A non-user %cs and an extended FPU state
still throw.
FreeBSD 11's sys_sched_setscheduler checks: a null parameter is EFAULT,
another process is ESRCH and an unknown policy is EINVAL. Pid 0 sets the
calling thread through scePthreadSetschedparam. Values that call
rejects, and the guest's own pid, whose first thread is not tracked,
still throw.
An owner or group other than the guest's (0) or the unchanged value
returns EPERM after the path lookup, as FreeBSD 11's chown(2) does for
a caller without the superuser privilege. That is the answer #8457
gives for fchown. A lookup error still comes first.
On Linux and macOS, linkat with flag 0 gives a symbolic link, a dangling
one and one naming a directory a second name: the new name reads the same
target, the link's own count is 2 and the target's is unchanged. With
AT_SYMLINK_FOLLOW the dangling link fails with ENOENT and the directory
link with EPERM. A taken destination fails with EEXIST, a missing parent
with ENOENT and a file parent with ENOTDIR. Windows still throws.
Both read their caller's structures in place before validation, so an unreadable pointer crashed the host. Copy them in with a checked read first and return EFAULT, as FreeBSD 11.4 does.
Fixes#11370
lchflags is chflags without following a symbolic link in the last path
component, as FreeBSD 11.4's sys_lchflags calls kern_chflagsat with
AT_SYMLINK_NOFOLLOW. chflags now goes through a shared helper that takes
the follow choice; a link in the last component is accepted as the
target when not following, and the flag checks are unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Match the AT_REMOVEDIR and rmdir sites so file reparse points stay on the old unlink path. Cover file symlink unlinkat on Windows and point the debt at the drive-target consumers.
FreeBSD 11.4's kern_settimeofday rejects a timeval with a microsecond
field outside 0 to 999999 or a negative second field with EINVAL before
changing anything, sets the clock from a valid timeval, and then stores
the timezone, which gettimeofday reports. settimeofday now checks the
timeval the same way and throws for a valid one, as clock_settime does,
because the host clock is not changed. A timezone given without a
timeval is stored and gettimeofday reports it instead of 0 and 0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>