构建与调试 Linux 内核

Catalogue
  1. 1. Linux Kenrel
  2. 2. Install Build
  3. 3. CP Old Config
  4. 4. Build
  5. 5. disable kaslr
  6. 6. gdb stub
  7. 7. debug

Linux Kenrel

1
2
wget http://mirrors.ustc.edu.cn/kernel.org/linux/kernel/v4.x/linux-4.19.171.tar.gz
tar -xvf linux-4.19.171.tar.gz

Install Build

1
apt-get install -y libncurses5-dev libssl-dev bison flex libelf-dev gcc make openssl libc6-dev bc

CP Old Config

1
2
3
4
cp /boot/config-4.19.0-14-amd64 .config
make oldconfig
# for debian
sed -ri '/CONFIG_SYSTEM_TRUSTED_KEYS/s/=.+/=""/g' .config

Build

1
2
3
4
5
make -j8
make bzImage
make modules
make modules_install
make install

disable kaslr

1
2
3
vim /etc/default/grub
# append nokaslr
update-grub

gdb stub

1
2
3
4
vim xxx.vmx
debugStub.listen.guest64.remote = "TRUE"
debugStub.listen.guest64 = "TRUE"
monitor.debugOnStartGuest64 = "TRUE"

debug