fix(libSceGLSlimVSH): safely probe the version outputs of eglInitialize #20798

Merged
milescoviello merged 1 commit from upstream-pr/20798 into main 2026-11-15 16:44:49 +00:00
milescoviello commented 2026-11-15 15:45:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-15T15:45:17Z.


What

eglInitialize stored the version numbers straight into the guest major and minor pointers, so a non-null output pointing at unmapped or read-only memory faulted the host.

Both values now go through GuestCopyOut_nid_no_patch. A non-null output that can't be written makes the call return EGL_FALSE and set EGL_BAD_PARAMETER (0x300c). That is the code the other EGL exports in this file (eglGetConfigs, eglGetConfigAttrib, eglQuerySurface, eglQueryContext) already return for an unwritable output. The display is marked initialized only after both writes succeed. Null outputs are still skipped, and valid calls still return 1.4.

The debt entry goes in a fragment under docs/dev/debt/changes/ and marks the error code as a host-safety fallback. What the console does here is not measured.

Tested

Linux (Ubuntu 26.04.1), GCC 15.2, Release.

  • guest_glslim_query_surface: three new cases.
    • A valid call still writes 1 and 4 and leaves the error at EGL_SUCCESS.
    • An unmapped major (0x1) returns EGL_FALSE with error 0x300c.
    • A read-only minor page returns EGL_FALSE with error 0x300c.
  • guest_glslim_state, guest_glslim_eglgetconfigs and guest_glslim_ipc_returns still pass.
  • Negative control: Egl.cpp from main with the new test fails guest_glslim_query_surface.
  • tools/check_conventions.py passes on the branch and this body. tools/debt_fold.py --check passes with the fragment applied.
  • git merge-tree against main and against #14212 (the only open PR touching this library's files) is clean.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5324364398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20798). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-15T15:45:17Z. --- ### What `eglInitialize` stored the version numbers straight into the guest `major` and `minor` pointers, so a non-null output pointing at unmapped or read-only memory faulted the host. Both values now go through `GuestCopyOut_nid_no_patch`. A non-null output that can't be written makes the call return `EGL_FALSE` and set `EGL_BAD_PARAMETER` (0x300c). That is the code the other EGL exports in this file (`eglGetConfigs`, `eglGetConfigAttrib`, `eglQuerySurface`, `eglQueryContext`) already return for an unwritable output. The display is marked initialized only after both writes succeed. Null outputs are still skipped, and valid calls still return 1.4. The debt entry goes in a fragment under `docs/dev/debt/changes/` and marks the error code as a host-safety fallback. What the console does here is not measured. ### Tested Linux (Ubuntu 26.04.1), GCC 15.2, Release. - `guest_glslim_query_surface`: three new cases. - A valid call still writes 1 and 4 and leaves the error at `EGL_SUCCESS`. - An unmapped `major` (`0x1`) returns `EGL_FALSE` with error 0x300c. - A read-only `minor` page returns `EGL_FALSE` with error 0x300c. - `guest_glslim_state`, `guest_glslim_eglgetconfigs` and `guest_glslim_ipc_returns` still pass. - Negative control: `Egl.cpp` from `main` with the new test fails `guest_glslim_query_surface`. - `tools/check_conventions.py` passes on the branch and this body. `tools/debt_fold.py --check` passes with the fragment applied. - `git merge-tree` against `main` and against #14212 (the only open PR touching this library's files) is clean. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!20798
No description provided.