Skip to content

fix(libkernel): reject mprotect crossing guest thread stack bounds on Windows - #4113

Closed
Feuris wants to merge 1 commit into
boykopovar:mainfrom
Feuris:fix/kernel-mprotect-stack-bound
Closed

Feuris wants to merge 1 commit into
boykopovar:mainfrom
Feuris:fix/kernel-mprotect-stack-bound

Conversation

@Feuris

@Feuris Feuris commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

What

Fixes #4088: sceKernelMprotect and mprotect accepted ranges that crossed a guest thread stack's bounds or touched the host stack margin on Windows since #3788, because the committed private memory fast path applied native protection to any unregistered host region.

  • Adds IsGuestThreadStackAllocation in Pthread to identify thread stack allocation bases on Windows.
  • Excludes thread stack allocations from the Windows committed private host memory fast path in DoMprotect.
  • Removes the GPU protection check from the in-stack handler so valid guest stack protections succeed directly.
  • Extends GuestKernelStackProtect to assert that ranges crossing stack boundaries and host margins are rejected with -1.

Closes #4088.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0: syntax and compilation verified (-fsyntax-only on modified PRX and test sources); tools/check_conventions.py --base origin/main and git diff --check pass cleanly.

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
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • 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
  • AI-assisted: yes

@Feuris

Feuris commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #4169. Glad to see the Windows test suite green again!

@Feuris Feuris closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: guest_kernel_stack_protect aborts since #3788, sceKernelMprotect accepts a range crossing a guest stack's lower bound

1 participant