fix(libkernel): skip the sysctl copy-out when no bytes are copied #10921
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10921"
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 MarcZX10 on 2026-10-25T10:17:27Z.
What
CopyOutinlibkernel/System/src/SystemConfiguration.cppcalledstd::memcpy(oldValue, value, copied)with a nullvaluefor thekern.proc.envquery ({1, 14, 35, pid}), which reports no data.copiedis 0 there, but a null source pointer is undefined behavior formemcpywhatever the length, and UBSan reports it (null pointer passed as argument 2, which is declared to never be null). The copy now happens only whencopiedis not 0. Results, lengths and errno are unchanged. One commit: fix; no new test is needed because the existingCheckEnvSysctlcase already makes this exact call (output buffer non-null, length 16, no new value).Tested
Linux x86-64 (Debian 12, GCC 12), Release with ASan+UBSan. On current
main,guest_system_configurationaborts on the UBSan report above; with this change it passes (ctest -R '^guest_system_configuration$').python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/mainpass. Windows, macOS and hardware were not run.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)