开发者

Alternatives to mprotect()

The mprotect 开发者_如何学Pythonsyscall protects the memory area within page boundary:

int mprotect(void *addr, size_t len, int prot);

Here len should be multiple of pagesize.

Is there any way to protect only a few consecutive addresses, which are not aligned to page boundary i.e. len < pagesize ?


I wouldn't think so, no. The limitation is because the MMU has hardware limits on how fine a granularity it can control. There are tables that hold the access restrictions and you can't have a table slot for each byte; the table itself would use all your RAM. So instead it's made more coarse, with table entries for each page.

You might be able to do something using Valgrind, if you're on Linux.


No, there isn't. The virtual memory system of your OS only operates on the page level, nothing smaller than that.


I think the below link is what U would expect, but U have to wait for it to release.

https://software.intel.com/en-us/blogs/2013/07/22/intel-memory-protection-extensions-intel-mpx-support-in-the-gnu-toolchain

"MPX —— Intel® Memory Protection Extensions" is what all C++ programmers want. I am very looking forward to it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜