Repository navigation
fix(libSceFont): check fill plot guest inputs and output - #20340
oneandonlydean merged 6 commits into
Conversation
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 08ad40eb30:
- Conventions:
tools/check_conventions.pyfailed;git diff --checkclean.(pull request): error: [pr-template] Fill in the pull request template: fill Depends on with #N or none 1 findings, 1 errors; GitHub shows at most 10 error annotations, the job summary lists all - Build:
guest_font_graphics_testsbuilt cleanly. - CTest (
guest_font_graphics):1/1 Test #3281: guest_font_graphics .............. Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceFont/src/Graphics.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #3281: guest_font_graphics ..............***Exception: SegFault 0.41 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- core/libs/prx/libSceFont/src/Graphics.cpp (GraphicsFillPlotInit): Verified null/sentinel pointer handling for plot and region, confirming IsObject correctly handles nullptr and ~0ULL sentinels (flags = 2 for null region, flags = 6 for -1 region).
- core/libs/prx/libSceFont/src/Graphics.cpp (GraphicsFillPlotInit): Verified guest memory safety on invalid region handling; confirmed GuestCopyIn_nid_no_patch checks readability, preserves errno, and conditionally clears tag via CopyOutGuest with pointer overflow check (address > UINTPTR_MAX - tagOffset).
- core/libs/prx/libSceFont/src/Graphics.cpp (GraphicsFillPlotInit): Verified error precedence and return codes (FONT_GRAPHICS_ERROR_INVALID_FILL_PLOT vs FONT_GRAPHICS_ERROR_INVALID_REGION), confirming unwritable output reports INVALID_FILL_PLOT on both the invalid-region tag-clearing path and the success write-out path.
- core/libs/prx/libSceFont/src/Graphics.cpp (GraphicsFillPlotInit): Verified output construction in local stack variable value before CopyOutGuest, preventing host SIGSEGV or partial/corrupted memory writes on invalid output pointers.
- core/libs/tests/GuestFontGraphics.cpp (FillPlots): Verified unit test coverage for bad pointers (0x10), errno preservation, untouched non-tag byte verification (0xa5), and subsequent layout/mapping setter behavior.
- docs/dev/debt/libSceFont.md: Verified debt documentation accurately records the host-safety fallback policies for inaccessible guest memory in sceFontGraphicsFillPlotInit.
- Note: the AI-assisted checkbox can stay.
Requesting changes for the points above.
|
@PrivacyOnion Thank you for reviewing. I corrected the PR checklist to include the required |
…-plot-guest-pointers
…-plot-guest-pointers
|
The previous conventions failure was from the missing Depends on field; the current PR description now has ### What, ### Tested, ### Checklist and checked Depends on: none / AI-assisted: yes. Since main moved (including #20345), I merged current upstream into this separate branch normally and pushed 3d073ae. GitHub head is mergeable, local conventions/whitespace checks and Windows GCC15 Graphics.cpp plus GuestFontGraphics.cpp syntax pass, and the original source-linked sanitizer negative control is documented. New hosted checks are queued; please re-evaluate against this head. No full project CTest claim. |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 3d073aec54:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_font_graphics_testsfailed to build.ftbase.c:(.text+0x1bb7): undefined reference to `FT_Stream_Open' ftbase.c:(.text+0x24c7): undefined reference to `FT_Stream_Open' ftbase.c:(.text+0x73c8): undefined reference to `FT_Stream_Open' ftbase.c:(.text+0x74c8): undefined reference to `FT_Stream_Open' ftbase.c:(.text+0x75c8): undefined reference to `FT_Stream_Open' /usr/bin/ld: 3rdparty/freetype/libfreetype.a(ftbase.c.o):ftbase.c:(.text+0xe495): more undefined references to `FT_Stream_Open' follow ftinit.c:(.text+0x1fc): undefined reference to `FT_New_Memory' /usr/bin/ld: ftinit.c:(.text+0x23c): undefined reference to `FT_Done_Memory' ftinit.c:(.text+0x276): undefined reference to `FT_Done_Memory' collect2: error: ld returned 1 exit status - Note: the AI-assisted checkbox can stay.
Requesting changes for the points above.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the reviewed code supports merging, and the checks described by the author are not checks I ran.
What I ran
Reviewed head d4324b9111fdc1923ca7a60d9cf2c16348a0400c. No commands or tests were run. Read description.md, commits.md, manifest.json, diff.patch, README.md, and all three changed files: core/libs/prx/libSceFont/src/Graphics.cpp, core/libs/tests/GuestFontGraphics.cpp, and docs/dev/debt/changes/fix-font-fill-plot-guest.md. No changed files were excluded.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Added paths checked against surrounding helpers |
| Tests in this review | not run | Author reports targeted tests passed |
| Build and hardware checks | not run | Author reports these were not run |
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the reported sanitizer tests, syntax checks, or diff checks, and did not verify Windows runtime or PS5 hardware behavior. The claimed overlap and duplicate-fix scans were not verified.
To get this to a good state
Nothing is required.
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against d4324b9111:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_font_graphics_testsbuilt cleanly. - CTest (
guest_font_graphics):1/1 Test #3285: guest_font_graphics .............. Passed 0.07 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceFont/src/Graphics.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #3285: guest_font_graphics ..............***Exception: SegFault 1.04 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- In core/libs/prx/libSceFont/src/Graphics.cpp (GraphicsFillPlotInit), verified that bad guest region pointers are safely read through GuestCopyIn_nid_no_patch into a local guestRegion copy while preserving errno, preventing host segmentation faults on invalid addresses such as 0x10.
- Verified that when an input region is invalid or unreadable, GraphicsFillPlotInit clears only plot->tag (offset 24, 2 bytes) via CopyOutGuest with an overflow guard (address > UINTPTR_MAX - tagOffset), returning FONT_GRAPHICS_ERROR_INVALID_REGION (or FONT_GRAPHICS_ERROR_INVALID_FILL_PLOT if plot is unwritable) and leaving non-tag bytes untouched.
- Verified that null (nullptr, flags = 2) and sentinel ((void*)-1, flags = 6, layout = DefaultLayout) region handling preserves existing Orbis behavior without dereferencing region.
- Verified that full output construction for valid regions builds local value with correct mapping calculations and stores the caller's guest region pointer before writing through CopyOutGuest(plot, value), returning FONT_GRAPHICS_ERROR_INVALID_FILL_PLOT if output writing fails.
- In core/libs/tests/GuestFontGraphics.cpp (FillPlots), verified that tests exercise unwritable fill plot (0x10), unreadable region pointer (0x10), errno preservation (errno == 71), and non-tag byte preservation (AllBytes(plot, 0, 24, 0xa5) and AllBytes(plot, 26, 64, 0xa5)).
- In docs/dev/debt/changes/fix-font-fill-plot-guest.md, verified that the debt fragment adheres to the technical debt format under # libSceFont / ## add Unknown function info with zero disallowed comments in code per AGENTS.md.
- Note: the AI-assisted checkbox can stay.
Looks Good To Me
What
sceFontGraphicsFillPlotInitdereferenced a guest region through a raw pointer and wrote a 64-byte fill-plot directly into guest memory. Invalid non-null pointers (such as 0x10) crashed the host, including a damaged region pointer on an otherwise valid output.Read real region descriptors through an errno-preserving checked guest copy. Construct the complete fill-plot locally and write it through
CopyOutGuest. For an invalid region, preserve the existing behavior of clearing only the two-byte plot tag, but do so through a checked write with pointer overflow guard. Preserve null region and -1 sentinel region behavior. New inaccessible-pointer error choices are host-safety fallbacks, not a measured PS5 ABI rule.Tested
GuestFontGraphics.cppregression extended for both bad pointers and untouched fields.Checklist