Repository navigation
fix(libSceFont): reject an external font count whose context size overflows 32 bits - #12201
Conversation
…rflows 32 bits sceFontSupportExternalFonts sized the external font context as (fontMax << 6) | 0x20 in 32 bits. From fontMax = 0x04000000 the shift wrapped, so CreateFontContext allocated and cleared a few bytes while recording the full fontMax as max_entries. The bounds check against max_entries then never fired, and opening a font scanned the context's entries far past the allocation. Counts above 0x03ffffff are now rejected with SCE_FONT_ERROR_INVALID_PARAMETER before the context is created.
…context size 0x04000000 and 0xffffffff have to be rejected as invalid parameters, and the supported count of 4 still succeeds afterwards.
|
A Windows run, since the description lists none. Head
AI-assisted: yes (Claude Code). |
|
Results in the project's real build on Windows and Linux, with the control the description lists as not run ("Not run against the unfixed code"). Head Windows: Windows 11 Pro 26300, AMD Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7, Ninja Release,
Linux: Ubuntu 22.04 under WSL2, GCC 11.4.0, Ninja Release, on
In the merged file, line 442 is the first new check, Not tested: macOS, any title. AI-assisted (Claude Code). |
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tree also carried the open PRs #12290, #12288, #12285, #12269, #12265, #12232, #12206, #12199, #12197, #12165, #12146, all merged cleanly, so the run is a joint one; the tests of this PR are AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — Windows and Linux control results match the code, no change requested
The new check rejects a font count whose << 6 context size wraps to zero in 32 bits, and the test reports only confirm that behaviour.
What I ran
- Live head:
858eb3080e014e1c10610f93f5eddbf6e4960a38(OPEN, same as batch file). gh apiGET of issue comments, PR reviews and review comments for #12201;gh pr view --json statusCheckRollup;git -C /marc/AnyPS5 diff f1f17373… 858eb308…(PR diff against its merge base).git show 858eb308…:core/libs/prx/libSceFont/src/Library.cppand…:core/libs/tests/GuestFont.cpp(lines cited).- Nothing was built, run or merged.
Results
| Check | Result | Note |
|---|---|---|
| conventions, eligibility, intake, labels | SUCCESS | hosted |
| report | SUCCESS | hosted |
| windows | SUCCESS | hosted |
| linux, relinker, relinker-asan, register-context, write-watch | SKIPPED | not run by the hosted matrix here |
Findings
- B-Howell (2026-10-28 05:45Z) says the old code accepts the wrapping count and the fix rejects it. Checked:
Library.cpp:416now returnsSCE_FONT_ERROR_INVALID_PARAMETERwhenfontMax > (UINT32_MAX >> 6u). ForfontMax = 0x04000000,fontMax << 6is0x100000000, which wraps to 0 in 32 bits, so the check is needed. The PR diff is one line inLibrary.cppand twoRequirelines inGuestFont.cpp. - B-Howell's line number: the first new check is
GuestFont.cpp:420, not 442. The report cites line 442 "in the merged file", which is a tree with main's lines included, so the offset is expected. Not verified: that merged line 442 is the same check. - JJenkx, maskym (2026-10-28): Windows and
guest_fonttest reports, all passing, no question or change request. No reply needed. - Windows and Linux runs and the control aborts were not reproduced here.
Sources
AnyPS5/core/libs/prx/libSceFont/src/Library.cpp
Lines 415 to 417 in 858eb30
AnyPS5/core/libs/tests/GuestFont.cpp
Lines 420 to 421 in 858eb30
Not verified
- The merged-tree line 442 claim and the 10-iteration Windows and Linux
ctestresults. - The macOS and PS5 behaviour, which the PR and the reports both leave untested.
What
sceFontSupportExternalFontssized the external font context as(fontMax << 6) | 0x20in 32 bits. FromfontMax = 0x04000000the shift wraps, soCreateFontContextallocated and cleared a few bytes while recording the fullfontMaxasmax_entries. The bounds check againstmax_entries(State.cpp) then never fires, andClaimEntry/AcquireFontCtxEntryscan entries far past the allocation when a font is opened. For examplesceFontSupportExternalFonts(lib, 0x04000001, 0x52)allocates 0x60 bytes.Counts above 0x03ffffff are now rejected with
SCE_FONT_ERROR_INVALID_PARAMETERbefore the context is created.Two commits: the fix, then the test (in
GuestFont.cpp: 0x04000000 and 0xffffffff are rejected, and the supported count of 4 still succeeds afterwards).Tested
Linux x86-64, a throwaway archive build with the host CPU gate patched.
guest_fontpasses.tools/check_conventions.py --base upstream/mainandgit diff --checkpass. Not run against the unfixed code; the wrap follows from the 32-bit shift.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)