替代则mprotect() [英] Alternatives to mprotect()

查看:347
本文介绍了替代则mprotect()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在系统调用mprotect的网页保护边界内的存储区:

The mprotect syscall protects the memory area within page boundary:

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

下面 LEN 应该是多个页面大小的。

Here len should be multiple of pagesize.

有什么办法来保护只有少数几个连续的地址,这是不对齐页边界,即 LEN< PAGESIZE

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

推荐答案

我不这么认为,没有。该限制是因为 MMU 上有一个可以如何细粒度控制硬件限制。有迹象表明,持访问限制,你不能为每个字节表时隙表;表本身会使用所有的RAM。因此,而不是它是由越粗,对每个页表项。

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.

您可能能够通过做一些Valgrind的,如果你是在Linux上。

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

这篇关于替代则mprotect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆