Commit 970ab72
committed
ch04: kernel panic when openning
proc_create returns non-null pointer but open generates null-pointer
panic.
I checked the panic address. That is a code calling open.
/ # insmod share/rust_proc.ko
[ 22.202776] rust_proc: module verification failed: signature and/or required key missing - tainting kernel
[ 22.204453] rust_proc: rust_proc is loaded
[ 22.205103] rust_proc: succeeded to create a proc entry: 0xffff8880054696c0
/ # cat /proc/rust_demo/rust_proc_fs
[ 26.663960] kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
[ 26.665132] BUG: unable to handle page fault for address: ffff888005492a00
[ 26.666141] #PF: supervisor instruction fetch in kernel mode
[ 26.666674] #PF: error_code(0x0011) - permissions violation
[ 26.666674] PGD 3a01067 P4D 3a01067 PUD 3a02067 PMD 80000000054001e3
[ 26.666674] Oops: 0011 [#1] PREEMPT SMP NOPTI
[ 26.666674] CPU: 0 PID: 120 Comm: cat Tainted: G E 6.3.0+ Rust-for-Linux#18
[ 26.666674] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[ 26.666674] RIP: 0010:0xffff888005492a00
[ 26.666674] Code: 00 00 60 11 e0 81 ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08
[ 26.666674] RSP: 0018:ffff8880056c7e00 EFLAGS: 00010286
[ 26.666674] RAX: ffff8880056c7918 RBX: 0000000000000000 RCX: ffff8880056c7ef0
[ 26.666674] RDX: 0000000000001000 RSI: 00007ffc8b3ba048 RDI: ffff888005721400
[ 26.666674] RBP: ffff8880056c7e48 R08: 00007ffc8b3ba048 R09: 0000000000000000
[ 26.666674] R10: 0000000000000000 R11: ffff888005492a00 R12: ffff8880054696c0
[ 26.666674] R13: ffff888005721400 R14: 0000000000000001 R15: 0000000000000000
[ 26.666674] FS: 000000000249a3c0(0000) GS:ffff888007a00000(0000) knlGS:0000000000000000
[ 26.666674] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 26.666674] CR2: ffff888005492a00 CR3: 00000000054c6000 CR4: 00000000000006f0
[ 26.666674] Call Trace:
[ 26.666674] <TASK>
[ 26.666674] ? proc_reg_read+0xe8/0x150
[ 26.666674] vfs_read+0xb4/0x260
[ 26.666674] ? do_sendfile+0x1cf/0x3f0
[ 26.666674] ksys_read+0x5f/0xb0
[ 26.666674] __x64_sys_read+0x1b/0x20
[ 26.666674] do_syscall_64+0x35/0x50
[ 26.666674] entry_SYSCALL_64_after_hwframe+0x63/0xcd
[ 26.666674] RIP: 0033:0x4ad272
[ 26.666674] Code: 31 c0 e9 b1 fe ff ff 50 48 8d 3d c1 80 17 00 e8 54 8e 00 00 0f 1f 40 00 f3 0f 1e fa 64 8b 04 25 18 00 00 04
[ 26.666674] RSP: 002b:00007ffc8b3b9fe8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 26.666674] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00000000004ad272
[ 26.666674] RDX: 0000000000001000 RSI: 00007ffc8b3ba048 RDI: 0000000000000003
[ 26.666674] RBP: 00007ffc8b3ba048 R08: 0000000000000001 R09: 0000000000000000
[ 26.666674] R10: 0000000001000000 R11: 0000000000000246 R12: 0000000000001000
[ 26.666674] R13: 000000000249a3a0 R14: 0000000000000000 R15: 0000000000000001
[ 26.666674] </TASK>
[ 26.666674] Modules linked in: rust_proc(E)
[ 26.666674] CR2: ffff888005492a00
[ 26.666674] ---[ end trace 0000000000000000 ]---
[ 26.666674] RIP: 0010:0xffff888005492a00
[ 26.666674] Code: 00 00 60 11 e0 81 ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08
[ 26.666674] RSP: 0018:ffff8880056c7e00 EFLAGS: 00010286
[ 26.666674] RAX: ffff8880056c7918 RBX: 0000000000000000 RCX: ffff8880056c7ef0
[ 26.666674] RDX: 0000000000001000 RSI: 00007ffc8b3ba048 RDI: ffff888005721400
[ 26.666674] RBP: ffff8880056c7e48 R08: 00007ffc8b3ba048 R09: 0000000000000000
[ 26.666674] R10: 0000000000000000 R11: ffff888005492a00 R12: ffff8880054696c0
[ 26.666674] R13: ffff888005721400 R14: 0000000000000001 R15: 0000000000000000
[ 26.666674] FS: 000000000249a3c0(0000) GS:ffff888007a00000(0000) knlGS:0000000000000000
[ 26.666674] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 26.666674] CR2: ffff888005492a00 CR3: 00000000054c6000 CR4: 00000000000006f0
[ 26.666674] note: cat[120] exited with irqs disabled
Killed1 parent e77fc1d commit 970ab72
1 file changed
Lines changed: 30 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| |||
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
94 | 106 | | |
| 107 | + | |
95 | 108 | | |
96 | 109 | | |
97 | | - | |
| 110 | + | |
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
103 | 116 | | |
104 | 117 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 118 | + | |
109 | 119 | | |
110 | 120 | | |
111 | 121 | | |
| |||
0 commit comments