Repository navigation
fix(libkernel_sys): throw from fchmodat on a symbolic link as lchmod does - #14101
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
At head f0cef5ef214ee5f0978298ad18dcab70e6cff70b, lchmod now reaches the same explicit unsupported symlink-mode path as fchmodat(..., AT_SYMLINK_NOFOLLOW) on Linux and Windows, resolving the inconsistency in issue #14088.
What I ran
Reviewed head f0cef5ef214ee5f0978298ad18dcab70e6cff70b against base 16452da93473aa42d8054da95f89e44a2a1d8d97. The PR previewed cleanly against current main. Environment: Debian 12, Python 3.11.2, GCC 12.2.0.
git diff --check 16452da93473aa42d8054da95f89e44a2a1d8d97...f0cef5ef214ee5f0978298ad18dcab70e6cff70b
python3 tools/check_conventions.py --base 16452da93473aa42d8054da95f89e44a2a1d8d97 --head f0cef5ef214ee5f0978298ad18dcab70e6cff70b
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14101
gh pr checks 14101 -R boykopovar/AnyPS5Results
| Check | Result |
|---|---|
| Diff check and repository conventions | Passed |
| Dependency/merge preview | Passed |
| Hosted conventions, intake and labels | Passed |
Local guest_kernel_sys |
Not run locally; the author reports it passed on Ubuntu 24.04/GCC 13.3 |
| ABI/test-quality helper scripts | Could not run in the isolated precheck checkout because the local-only scripts are absent |
Unedited command output
All conventions checks passed.
conventions pass 19s https://github.com/boykopovar/AnyPS5/actions/runs/41232082420/job/124628223490
intake pass 20s https://github.com/boykopovar/AnyPS5/actions/runs/41232082405/job/124628222974
labels pass 8s https://github.com/boykopovar/AnyPS5/actions/runs/41232082397/job/124628223300
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.
slopgobblercobbler
left a comment
There was a problem hiding this comment.
Audited the implementation and Windows behavior:
- FreeBSD 11.4 alignment: In FreeBSD (
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. - Windows host semantics: On Windows NTFS, reparse points (
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. - Error precedence: Invalid flag combinations are caught with
EINVAL(22) and null path pointers withEFAULT(14) viaCopyPathprior to symlink inspection. - Conventions & Debt: Verified
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 lchmod and fchmodat.
|
@QW1CKS, please drop the three new |
|
Dropped in |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows build and run, since the description notes Windows was not built. Head
The changed branch decides "symbolic" from
As agreed in review, |
e7f1dce to
865b873
Compare
|
Both Windows facts are the ones the branch depends on: a compressed file that does not report |
|
Rebased onto |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-checked — new head, approved
The rebase preserves the reviewed fchmodat/lchmod implementation, 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 865b873c4bad99d6cbb23d90136382ff2f1655bf against base/current main 9090972b7e91fd266819cbd77a8b058e177b5682; 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.
git diff --check 9090972b7e91fd266819cbd77a8b058e177b5682...865b873c4bad99d6cbb23d90136382ff2f1655bf
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14101
python3 tools/check_conventions.py --base 9090972b7e91fd266819cbd77a8b058e177b5682 --head 865b873c4bad99d6cbb23d90136382ff2f1655bf
gh pr checks 14101 --repo boykopovar/AnyPS5
python3 - <<'PY'
import subprocess
commits = ['e7f1dcec9c', 'f0cef5ef214ee5f0978298ad18dcab70e6cff70b', '865b873c4bad99d6cbb23d90136382ff2f1655bf']
path = 'core/libs/prx/libkernel_sys/Export.cpp'
def body(commit, start, end):
source = subprocess.check_output(['git', 'show', f'{commit}:{path}'], text=True)
i = source.index(start)
return source[i:source.index(end, i)]
for name, start, end in [('fchmodat', 'int APS5_VABI fchmodat_nid_postfix(', 'int APS5_VABI lchmod_nid_postfix('), ('lchmod', 'int APS5_VABI lchmod_nid_postfix(', 'int APS5_VABI fchown_nid_postfix(')]:
versions = [body(commit, start, end) for commit in commits]
print(name, 'all_identical=' + str(versions[0] == versions[1] == versions[2]), 'lines=' + str(len(versions[0].splitlines())))
PYThe 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
| Check | Result | Note |
|---|---|---|
| Diff and conventions | passed | No diff errors; all convention checks passed. |
| Current-base merge preview | passed | Clean against current main. |
| Hosted conventions and labels | passed | Both completed on the reviewed head. |
Linux guest_kernel_sys |
passed | Author-reported after rebase; tested SHA not stated. |
| Windows build and focused CTest | passed | Contributor-reported at e7f1dcec9c; function bodies match this head. |
| Local build and test suite | not run | No local compilation or PR tests. |
| Repository precheck bundle | failed | Isolated snapshot lacks two workspace-only helper scripts. |
Unedited command output and test evidence
Diff check produced no output and exited 0.
All conventions checks passed.
conventions pass 37s https://github.com/boykopovar/AnyPS5/actions/runs/41520995645/job/125536668538
labels pass 12s https://github.com/boykopovar/AnyPS5/actions/runs/41520995525/job/125536666898
fchmodat all_identical=True lines=37
lchmod all_identical=True lines=8
Precheck helper errors:
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14101-865b873c4bad/head-865b873c4bad-8419fb82/tools/pr_abi_audit.py': [Errno 2] No such file or directory
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14101-865b873c4bad/head-865b873c4bad-8419fb82/tools/pr_test_quality.py': [Errno 2] No such file or directory
Windows test report at the earlier head, supplied by JJenkx in this PR comment:
- Build: clean, no new warnings in `Export.cpp`.
- `ctest -R ^guest_kernel_sys$ --repeat until-fail:3`: passes 3/3.
As agreed in review, `guest_kernel_sys` has no assertion on that throw, so this run does not exercise it.
The author reports guest_kernel_sys and check_conventions.py passing after the rebase in this PR comment; that report does not state the tested SHA.
Negative control
| Assertion | Code change | Test failed? |
|---|---|---|
| Unsupported symlink-mode calls throw on Linux/Windows | None; no assertion or local test binary exercised this branch. | Could not exercise. |
Findings
Blocking
None found in the reviewed implementation.
Non-blocking
- The new throw branch has no regression assertion. The reported Windows test explicitly says it did not exercise the throw; the author reports the Linux suite passes without an assertion for it. I reviewed the branch directly and found its error handling consistent with the documented unsupported-host behavior.
Sources
Not 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.
865b873 to
a1471ff
Compare
|
Rebased onto |
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)