开发者

Setting protection bits for the whole address space

开发者 https://www.devze.com 2023-04-07 12:22 出处:网络
OK, what I want to do here is to only give read access to all the pages in an address space in Linux. Whenever a page would be written, I will give write access to it in a SIGSEGV signal handler. For

OK, what I want to do here is to only give read access to all the pages in an address space in Linux. Whenever a page would be written, I will give write access to it in a SIGSEGV signal handler. For 32 bit, this is easy as the address space is of only 4GB, therefore it wouldn't take alot of time to set bits for each page, but how do I approach this problem for a 64 bit process as the address space is almost infinite in this case.

Its no problem for me if I limit the address space size with ulimi开发者_StackOverflow社区t -v, but people told me the address would not be linear. Now my head is aching thinking how can I solve this problem. Any help in this regard would be highly appreciated. Please tell me the most efficient way possible to set read access of all pages for a 64 bit program.


To avoid protecting the entire address space, only protect the pages in use. And, trap the system calls that change the address space (mmap, brk, possibly thread creation, etc) so you can protect those pages.

Note that your signal handler cannot run without being able to write to its stack (nor being able to execute its code), so there are some fundamental problems beyond just 64-bits being large.

0

精彩评论

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

关注公众号