사용자 모드에서 Linux 커널을 시작하는 예: 커널에 .so 종속성이 없으며 LD_PRELOAD=libHookMemAlloc.so 및 종료가 작동하지 않음

사용자 모드 Linux 커널 부트 예제

페이지

커널

root_fs

긍정적인 예


uname -a
#Linux zz 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

###############################

mkdir ~/uml/; cd ~/uml/;

wget http://uml.devloop.org.uk/kernels/kernel64-4.3.5.xz
xz -d kernel64-4.3.5.xz
chmod 755 kernel64-4.3.5

wget http://fs.devloop.org.uk/filesystems/BusyBox-1.13.2/BusyBox-1.13.2-amd64-root_fs.bz
bzip2 -d BusyBox-1.13.2-amd64-root_fs.bz2

ls -lh 
#-rw-rw-r-- 1 z z 4.0M 2月  16  2012 BusyBox-1.13.2-amd64-root_fs
#-rwxr-xr-x 1 z z 101M 2月   1  2016 kernel64-4.3.5

./kernel64-4.3.5 ubda=./BusyBox-1.13.2-amd64-root_fs  mem=128M
#用户态内核正常启动 直至出现shell命令提示符
#命令提示符下输入 halt, 该用户态内核即可关机




#以下版本的:用户态内核正常启动 直至出现shell命令提示符:  
./kernel64-4.2.8 ubda=./BusyBox-1.13.2-amd64-root_fs mem=128M

./kernel64-4.1.42 ubda=./BusyBox-1.13.2-amd64-root_fs mem=128M

./kernel64-3.19.8 ubda=./BusyBox-1.13.2-amd64-root_fs mem=128M

카운터 인수

오류 예: 더 높은 버전의 커널이 있는 호스트는 더 낮은 버전의 사용자 모드 커널을 시작하지 못합니다.

uname -a
#Linux mechrev 5.19.0-42-generic #43~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 21 16:51:08 UTC 2 x86_64 x86_64 x86_64   GNU/Linux


./kernel64-4.3.5 ubda=./BusyBox-1.13.2-amd64-root_fs  mem=128M

'Core dump limits :
	soft - 0
	hard - NONE
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking environment variables for a tempdir...none found
Checking if /dev/shm is on tmpfs...OK
Checking PROT_EXEC mmap in /dev/shm...OK
Adding 29007872 bytes to physical memory to account for exec-shield gap
kmsg_dump:
<6>[    0.000000] Initializing cgroup subsys cpuset
<6>[    0.000000] Initializing cgroup subsys cpu
<6>[    0.000000] Initializing cgroup subsys cpuacct
<5>[    0.000000] Linux version 4.3.5 ([email protected]) (gcc version 4.9.3 (Gentoo 4.9.3 p1.2, pie-0.6.3) ) #4 Mon Feb 1 00:48:18 Local time zone must be set--see zic manua
<7>[    0.000000] On node 0 totalpages: 39850
<7>[    0.000000] free_area_init_node: node 0, pgdat 609551c0, node_mem_map 62c04000
<7>[    0.000000]   Normal zone: 545 pages used for memmap
<7>[    0.000000]   Normal zone: 0 pages reserved
<7>[    0.000000]   Normal zone: 39850 pages, LIFO batch:7
<7>[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
<7>[    0.000000] pcpu-alloc: [0] 0 
<6>[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 39305
<5>[    0.000000] Kernel command line: ubda=./BusyBox-1.13.2-amd64-root_fs mem=128M root=98:0
<6>[    0.000000] PID hash table entries: 1024 (order: 1, 8192 bytes)
<6>[    0.000000] Dentry cache hash table entries: 32768 (order: 6, 262144 bytes)
<6>[    0.000000] Inode-cache hash table entries: 16384 (order: 5, 131072 bytes)
<6>[    0.000000] Memory: 118472K/159400K available (6412K kernel code, 377K rwdata, 2576K rodata, 188K init, 388K bss, 40928K reserved, 0K cma-reserved)
<6>[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
<6>[    0.000000] NR_IRQS:15
<6>[    0.000000] clocksource: itimer: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
<6>[    0.080000] Calibrating delay loop... 7490.76 BogoMIPS (lpj=37453824)
<6>[    0.080000] pid_max: default: 32768 minimum: 301
<6>[    0.080000] Security Framework initialized
<6>[    0.080000] SELinux:  Initializing.
<7>[    0.080000] SELinux:  Starting in permissive mode
<6>[    0.080000] AppArmor: AppArmor disabled by boot time parameter
<6>[    0.080000] Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
<6>[    0.080000] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes)
<6>[    0.080000] Initializing cgroup subsys io
<6>[    0.080000] Initializing cgroup subsys devices
<6>[    0.080000] Initializing cgroup subsys freezer
<4>[    0.080000] 
<6>[    0.080000] Pid: 0, comm: swapper Not tainted 4.3.5
<6>[    0.080000] RIP: 0033:[<00007fb9d1954ef4>]
<6>[    0.080000] RSP: 00007fffec813570  EFLAGS: 00010246
<6>[    0.080000] RAX: 0000000000000072 RBX: 00007fffec8135d0 RCX: 0000000000000000
<6>[    0.080000] RDX: 0000000000000072 RSI: 3a303a783a746f6f RDI: 00007fffec813681
<6>[    0.080000] RBP: 00007fffec813680 R08: 00007fffec813680 R09: 0000000000000000
<6>[    0.080000] R10: 0000000000000077 R11: 0000000000000246 R12: 00007fffec813a7f
<6>[    0.080000] R13: 0000000000000400 R14: 00007fffec813680 R15: 00007fb9d17002a0
<0>[    0.080000] Kernel panic - not syncing: Segfault with no mm
<4>[    0.080000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.3.5 #4
<6>[    0.080000] Stack:
<4>[    0.080000]  7fffec8135e0 7fffec813680 7fb9d17002a0 62540850
<4>[    0.080000]  7fffec813ab0 00000400 607d6c99 7fb9d195a565
<4>[    0.080000]  00000000 00000400 7fffec8135d0 00000400
<6>[    0.080000] Call Trace:
<6>[    0.080000]  [<60635aed>] ? __getgrnam_r+0xad/0x200
<6>[    0.080000]  [<60612d4d>] ? grantpt+0x20d/0x240
<6>[    0.080000]  [<6060fc0c>] ? __isatty+0xc/0x20
<6>[    0.080000]  [<60612eef>] ? __ptsname_internal+0x11f/0x290
<6>[    0.080000]  [<60612d11>] ? grantpt+0x1d1/0x240
<6>[    0.080000] 
已放弃 (核心已转储)
'

Guess you like

Origin blog.csdn.net/hfcaoguilin/article/details/131070825