fix(libkernel_sys): throw from fchmodat on a symbolic link as lchmod does #14101
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14101"
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 QW1CKS on 2026-10-31T19:00:01Z.
What
fchmodatwithAT_SYMLINK_NOFOLLOWon a symbolic link returned 0 and changed nothing on Windows and Linux, whilelchmodon the same link threw throughNotImplemented_nid_no_patch. The same unsupported operation was a fabricated success through one entry point and a throw through the other, against the rule that a path either does what it should or throws.fchmodatnow throws in that branch on the hosts whosefchmodatcannot change a link's own mode; macOS still calls the hostfchmodatas before.lchmoddrops its own symlink check and reaches the same throw throughfchmodat, as FreeBSD'ssys_lchmodforwards. Thefchmodatentry under Silent stubs indocs/dev/debt/libkernel_sys.mdis removed and both entries are cut to what is still open.Tested
Linux x86-64, Ubuntu 24.04, GCC 13.3, Release relinker-unrelated full build with
BUILD_TESTING=ON.guest_kernel_sys: passes with the change and withExport.cppreverted tomain, so the test exercises the surroundinglchmodand regular-file cases on both trees. Per review, the addedfchmodatthrow assertion was dropped: it would fail a future implementation that correctly changes the link's own mode.python3 tools/check_conventions.py --base origin/main: clean.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T19:09:43Z.
Review: APPROVED
Reviewed — looks good
At head
f0cef5ef214ee5f0978298ad18dcab70e6cff70b,lchmodnow reaches the same explicit unsupported symlink-mode path asfchmodat(..., AT_SYMLINK_NOFOLLOW)on Linux and Windows, resolving the inconsistency in issue #14088.What I ran
Reviewed head
f0cef5ef214ee5f0978298ad18dcab70e6cff70bagainst base16452da93473aa42d8054da95f89e44a2a1d8d97. The PR previewed cleanly against currentmain. Environment: Debian 12, Python 3.11.2, GCC 12.2.0.Results
guest_kernel_sysUnedited command output
Not verified
I did not independently run the C++ test or verify macOS/Windows runtime behavior or console behavior. The added symlink regression executes on Linux; the author reports the Linux test pass, and notes Windows/macOS were not run.
Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-10-31T19:13:43Z.
Review: COMMENTED
Audited the implementation and Windows behavior:
sys/kern/vfs_syscalls.c),sys_lchmodis defined directly as a forwarder tokern_fchmodat(td, AT_FDCWD, path, UIO_USERSPACE, mode, AT_SYMLINK_NOFOLLOW). Simplifying AnyPS5'slchmodto forward directly intofchmodat_nid_postfixmatches FreeBSD kernel structure and eliminates duplicated path resolution and reparse point checks.FILE_ATTRIBUTE_REPARSE_POINT) do not support independent POSIX file modes on the link object itself. Replacing the silent return 0 infchmodatwithNotImplemented_nid_no_patchremoves a fabricated success stub and ensures consistent throw semantics across both entry points on hosts without native symlink mode manipulation.EINVAL(22) and null path pointers withEFAULT(14) viaCopyPathprior to symlink inspection.python tools/check_conventions.py --base upstream/main --head HEADpasses cleanly with 0 findings, and the silent stub entry indocs/dev/debt/libkernel_sys.mdwas appropriately removed.Great cleanup that eliminates silent divergence between
lchmodandfchmodat.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T21:05:43Z.
Review: APPROVED
Re-checked — new head, approved
The rebase preserves the reviewed
fchmodat/lchmodimplementation, current conventions and labels checks pass, and the Linux test is reported passing after the rebase; I found no blocking defect.What I ran
Reviewed exact head
865b873c4bad99d6cbb23d90136382ff2f1655bfagainst base/currentmain9090972b7e91fd266819cbd77a8b058e177b5682; GitHub and the repository precheck report a clean merge preview. Environment: Debian 12 x86_64, Linux 6.1.0-54-amd64, Python 3.11.2, Git 2.39.5, GCC 12.2.0. No local build or PR test suite was run.The Windows build and test below were reported by another contributor at
e7f1dcec9c, not run by me. I compared both changed function bodies at that head, the previous reviewed head, and this head; they are identical.Results
main.guest_kernel_syse7f1dcec9c; function bodies match this head.Unedited command output and test evidence
Diff check produced no output and exited 0.
Precheck helper errors:
Windows test report at the earlier head, supplied by
JJenkxin this PR comment:The author reports
guest_kernel_sysandcheck_conventions.pypassing after the rebase in this PR comment; that report does not state the tested SHA.Negative control
Findings
Blocking
None found in the reviewed implementation.
Non-blocking
Sources
fchmodatandlchmodat the reviewed headsys_lchmodsourceNot verified
I did not run a local build, CTest, a negative control, macOS tests or console behavior. The Linux test result is author-reported without an exact SHA; the Windows run is contributor-reported at the earlier head, though the two changed function bodies are identical at the reviewed head.
To get this to a good state
No code change is requested. I will rerun the same review checks if the head changes.