坚持学习,不断进取
cdxffaaaa
全部博文(69)
2011年(1)
2010年(68)
wojiuzhu
浪花小雨
qingyd
xhjdata
hu17909
yanghelo
11937341
davidxu3
zhu88120
分类: LINUX
2010-08-23 21:38:04
ssize_t faulty_write (struct file *filp, const char __user *buf, size_t count, loff_t *pos){ /* make a simple fault by dereferencing a NULL pointer */ if(count > 0x100) count = 0x100; *(int *)0 = 0; return count;}
(2)编译该模块,并且mknod /dev/faulty(3)向该模块写入数据:echo 1 > /dev/faulty, 内核OOPS,信息如下:
<1>BUG: unable to handle kernel NULL pointer dereference at virtual address 00000000printing eip:f8e8000e*pde = 00000000Oops: 0002 [#3]SMPModules linked in: faulty autofs4 hidp rfcomm l2cap ...... //此处省略若干字符CPU: 1EIP: 0060:[<f8e8000e>] Not tainted VLIEFLAGS: 00010283 (2.6.18.3 #2)EIP is at faulty_write+0xe/0x19 [faulty]eax: 00000001 ebx: f4f6ca40 ecx: 00000001 edx: b7c2d000esi: f8e80000 edi: b7c2d000 ebp: 00000001 esp: f4dc5f84ds: 007b es: 007b ss: 0068Process bash (pid: 6084, ti=f4dc5000 task=f7c8d4d0 task.ti=f4dc5000)Stack: c1065914 f4dc5fa4 f4f6ca40 fffffff7 b7c2d000 f4dc5000 c1065f06 f4dc5fa4 00000000 00000000 00000000 00000001 00000001 c1003d0b 00000001 b7c2d000 00000001 00000001 b7c2d000 bfd40aa8 ffffffda 0000007b c100007b 00000004Call Trace:[<c1065914>] vfs_write+0xa1/0x143[<c1065f06>] sys_write+0x3c/0x63[<c1003d0b>] syscall_call+0x7/0xbCode: Bad EIP value.EIP: [<f8e8000e>] faulty_write+0xe/0x19 [faulty] SS:ESP 0068:f4dc5f84
faulty.o: file format elf32-i386Disassembly of section .text:00000000 <faulty_write>: 0: 81 f9 00 01 00 00 cmp $0x100,%ecx 6: b8 00 01 00 00 mov $0x100,%eax b: 0f 46 c1 cmovbe %ecx,%eax e: c7 05 00 00 00 00 00 movl $0x0,0x0 15: 00 00 00 18: c3 ret 00000019 <cleanup_module>: 19: a1 00 00 00 00 mov 0x0,%eax 1e: ba 00 00 00 00 mov $0x0,%edx 23: e9 fc ff ff ff jmp 24 <cleanup_module+0xb>00000028 <faulty_init>: 28: a1 00 00 00 00 mov 0x0,%eax 2d: b9 00 00 00 00 mov $0x0,%ecx 32: ba 00 00 00 00 mov $0x0,%edx 37: e8 fc ff ff ff call 38 <faulty_init+0x10> 3c: 85 c0 test %eax,%eax 3e: 78 13 js 53 <faulty_init+0x2b> 40: 83 3d 00 00 00 00 00 cmpl $0x0,0x0 47: 74 03 je 4c <faulty_init+0x24> 49: 31 c0 xor %eax,%eax 4b: c3 ret 4c: a3 00 00 00 00 mov %eax,0x0 51: 31 c0 xor %eax,%eax 53: c3 ret
e: c7 05 00 00 00 00 00 movl $0x0,0x0
上一篇:Decoding Oops
下一篇:Linux内核中的一些基本编程操作
登录 注册