feat(libSceAjm.native): check the three driver queries' arguments #14226
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14226"
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 zaryabzip on 2026-11-01T00:53:58Z.
What
sceAjmInstanceGetSize,sceAjmGetFailedInstanceandsceAjmTelemetryGetLogget their argument lists and checks in libSceAjm.native. This follows @BunnyFl's firmware 13.42 run and disassembly: the module ran under an emulator after its ownsceAjmInitialize, with imports stubbed, not on a console. Argument types are inferred from register use.Which module. In 13.42 only
libSceAjm.native.sprxexports the three.libSceAjm.sprxexports 22 functions and none of these NIDs.sceAjmInitialize's NID, the control, is in both. Onmainthey were throwing stubs in libSceAjm's ownExport.cpp. The implementations live in a newsrc/DriverQueries.cpp, which only libSceAjm.native compiles. The pinned 13.60 inventory lists all three as defined exports of libSceAjm, and that module wasn't checked, so libSceAjm keeps them as throwing placeholders. They are named…_nid_disambig1, which keeps their NIDs: the convention check doesn't allow the same name in two libraries. libSceAjm's debt entry scopes the native-only finding to 13.42.What they do. Each checks its arguments, then sends one
ioctlto/dev/ajmon the context and returns the first dword of the driver's reply. AnyPS5 has no such driver, so that part throws.sceAjmInstanceGetSize(uint32_t context, uint32_t codec, uint64_t flags)0x8093000Cwhen(flags & 0x380) >= 0x180,(flags & 0x2400) == 0x2000, or any bit in0xf0000000ffffc000is set. The run rejected 0x180, 0x380, 0x2000, 0x4000, 0x8000 and1 << 60, and passed 0, 0x80, 0x17f, 0x400 and 0x2400.codecisn't checkedsceAjmGetFailedInstance(uint32_t context, void* failed)0x80930005sceAjmTelemetryGetLog(uint32_t context, uint8_t* flag, void* log)log:0x80930005;flagisn't checkedThe module reads no size table and no failure or log state of its own. So the sizes, failed instances and logs aren't modelled here. Neither is the mapping of a failed
ioctl(errno 9, 13, 19, 22 or 25 to0x80930002, others to0x80930001), because contexts aren't validated anywhere in this library. libSceAjm.native gains three functions.Test. The new
GuestAjmDriverQueries.cppresolves the three by name from libSceAjm.native, so onmainit builds and aborts because they aren't exported there. It checks every rejected flag combination for three codecs, and the null rejections, without calling a valid path, since that reaches the driver.Overlap:
git merge-treemerges this cleanly withmainand every open pull request that merges withmain.Tested
Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), with the head
803d608419merged intomaincae3edaf11.Api.hpprebuilds with no warnings, and so does each header compiled on its own.libSceAjm.native.prxexports the three;libSceAjm.prxexports none of them. Sincefbb68ec459,libSceAjm.prxexports the three_nid_disambig1placeholders, and both NID-patched modules exportCt3WeO240lw,QeaZORfh9GAandWxcje0U9LNE. At that head, onmain5bae1a4bc2, the six (Windows) and seven (WSL2)guest_ajm*/guest_offline_importstests pass, with no warnings in the changed files.ctest -R "guest_ajm|atrac9|ngs2|guest_offline_imports": 54 of 54 pass on Windows and 55 of 55 on WSL2 (guest_ajm_teardownis registered off Windows only).guest_ajm_driver_queriespasses 3 of 3 on--repeat until-fail:3.mainwith only the new test file and itsCMakeLists.txtlines, the test aborts withsceAjmInstanceGetSize is not exported by libSceAjm.native(Windows exit 0xc0000409, Linux SIGABRT).tools/check_conventions.pypasses.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-11-01T00:57:25Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The exact head
803d608419b345fc4556b05a2c2d0507decdd471has two blocking issues: it removes exports recorded for firmware 13.60, and the repository convention check fails on the debt entry.What I ran
Reviewed head
803d608419b345fc4556b05a2c2d0507decdd471against baseca96807e83496557fed7cc8ea4d2261bc7a5d7c3(main); the exact-head merge preview was clean. Environment: Linux x86_64, glibc 2.36, Python 3.11.2, GCC 12.2.0. No build or C++ tests were run locally.I also inspected the full PR diff, test registration, debt files, the PR's linked 13.42 report, and the pinned 13.60 export inventory. The local C++ test binary was not built.
Results
git diff --checkdocs/dev/debt/libSceAjm.mdentry points tolibSceAjm.native, so it belongs in that library's debt file; the same topic is already recorded there.ca96807e83496557fed7cc8ea4d2261bc7a5d7c3; no declared PR dependencies.guest_ajm_driver_queriesusing${LIBS_INCLUDE_DIR}/tests/GuestAjmDriverQueries.cpp, so the literal-path heuristic does not match it. Manual inspection confirms registration.Unedited outputs for the relevant checks
git diff --checkproduced no output and exited successfully.Conventions check:
ABI audit output for the changed symbols:
Test-quality heuristic output:
Hosted check snapshot:
Negative control
sceAjmInstanceGetSize.Findings
Blocking
libSceAjmand adds them only tolibSceAjm.native. The pinned 13.60 inventory recordssceAjmGetFailedInstance,sceAjmInstanceGetSize, andsceAjmTelemetryGetLogas defined exports oflibSceAjm; the PR's linked measurement establishes the native-only placement for 13.42 and explicitly says 13.60 was not checked. Applying the same module move globally therefore drops the recorded 13.60 import surface. Please preserve the correct module mapping for both firmware inventories, or provide evidence and version-aware export handling that makes the removal safe.docs/dev/debt/libSceAjm.md:5now describes exports fromlibSceAjm.nativeand links into that PRX, while the same finding is documented indocs/dev/debt/libSceAjm.native.md. Remove or relocate the stale entry fromlibSceAjm.mdsotools/check_conventions.pypasses.Non-blocking
Sources
bfec40deb4c47a17d7603ee2bc79aa6862c0c56b, #L26, and #L34.ca96807e83496557fed7cc8ea4d2261bc7a5d7c3.Not verified
To get this to a good state
Please retain the correct
libSceAjmexports for the 13.60 inventory and remove or relocate the misplaced duplicate debt entry. I will rerun the same checks against the new head.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T15:10:32Z.
Review: APPROVED
Approving at
fbb68ec459. I re-read the three 13.42 bodies instead of relying on my earlier note, and both of MarcZX10's blocking points from the review of803d608419look addressed. @MarcZX10, for your re-review.Firmware 13.42 (
system/common/lib/libSceAjm.native.sprx, sha2568eea270172e7ea177e69fa7865493b72131670f87afa91798d7d749ac183d5c0; read from disassembly, not run on a console):sceAjmInstanceGetSize(QeaZORfh9GA): On a negative result it returns before the driver (jsat0xd8a). Otherwise it sends ioctl0xc028890don the context (0xd90) and returns the reply's first dword (0xdaa).DriverQueries.cpphas the same three conditions in the same form.sceAjmGetFailedInstance(Ct3WeO240lw):test %rsi,%rsiat0x1393, so a null second argument gives0x80930005(0x13b8) before ioctl0xc0288965.sceAjmTelemetryGetLog(Wxcje0U9LNE): only the third argument is tested (test %rdx,%rdxat0x1479, null gives0x80930005). After a successful ioctl0xc0288990it stores a byte through the second argument without a null check (mov %al,(%rbx)at0x149d). That matches the debt entry's "flagisn't checked" and the PR's test, which expectsflaguntouched on the null-log path.libSceAjm.native.sprx, not inlibSceAjm.sprxorlibSceAjmi.sprx(objdump -T, defined entries).MarcZX10's points:
main, both patched modules exportCt3WeO240lw,QeaZORfh9GAandWxcje0U9LNE.libSceAjm.prxexports them through the_nid_disambig1placeholders;libSceAjm.native.prxexports the checked implementations.tools/check_conventions.py --base upstream/mainon the merge: "All conventions checks passed."What I ran (Windows 11, WinLibs GCC 15.2.0, Release, this head merged onto
upstream/main4f41f4c375):guest_ajm*,ajm*andatrac9*tests, 7 of 7 pass, including the newguest_ajm_driver_queries.Mutation checks on the merge, one at a time, rebuilding each time. Each mutant makes the new test fail; the failure output names the throwing driver path (
what(): <function>: the request to the AJM driver):(flags & 0x380u) >= 0x180uchanged to>= 0x380u;if (!failed) returnchanged toif (false) return;if (!log) returnchanged toif (false) return.No negative control on
main: the test resolves the three names fromlibSceAjm.native, which doesn't export them there.Non-blocking, for whoever takes the next step: the same module defines one more query of this shape,
KWoxiB9bVmA. Its NID is the hash ofsceAjmTelemetryClearLog. Its 13.42 body at0x1520takes only the context, sends ioctl0xc0288991, and returns the reply's first dword, with the same errno mapping as these three (0x1550-0x15aa). It's not declared in the repo; I'll leave it out of this PR.