Skip to content

fix(libkernel): fail madvise MADV_PROTECT with EPERM - #3795

Closed
13hourstilliland wants to merge 1 commit into
boykopovar:mainfrom
13hourstilliland:fix/madvise-protect-eperm
Closed

13hourstilliland wants to merge 1 commit into
boykopovar:mainfrom
13hourstilliland:fix/madvise-protect-eperm

Conversation

@13hourstilliland

Copy link
Copy Markdown
Contributor

What

madvise threw on MADV_PROTECT. It now fails with EPERM, as an unprivileged process does on FreeBSD 11.4. There, MADV_PROTECT is handled before the address and length checks and becomes PROC_SPROTECT. That call requires PRIV_VM_MADV_PROTECT. This keeps the same order, so an invalid range with MADV_PROTECT still gets EPERM. Whether PS5 titles hold that privilege isn't verified; it's noted in TechnicalDebt.

Tested

Linux (GCC 14.2): guest_memory checks that MADV_PROTECT returns -1 with errno 1 on a mapped page and on an out-of-range address. The test aborts on current main and passes with this change. check_conventions.py passes. Not tested with a title.

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

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Progress report (11d9c00 → 0e00e27)

📈 System libraries: 86.23% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel madvise_nid_postfix

@13hourstilliland
13hourstilliland force-pushed the fix/madvise-protect-eperm branch from 2975897 to 0e00e27 Compare October 11, 2026 22:13
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 11, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Which title calls madvise with MADV_PROTECT? With the ID and the log line where it stops on main this can go in; otherwise I'll close it until one does.

@13hourstilliland

Copy link
Copy Markdown
Contributor Author

No title: I can't give a title ID or a log line where a title calls madvise with MADV_PROTECT — the change is FreeBSD-fidelity only (the PRIV_VM_MADV_PROTECT requirement mapped to an unprivileged EPERM), with a host test showing the errno on a mapped page.

If title evidence is the bar for this kind of turn, close it until a title calls it.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Closing as agreed in the thread: @oneandonlydean asked which title calls madvise with MADV_PROTECT, and there is none, so the change has no consumer and whether PS5 titles hold PRIV_VM_MADV_PROTECT is unverified. The branch also conflicts with main now.

Feel free to reopen, rebased, once a title ID and the log line where it stops on main are available.

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

Labels

docs libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants