Linux内核调试躺坑
偶尔要分析一下Linux内核,内核探针有时并不能满足需要(例如调试分析CVE)。采用VM虚拟机通过管道加IDA双机调试很卡,调试体验很差。用KDB也是卡,还有可能断点无效,死机也是常事。Visual Studio调试内核依然不方便,重点是卡慢。最终还是学习Google使用QEMU调试内核。(网上一大推调试文章,能用好用的并不多,我跟着一路折腾过来真把我弄得够呛。给后来人一个忠告,老老实实在开启虚拟化的Linux虚拟机中使用QEMU+gdb)
靠谱点的资料
多读牛逼人的一手资料,官方文档。每次找资料真找的我血压升高
https://www.starlab.io/blog/using-gdb-to-debug-the-linux-kernel
https://github.com/google/syzkaller/blob/master/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md
https://www.kernel.org/doc/html/latest/dev-tools/gdb-kernel-debugging.html
https://bbs.pediy.com/thread-252344.htm
http://jiayy.me/2020/05/13/qemu+gdb+kernel/
我的环境搭建过程
安装VMTool
拷贝vmare-tools-distrib到桌面。
运行sudo ./vmare-install.ph
# 修复不能从桌面拷贝的问题
sudo apt-get install open-vm-tools-desktop
修改Ubuntu源
获取Codename
lsb_release -a
将TODO替换成Codename
deb http://mirrors.aliyun.com/ubuntu/ TODO main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ TODO main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ TODO-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ TODO-security main restricted universe