Reporting Issues
Bug 3331 - Treat memory protection attributes separately
Summary: Treat memory protection attributes separately
Status: UNCONFIRMED
Alias: None
Product: EDK2
Classification: Unclassified
Component: Code (show other bugs)
Version: Current
Hardware: All All
: Lowest normal
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-12 12:34 UTC by Marvin Häuser
Modified: 2021-12-07 21:44 UTC (History)
8 users (show)

See Also:
EDK II Code First industry standard specifications: ---
Branch URL:
Release(s) the issue is observed: EDK II Master
The OS the target platform is running: ---
Package: N/A
Release(s) the issues must be fixed: EDK II Master
Tianocore documents:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marvin Häuser 2021-04-12 12:34:43 UTC
Current code, for example guarding code, asserts implications between memory protection attributes. For example, pages that are supposed to be unmapped only get marked as EFI_MEMORY_RP[1][2], as the code expects this to imply WP and NX. While it seems intuitive that excluded read permissions imply excluded execute permissions, e.g. ARM does support this[3]. Write-only pages are rare in practice, but yet again this does exist.

On the caller side, the most granular values should be passed in. For unmapped pages for example, this should be "EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP". "EFI_MEMORY_RO" in this case should be defined as "write-protected" rather than "read-only" (unfortunately the WP name is occupied by caching attributes). The architectural implementation should then deal with its own limitations to satisfy the request the best way it can, or return an error, whichever makes more sense for the attribute combination.

[1] https://github.com/tianocore/edk2/blob/2072c22a0d63c780b0cc6377f6d4ffb116ad6144/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c#L521

[2] https://github.com/tianocore/edk2/blob/2072c22a0d63c780b0cc6377f6d4ffb116ad6144/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c#L1311-L1316

[3] https://developer.arm.com/documentation/dui0471/m/embedded-software-development/execute-only-memory
Comment 1 gaoliming 2021-04-13 21:52:12 UTC
Include Jiewen and Jian for review the issue.
Comment 2 jiewen.yao 2021-04-13 21:59:34 UTC
Agree the problem statement.

Marvin, do you want to propose a solution?
Comment 3 gaoliming 2021-12-07 21:44:32 UTC
Marvin, have you any update for this issue?