-
-
Notifications
You must be signed in to change notification settings - Fork 151
feat: debug kernel stack #1176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: debug kernel stack #1176
Conversation
Signed-off-by: Godones <[email protected]>
@fslongjin 请帮我看看这段代码实现有什么错误吗?感觉没什么错误,但是无法运行 |
具体是啥问题,贴一下报错? |
固定这个位置 |
具体位置是开启中断后,我打印了中断处理信息,发现发生了几次中断,然后就结束了 |
刚才看了一下,暂时没发现问题,我明天认真看看。 |
Signed-off-by: Godones <[email protected]>
添加enable_kernel_wp函数来设置CR0的WP位,防止内核错误写入只读页面 Signed-off-by: longjin <[email protected]>
我为x86加了kernel wp的保护,现在这个机制能检测到栈溢出了。但是还存在以下问题:
|
Signed-off-by: longjin <[email protected]>
Restore accidentally deleted functions. Signed-off-by: Godones <[email protected]>
内核栈的检测只是用来debug使用,在内核稳定后应该使用原有的实现,所以分配多一倍的内存并没有太多的副作用。 |
我在想,异常处理程序里面不是有发生异常时的栈指针吗?那为啥不能traceback哈哈哈 |
使用unwind进行堆栈展开时,它的工作方式是从当前栈帧逐步向上展开的,它不能对异常处理函数进行展开 |
- 从default特性中移除kstack_protect - 为X86_64MMBootstrapInfo添加kernel_rodata_start字段 - 调整内核页标志对rodata区域的判断逻辑 Signed-off-by: longjin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在没问题了,哈哈。麻烦添加个文档~3q!
kernel/src/mm/mod.rs
Outdated
// map集合中并不会主动设置该位,需要手动设置 | ||
if vm_flags.contains(VmFlags::VM_WRITE) { | ||
ret = ret.set_write(true) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我检查了一下protection map,这个map的值貌似没问题?
https://code.dragonos.org.cn/xref/linux-6.6.21/arch/x86/mm/pgprot.c#8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: longjin <[email protected]>
目标: 检测内核栈溢出bug
实现: 在分配内核栈时手动在内核高位地址空间分配一个映射区间,同时保留一块未映射区域