劫持页面错误处理程序

发布于 2025-01-17 00:38:57 字数 243 浏览 6 评论 0原文

我有一个进程 PID 访问了不允许访问的内存区域,CPU 在内核中创建了一个陷阱,该陷阱调用 do_page_fault() ,它将向用户进程发送 SIGSEGV。用户进程有一个自定义信号处理程序,该处理程序具有一些逻辑并且恢复错误指令。我想要做的是将这个信号处理程序逻辑移至内核空间并防止发送 SIGSEGV。 为此,我可以编写一个内核模块来劫持该 PID 的故障处理程序或其他东西吗?或者我是否必须将逻辑添加到 do_page_fault() 中?一些指导会有所帮助。

I have a process PID that access a memory region that it's not allowed to, the CPU creates a trap into the kernel which calls do_page_fault() which will send SIGSEGV to the user process. The user process has a custom signal handler that has some logic and the faulting instruction is resumed. What I want to do is to move this signal handler logic to kernel space and prevent SIGSEGV from being sent.
For that could I write a kernel module that hijacks the fault handler for this PID or something? or do I have to add my logic to do_page_fault()? Some guidance would be helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫嚣ゝ 2025-01-24 00:38:57

userfaultfd() 可能对您有用。它可以让你处理
用户模式下的页面错误。

userfaultfd() could be useful to you. It allows you to handle
page faults in usermode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文