fix(libkernel_sys): fail fchdir on a kqueue descriptor with EINVAL #9994
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9994"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-23T03:23:02Z.
What
DescriptorHasNoVnode_nid_no_patchnow also reports a kqueue descriptor (IsKqueueDescriptor) as having no vnode, sofchdiron it fails withEINVAL.guest_kernel_sysgets the case. The helper has one caller,fchdir_nid_postfix.FreeBSD 11.4
getvnode/sys_fchdir(sys/kern/vfs_syscalls.c). Found by comparing against that source, not from a title.Fixes: #9993
Tested
Head
c76ff24b4d, rebased ontomainf26434afa3;git merge-treeagainst currentmaind8db8faef5is clean. The diff is 2 files, +6/-1:DescriptorControl.cpp+2/-1 andGuestKernelSys.cpp+4. The rebase dropped exactly one hunk of the earlier headc55d6d7333: the declarationint kqueue_nid_postfix();inGuestKernelSys.cpp, whichmainnow declares in the library headers. The other hunks are unchanged.mainf26434afa3with this head (ninja exit code 0):guest_kernel_syspasses 3 of 3 runs.DescriptorControl.cpp(taken frommain, same build directory, test kept; ninja exit code 0):guest_kernel_sysfails 3 of 3 runs with exit code 0xc0000409.kernel_sys|kqueue|equeue|file_event|fchdir|chdir|descriptorhas 23 tests onmainnow (the earlier description named 16) and passes 23 of 23 with this head.check_conventions --base upstream/mainpasses./dev/null, and the new check does not depend on the host). Measured by others: jotitadev on bare-metal Linux x86_64 (Intel i7-8700, Ubuntu 26.04, kernel 7.0, glibc 2.43, GCC 15.2, Release,BUILD_TESTING=ON, full build), headc76ff24b4ddf1c7efbd28f44305d5f455c8d48b9merged ontomainabed03546:guest_kernel_syspasses 3 of 3, the 27 tests matchingkernel_sys|kqueue|equeue|file_event|fchdir|chdir|descriptorpass, and withDescriptorControl.cppfrommainand the new test keptguest_kernel_sysaborts at line 889 with guest errno 20 (review); and at the earlier headc55d6d7333(the current head only drops one local declaration from the test): jotitadev on macOS 27.2 (Apple M2 Max, x86_64 under Rosetta 2, on #8658):guest_kernel_sysfails without the fix at line 461 with guest errno 20 and passes 3 of 3 with it, and the eight related tests pass; JJenkx on Windows 11 Enterprise 22H2: the same red at line 461 without the fix, and with it the test stops later at line 840 on the existinglinksymbolic-link loop, which also fails onmain.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T03:27:16Z.
Review: APPROVED
Reviewed the exact PR diff and the corresponding current-main helper declaration/call path. The change makes kqueue descriptors fail the no-vnode predicate before the character-device placeholder can make them appear vnode-backed; the regression exercises
fchdir(kqueue())and checksEINVAL. The issue supplies FreeBSD 11.4 source basis and Windows before/after observations, and the PR reports Windows 10 red/green results (3/3 plus a 16-test related family). Theeligibility,intake,conventions,labels, andreportchecks pass; product build and runtime jobs are skipped by repository policy. I attempted the focused Linux target using the available build, but compilation stopped in unrelatedSocket/src/Udp.cppbecause/tmpis out of space, so I did not obtain an additional local test result.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T04:02:18Z.
Review: APPROVED
Reviewed the complete diff and its sole helper caller: the new predicate only adjusts the
fchdirfallback for a kqueue descriptor, returning the documented FreeBSD EINVAL case without changing unrelated descriptor classification. I also checked the uncomparable overlap report: the three other open PRs touching DescriptorControl.cpp change different helpers/regions, and the shared GuestKernelSys.cpp changes are in unrelated test sections.Exact-head local checks passed: both changed C++ translation units compiled with GCC 12.2
-std=c++20 -Wall -Wextra -Werror -fsyntax-only; conventions, test-registration audit (172 scripts), and diff check passed. Hosted eligibility, conventions, intake, labels and report checks pass; product builds are skipped. I could not run the guest test here because the host CPU does not meet the project test runtime gate. The PR reports the Windows negative control (3/3 failures before, 3/3 pass after) and a 16-test kernel/kqueue family pass.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-23T04:27:30Z.
Review: COMMENTED
macOS run, since the PR lists Linux/macOS as not run.
feat/macos-port) @81490845d2(main does not build the runtime on macOS yet), plus this PR's diff @ c55d6d7333.guest_kernel_sysKernel sys check failed at line 461 (guest errno 20)So the issue is not Windows-only: on macOS the kqueue placeholder is also a character device and
fchdir(kqueue())answersENOTDIR, as the description expects. The familykernel_sys|kqueue|equeue|file_event|fchdir|chdir|descriptor(non-agc, 8 tests) passes with the change.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T02:42:18Z.
Review: COMMENTED
First Linux run, since the description lists Linux as not run.
Bare-metal Linux x86_64: i7-8700, Ubuntu 26.04, kernel 7.0, glibc 2.43, GCC 15.2, Release,
BUILD_TESTING=ON, full build. Headc76ff24b4merged--no-commitontomainabed03546(clean).guest_kernel_sys: passes 3 of 3.kernel_sys|kqueue|equeue|file_event|fchdir|chdir|descriptor: 27 of 27 pass.DescriptorControl.cppfrommainwith the new test kept (full rebuild):guest_kernel_sysaborts withKernel sys check failed at line 889 (guest errno 20). That is the newfchdir(kqueue)check gettingENOTDIRfrom the/dev/nullplaceholder instead ofEINVAL, the same failure seen on macOS earlier. So the test catches the regression on Linux too.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:58:04Z.
Review: CHANGES_REQUESTED
Re-check — changes requested
The new Windows build report confirms that the latest head does not compile when integrated with the reported current
main:DescriptorControl.cpprefers to the renamed kqueue predicate, andGuestKernelSys.cppredeclareskqueueDescriptor. These are integration blockers despite the earlier approval and successful tests on the preceding head.Please rebase/update onto current
main, resolve both compile errors, and rerun the focused Windowsguest_kernel_systest with the negative control on the resulting exact head. The hostedwindowscheck does not compile these two affected translation units, so it does not replace that validation. I have not run a local build or test for this update.