Skip to content

pe: Fix PF in GRUB after memattrs call - #772

Merged
vathpela merged 1 commit into
rhboot:mainfrom
rosslagerwall:private/rossla/memattrs
Oct 1, 2026
Merged

vathpela merged 1 commit into
rhboot:mainfrom
rosslagerwall:private/rossla/memattrs

Conversation

@rosslagerwall

Copy link
Copy Markdown
Contributor

The call to update_mem_attrs() takes an aligned pointer within an allocated region but passes the entire size of the allocated region. The result is that Shim may remove execute permission from some pages belonging to GRUB causing a page fault upon returning from the LoadImage call.

@rosslagerwall

Copy link
Copy Markdown
Contributor Author

The three test failures are build errors and don't seem to be related to the change here.

@rosslagerwall
rosslagerwall force-pushed the private/rossla/memattrs branch from ccf3051 to e2fbcd2 Compare August 15, 2025 16:47
@rosslagerwall

Copy link
Copy Markdown
Contributor Author

I've updated the PR with another case that I found (and added Fixes tags).

The call to update_mem_attrs() takes an aligned pointer within an
allocated region but passes the entire size of the allocated region. The
result is that Shim may remove execute permission from some pages
belonging to GRUB causing a page fault upon returning from the LoadImage
call.

There are two cases:
* When loading the image, set the memory attributes for exactly what we
  intend to load.
* When freeing the image, be cautious and apply the edk2 workaround for
  the entire allocated region.

Fixes: 226fee2 ("PE Loader: support and require NX")
Fixes: 2f64bb9 ("loader-protocol: add workaround for EDK2 2025.02 page fault on FreePages")
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
@vathpela
vathpela force-pushed the private/rossla/memattrs branch from e2fbcd2 to 21893c1 Compare October 1, 2026 20:17
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.96%. Comparing base (dbd86c0) to head (21893c1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #772   +/-   ##
=======================================
  Coverage   58.96%   58.96%           
=======================================
  Files          24       24           
  Lines        4223     4223           
  Branches      654      654           
=======================================
  Hits         2490     2490           
  Misses       1462     1462           
  Partials      271      271           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vathpela
vathpela merged commit 4dc4a1b into rhboot:main Oct 1, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants