Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我真的在寻找任何解决方案——我的目标是将一个小于系统页面大小的区域设置为 PROT_READ、PROT_WRITE、PROT_EXEC 或 PROT_NONE。这可能吗?似乎 mprotect 只是保护页面大小的倍数......
如果不可能,这种设计选择的原因是什么?
这通常是不可能的。
保护属性设置在 CPU 的页表中,因此这是 CPU 设计决策。
如果您只需要对一个特定区域进行此子页面保护,我相信有办法设置硬件内存访问断点,如果该区域被访问,它将触发。