fix(libc): return EFAULT from getifaddrs for an unwritable list store #13804
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13804"
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 DeveshB-1 on 2026-10-31T07:24:58Z.
What
Safely copy out the allocated interface list in
getifaddrsusingGuestCopyOut_nid_no_patch, returning-1witherrnoset toEFAULT(14) and releasing the allocated memory if the output store is unwritable.Tested
ctest --test-dir build -R guest_interface --repeat until-fail:3 -V(passed 3/3).reinterpret_cast<GuestInterfaceAddress**>(0x10)) crashes withSIGSEGVon unmodifiedmain, and cleanly returns-1witherrno = 14(EFAULT) with this fix.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)Summary by CodeRabbit
getifaddrsnow reports an error when it cannot write the result to the requested memory, rather than returning an invalid result.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T07:27:44Z.
Review: APPROVED
Reviewed — looks good
The change uses the checked guest-memory copy for both empty and populated results, returns
EFAULTfor an unwritable output, and releases the allocated list on copy failure.Reviewed head
3fdc8a144fce9fb26973e12431fe4c9c8a3d1f8dagainst base828ac0b2ae74aac181ba128fb59b08a1534f2041. On Linux x86_64 with Python 3.11 and GCC 12.2, I ranpython3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13804(diff, conventions/template and dependency/mergeability passed; the isolated ABI/test-quality helpers were unavailable),python3 tools/pr_abi_audit.py --base 828ac0b2ae74aac181ba128fb59b08a1534f2041 --head 3fdc8a144fce9fb26973e12431fe4c9c8a3d1f8d(passed), andgit diff --check 828ac0b2ae74aac181ba128fb59b08a1534f2041...3fdc8a144fce9fb26973e12431fe4c9c8a3d1f8d(passed). The test-quality heuristic warned about registration; exact-headlibc/CMakeLists.txtregistersGuestInterfaces.cppasguest_interfaces. The PR body reportsctest --test-dir build -R guest_interface --repeat until-fail:3 -Vpassing 3/3 and a negative control onmain; I did not reproduce them, and the tested SHA is not stated. No local build or test was run. At the latest CI refresh, eligibility and intake passed, library-portability/report were in progress, and conventions, Windows, and specialized jobs were queued; Linux was skipped. The output-copy paths are visible in Interfaces.cpp, and the invalid-pointer assertion is in GuestInterfaces.cpp.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T03:43:25Z.
Review: APPROVED
Re-checked — new head, looks good
The new head frees the allocated guest list if output publication throws, resolving the cleanup issue noted in the earlier review.
What I ran
Reviewed exact head
d0de4c03c726cc27a13e9a4e29733ec55faa30a6on PR base3943473a50302cd1ed4ea1cac6a66af3f6f4f909; the local merge preview against currentmain5d3ad2112f60f35d463dc2c9d96d1c9d35871015was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or compile locally.Results
main5d3ad2112f60f35d463dc2c9d96d1c9d35871015.guest_interfacespassed 5/5 on Windows at this head and that revertingInterfaces.cpptomainmade it fail 5/5. This is author-provided evidence, not a run I performed.Raw precheck output
Negative control
guest_interfacesrejects an unwritable output storeInterfaces.cpptomainwhile retaining the PR testFindings
Blocking: None found in the reviewed change.
Non-blocking: The two macOS write-watch jobs failed during CMake configuration. Their available annotations contain only exit code 1, so I could not establish the cause from the logs; this failure does not identify a defect in the changed libc path.
Sources
Not verified
I did not build or run CTest locally. Linux CI was skipped, and the cause of the unrelated macOS write-watch configure failures was not available from the check annotations.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:42:40Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the checked output copy reports
EFAULTfor an unwritable list store and frees the allocated list when the checked copy throws.What I ran
Reviewed head
f0044b1d7edf3b41d836f8896975f6a07675465bagainst the prepared diff. I read all changed lines and the relevantGuestCopyOut_nid_no_patchimplementation and callers throughrepo_read.py. I did not run commands or tests. The Linux test and negative control are reported by the author, not run by me.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run, and console behavior for an unwritable output store has not been measured. The full repository files outside the targeted ranges were not read. The prepared review bundle included all three changed files; no changed files were excluded.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T10:28:04Z.
Review: COMMENTED
Actionable comments
8f691a8b-66d0-401e-b4b9-91bc4ec422a9Reviewing files that changed from the base of the PR and between
1965e614cband35938f9295.core/libs/prx/libc/src/Interfaces.cppcore/libs/tests/GuestInterfaces.cppdocs/dev/debt/libc.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T10:58:20Z.
Review: APPROVED
Reviewed — looks good
The checked copy-out returns
EFAULTfor an unwritable output store and releases the allocated list before returning.What I ran
Reviewed head
35938f9295f0e1095739a8b87377472ad38e6a6aagainst basemain; no merged-preview check or build was run. I inspected the changed code and theGuestCopyOut_nid_no_patchimplementation withrepo_read.py.Results
Negative control
Not run. The PR description reports that the unwritable-pointer case crashes on unmodified
mainand returnsEFAULTwith this change; I did not independently verify it.Findings
Blocking
None.
Non-blocking
None.
Sources
Interfaces.cppat the reviewed head handles empty and allocated lists with checked copy-out; on failure it setsEFAULT, and on exceptions during publication it frees the allocation before rethrowing.General.cppat the reviewed head checks destination writability and returns false for an invalid write on supported hosts.GuestInterfaces.cppat the reviewed head includes the unwritable-pointer assertion.Not verified
No build, test, or console behavior was independently verified. Read the relevant changed ranges in
core/libs/prx/libc/src/Interfaces.cpp,core/libs/tests/GuestInterfaces.cpp, anddocs/dev/debt/libc.md, plus the copy-out helper incore/libs/prx/libc/src/General.cpp.files.jsonlists no excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:16:50Z.
Review: COMMENTED
Checked the branch sources and built the focused tests against the existing Linux runtime.
GuestInterfacespassed.AI-assisted: yes.