| 1973 | |
| 1974 | = 11/21 = |
| 1975 | == check backtrace to stackmod_read == |
| 1976 | * s0711489@ubuntu-lucid64:~$ sudo insmod stackmod.ko |
| 1977 | * s0711489@ubuntu-lucid64:~$ sudo mknod /dev/stack c 251 0 |
| 1978 | * s0711489@ubuntu-lucid64:~$ cat /dev/stack |
| 1979 | * s0711489@ubuntu-lucid64:~$ tail /var/log/kern.log |
| 1980 | {{{ |
| 1981 | Nov 21 06:41:49 ubuntu-lucid64 kernel: [ 5352.251306] stackmod is loaded |
| 1982 | Nov 21 06:41:49 ubuntu-lucid64 kernel: [ 5352.251310] stackmod: 128 entry, major is 251, minor is 0 |
| 1983 | Nov 21 06:41:49 ubuntu-lucid64 kernel: [ 5352.251323] stackmod: create /proc/stackmod |
| 1984 | Nov 21 06:41:49 ubuntu-lucid64 kernel: [ 5352.251325] stackmod is added successfully |
| 1985 | Nov 21 06:42:03 ubuntu-lucid64 kernel: [ 5366.796334] stackmod is opened |
| 1986 | Nov 21 06:42:03 ubuntu-lucid64 kernel: [ 5366.796353] stackmod is read |
| 1987 | Nov 21 06:42:03 ubuntu-lucid64 kernel: [ 5366.796357] stackmod is released |
| 1988 | }}} |
| 1989 | |
| 1990 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.text |
| 1991 | {{{ |
| 1992 | 0xffffffffa0062000 |
| 1993 | }}} |
| 1994 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.data |
| 1995 | {{{ |
| 1996 | 0xffffffffa0062478 |
| 1997 | }}} |
| 1998 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.bss |
| 1999 | {{{ |
| 2000 | 0xffffffffa00626b0 |
| 2001 | }}} |
| 2002 | |
| 2003 | * gdb |
| 2004 | {{{ |
| 2005 | (gdb) file vmlinux |
| 2006 | Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/x86_64/vmlinux...(no debugging symbols found)...done. |
| 2007 | (gdb) add-symbol-file ../../04/stackmod/stackmod.o 0xffffffffa0062000 -s .data 0xffffffffa0062478 -s .bss 0xffffffffa00626b0 |
| 2008 | add symbol table from file "../../04/stackmod/stackmod.o" at |
| 2009 | .text_addr = 0xffffffffa0062000 |
| 2010 | .data_addr = 0xffffffffa0062478 |
| 2011 | .bss_addr = 0xffffffffa00626b0 |
| 2012 | (y or n) y |
| 2013 | Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.o...done. |
| 2014 | (gdb) target remote localhost:8864 |
| 2015 | Remote debugging using localhost:8864 |
| 2016 | 0xffffffff810097a9 in native_safe_halt () |
| 2017 | at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/x86_64/arch/x86/include/asm/irqflags.h:49 |
| 2018 | 49 asm volatile("sti; hlt": : :"memory"); |
| 2019 | (gdb) b stackmod_read |
| 2020 | Breakpoint 1 at 0xffffffffa0062016: file /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c, line 56. |
| 2021 | (gdb) c |
| 2022 | Continuing. |
| 2023 | }}} |
| 2024 | * s0711489@ubuntu-lucid64:~$ cat /dev/stack |
| 2025 | {{{ |
| 2026 | Breakpoint 1, stackmod_read (filep=0xffff88001efcf900, |
| 2027 | buf_user=0xde9000 <Address 0xde9000 out of bounds>, size=32768, |
| 2028 | offset=0xffff88001aecdf48) |
| 2029 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:56 |
| 2030 | 56 ) { |
| 2031 | (gdb) bt |
| 2032 | #0 stackmod_read (filep=0xffff88001efcf900, |
| 2033 | buf_user=0xde9000 <Address 0xde9000 out of bounds>, size=32768, |
| 2034 | offset=0xffff88001aecdf48) |
| 2035 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:56 |
| 2036 | #1 0xffffffff810df784 in vfs_read (file=0xffff88001efcf900, |
| 2037 | buf=0xde9000 <Address 0xde9000 out of bounds>, count=32768, |
| 2038 | pos=0xffff88001aecdf48) at fs/read_write.c:310 |
| 2039 | #2 0xffffffff810dfa2b in sys_read (fd=<value optimized out>, |
| 2040 | buf=0xde9000 <Address 0xde9000 out of bounds>, count=32768) |
| 2041 | at fs/read_write.c:400 |
| 2042 | #3 0xffffffff810029eb in ?? () |
| 2043 | #4 0x0000000000000246 in stackmod_exit () |
| 2044 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:175 |
| 2045 | Backtrace stopped: previous frame inner to this frame (corrupt stack?) |
| 2046 | }}} |
| 2047 | |
| 2048 | == implement read/write for char dev == |
| 2049 | * [http://www.mech.tohoku-gakuin.ac.jp/rde/contents/linux/drivers/chardev1.html 簡単なキャラクタデバイスをつくる] |
| 2050 | * 参考 |
| 2051 | * drivers/char/mem.c -> read_zero, write_null |
| 2052 | * access_ok |
| 2053 | * drivers/char/nvram.c -> nvram_read, nvram_write |
| 2054 | * loff_t *ppos |
| 2055 | * drivers/char/tpm/tpm.c -> tpm_read, tpm_write |
| 2056 | |
| 2057 | * s0711489@ubuntu-lucid64:~$ sudo insmod stackmod.ko |
| 2058 | {{{ |
| 2059 | Nov 21 17:33:19 ubuntu-lucid64 kernel: [ 53.780695] stackmod is loaded |
| 2060 | Nov 21 17:33:19 ubuntu-lucid64 kernel: [ 53.780699] stackmod: 128 entry, major is 251, minor is 0 |
| 2061 | Nov 21 17:33:19 ubuntu-lucid64 kernel: [ 53.780707] stackmod: create /proc/stackmod |
| 2062 | Nov 21 17:33:19 ubuntu-lucid64 kernel: [ 53.780709] stackmod is added successfully |
| 2063 | }}} |
| 2064 | |
| 2065 | * s0711489@ubuntu-lucid64:~$ sudo mknod /dev/stack c 251 0 |
| 2066 | * s0711489@ubuntu-lucid64:~$ ls -l /dev/stack |
| 2067 | * s0711489@ubuntu-lucid64:~$ sudo chmod 666 /dev/stack |
| 2068 | |
| 2069 | * s0711489@ubuntu-lucid64:~$ echo hoge > /dev/stack |
| 2070 | {{{ |
| 2071 | Nov 21 17:34:37 ubuntu-lucid64 kernel: [ 131.432249] stackmod is opened |
| 2072 | Nov 21 17:34:37 ubuntu-lucid64 kernel: [ 131.432286] stackmod is written |
| 2073 | Nov 21 17:34:37 ubuntu-lucid64 kernel: [ 131.432292] stackmod is released |
| 2074 | }}} |
| 2075 | * s0711489@ubuntu-lucid64:~$ echo fuga > /dev/stack |
| 2076 | {{{ |
| 2077 | Nov 21 17:34:50 ubuntu-lucid64 kernel: [ 144.556110] stackmod is opened |
| 2078 | Nov 21 17:34:50 ubuntu-lucid64 kernel: [ 144.556125] stackmod is written |
| 2079 | Nov 21 17:34:50 ubuntu-lucid64 kernel: [ 144.556136] stackmod is released |
| 2080 | }}} |
| 2081 | |
| 2082 | * s0711489@ubuntu-lucid64:~$ cat /dev/stack |
| 2083 | {{{ |
| 2084 | fuga |
| 2085 | ���hoge |
| 2086 | ���s0711489@ubuntu-lucid64:~$ |
| 2087 | }}} |
| 2088 | {{{ |
| 2089 | Nov 21 17:35:16 ubuntu-lucid64 kernel: [ 170.887727] stackmod is opened |
| 2090 | Nov 21 17:35:16 ubuntu-lucid64 kernel: [ 170.887745] stackmod is read |
| 2091 | Nov 21 17:35:16 ubuntu-lucid64 kernel: [ 170.887758] stackmod is read |
| 2092 | Nov 21 17:35:16 ubuntu-lucid64 kernel: [ 170.887763] stackmod is read |
| 2093 | Nov 21 17:35:16 ubuntu-lucid64 kernel: [ 170.887766] stackmod is released |
| 2094 | }}} |
| 2095 | * buggy |
| 2096 | |
| 2097 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2098 | {{{ |
| 2099 | stack: 0 |
| 2100 | }}} |
| 2101 | * s0711489@ubuntu-lucid64:~$ echo hoge > /dev/stack |
| 2102 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2103 | {{{ |
| 2104 | stack: 1 |
| 2105 | }}} |
| 2106 | * s0711489@ubuntu-lucid64:~$ echo fuga > /dev/stack |
| 2107 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2108 | {{{ |
| 2109 | stack: 2 |
| 2110 | }}} |
| 2111 | * s0711489@ubuntu-lucid64:~$ echo piyo > /dev/stack |
| 2112 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2113 | {{{ |
| 2114 | stack: 3 |
| 2115 | }}} |
| 2116 | * s0711489@ubuntu-lucid64:~$ cat /dev/stack |
| 2117 | {{{ |
| 2118 | piyo |
| 2119 | ���fuga |
| 2120 | ���hoge |
| 2121 | ���s0711489@ubuntu-lucid64:~$ |
| 2122 | }}} |
| 2123 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2124 | {{{ |
| 2125 | stack: 0 |
| 2126 | }}} |
| 2127 | |
| 2128 | === check what is bug with gdb === |
| 2129 | * s0711489@ubuntu-lucid64:~$ sudo insmod stackmod.ko |
| 2130 | * s0711489@ubuntu-lucid64:~$ sudo mknod /dev/stack c 251 0 |
| 2131 | * s0711489@ubuntu-lucid64:~$ sudo chmod 666 /dev/stack |
| 2132 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.text |
| 2133 | {{{ |
| 2134 | 0xffffffffa0056000 |
| 2135 | }}} |
| 2136 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.data |
| 2137 | {{{ |
| 2138 | 0xffffffffa0056738 |
| 2139 | }}} |
| 2140 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.bss |
| 2141 | {{{ |
| 2142 | 0xffffffffa0056970 |
| 2143 | }}} |
| 2144 | |
| 2145 | * gdb |
| 2146 | {{{ |
| 2147 | (gdb) file vmlinux |
| 2148 | Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/x86_64/vmlinux...(no debugging symbols found)...done. |
| 2149 | (gdb) add-symbol-file ../../04/stackmod/stackmod.o 0xffffffffa0056000 -s .data 0xffffffffa0056738 -s .bss 0xffffffffa0056970 |
| 2150 | add symbol table from file "../../04/stackmod/stackmod.o" at |
| 2151 | .text_addr = 0xffffffffa0056000 |
| 2152 | .data_addr = 0xffffffffa0056738 |
| 2153 | .bss_addr = 0xffffffffa0056970 |
| 2154 | (y or n) y |
| 2155 | Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.o...done. |
| 2156 | (gdb) b stackmod_proc_read |
| 2157 | Cannot access memory at address 0xffffffffa00561e0 |
| 2158 | (gdb) target remote localhost:8864 |
| 2159 | Remote debugging using localhost:8864 |
| 2160 | 0xffffffff810097a9 in native_safe_halt () |
| 2161 | at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/x86_64/arch/x86/include/asm/irqflags.h:49 |
| 2162 | 49 asm volatile("sti; hlt": : :"memory"); |
| 2163 | (gdb) b stackmod_proc_read |
| 2164 | Breakpoint 1 at 0xffffffffa00561e0: file /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c, line 137. |
| 2165 | (gdb) c |
| 2166 | Continuing. |
| 2167 | }}} |
| 2168 | |
| 2169 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2170 | {{{ |
| 2171 | stack: 0 |
| 2172 | }}} |
| 2173 | {{{ |
| 2174 | Breakpoint 1, stackmod_proc_read (page=0xffff88001f792000 "0\"y\037", |
| 2175 | start=0xffff88001b6d1e90, off=0, count=3072, eof=0xffff88001b6d1e9c, |
| 2176 | data=0x0) |
| 2177 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2178 | 137 ) { |
| 2179 | (gdb) p stack |
| 2180 | $1 = {buffer = 0xffff88001b6e5000, depth = 0, errno = 0} |
| 2181 | (gdb) p/x stack.buffer |
| 2182 | $2 = 0xffff88001b6e5000 |
| 2183 | (gdb) p/x stack.buffer[0] |
| 2184 | $3 = 0x0 |
| 2185 | (gdb) p/x stack.buffer[1] |
| 2186 | $4 = 0x0 |
| 2187 | (gdb) c |
| 2188 | Continuing. |
| 2189 | |
| 2190 | Breakpoint 1, stackmod_proc_read (page=0xffff88001f792000 "stack: 0\n", |
| 2191 | start=0xffff88001b6d1e90, off=9, count=3072, eof=0xffff88001b6d1e9c, |
| 2192 | data=0x0) |
| 2193 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2194 | 137 ) { |
| 2195 | (gdb) p/x stack.buffer |
| 2196 | $5 = 0xffff88001b6e5000 |
| 2197 | (gdb) p stack |
| 2198 | $6 = {buffer = 0xffff88001b6e5000, depth = 0, errno = 0} |
| 2199 | (gdb) p/x stack.buffer[0] |
| 2200 | $7 = 0x0 |
| 2201 | (gdb) c |
| 2202 | Continuing. |
| 2203 | }}} |
| 2204 | |
| 2205 | * s0711489@ubuntu-lucid64:~$ echo hoge > /dev/stack |
| 2206 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2207 | {{{ |
| 2208 | stack: 1 |
| 2209 | }}} |
| 2210 | {{{ |
| 2211 | Breakpoint 1, stackmod_proc_read (page=0xffff88001f7a3000 "@5z\037", |
| 2212 | start=0xffff88001b6d1e90, off=0, count=3072, eof=0xffff88001b6d1e9c, |
| 2213 | data=0x0) |
| 2214 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2215 | 137 ) { |
| 2216 | (gdb) p stack |
| 2217 | $8 = {buffer = 0xffff88001b6e5000, depth = 1, errno = 0} |
| 2218 | (gdb) p/x stack.buffer |
| 2219 | $9 = 0xffff88001b6e5000 |
| 2220 | (gdb) p/x stack.buffer[0] |
| 2221 | $10 = 0xffff880017ea1340 |
| 2222 | (gdb) p stack.buffer[0] |
| 2223 | $11 = 0xffff880017ea1340 "hoge\n\210\377\377" |
| 2224 | (gdb) p stack.buffer[1] |
| 2225 | $12 = 0x0 |
| 2226 | (gdb) bt |
| 2227 | #0 stackmod_proc_read (page=0xffff88001f7a3000 "@5z\037", |
| 2228 | start=0xffff88001b6d1e90, off=0, count=3072, eof=0xffff88001b6d1e9c, |
| 2229 | data=0x0) |
| 2230 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2231 | #1 0xffffffff811291f4 in __proc_file_read (file=<value optimized out>, |
| 2232 | buf=0x2398000 <Address 0x2398000 out of bounds>, nbytes=32768, |
| 2233 | ppos=0xffff88001b6d1f48) at fs/proc/generic.c:120 |
| 2234 | #2 proc_file_read (file=<value optimized out>, |
| 2235 | buf=0x2398000 <Address 0x2398000 out of bounds>, nbytes=32768, |
| 2236 | ppos=0xffff88001b6d1f48) at fs/proc/generic.c:201 |
| 2237 | #3 0xffffffff81124b07 in proc_reg_read (file=0xffff88001aeda840, |
| 2238 | buf=0x2398000 <Address 0x2398000 out of bounds>, count=32768, |
| 2239 | ppos=0xffff88001b6d1f48) at fs/proc/inode.c:163 |
| 2240 | #4 0xffffffff810df784 in vfs_read (file=0xffff88001aeda840, |
| 2241 | buf=0x2398000 <Address 0x2398000 out of bounds>, count=0, |
| 2242 | pos=0xffff88001b6d1f48) at fs/read_write.c:310 |
| 2243 | #5 0xffffffff810dfa2b in sys_read (fd=<value optimized out>, |
| 2244 | buf=0x2398000 <Address 0x2398000 out of bounds>, count=32768) |
| 2245 | at fs/read_write.c:400 |
| 2246 | #6 0xffffffff810029eb in ?? () |
| 2247 | #7 0x0000000000000246 in ?? () |
| 2248 | #8 0x00007fffe2db44d0 in ?? () |
| 2249 | #9 0x0000000000000000 in ?? () |
| 2250 | (gdb) c |
| 2251 | Continuing. |
| 2252 | |
| 2253 | Breakpoint 1, stackmod_proc_read (page=0xffff88001f7a3000 "stack: 1\n", |
| 2254 | start=0xffff88001b6d1e90, off=9, count=3072, eof=0xffff88001b6d1e9c, |
| 2255 | data=0x0) |
| 2256 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2257 | 137 ) { |
| 2258 | (gdb) bt |
| 2259 | #0 stackmod_proc_read (page=0xffff88001f7a3000 "stack: 1\n", |
| 2260 | start=0xffff88001b6d1e90, off=9, count=3072, eof=0xffff88001b6d1e9c, |
| 2261 | data=0x0) |
| 2262 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2263 | #1 0xffffffff811291f4 in __proc_file_read (file=<value optimized out>, |
| 2264 | buf=0x2398000 "stack: 1\n", nbytes=32768, ppos=0xffff88001b6d1f48) |
| 2265 | at fs/proc/generic.c:120 |
| 2266 | #2 proc_file_read (file=<value optimized out>, buf=0x2398000 "stack: 1\n", |
| 2267 | nbytes=32768, ppos=0xffff88001b6d1f48) at fs/proc/generic.c:201 |
| 2268 | #3 0xffffffff81124b07 in proc_reg_read (file=0xffff88001aeda840, |
| 2269 | buf=0x2398000 "stack: 1\n", count=32768, ppos=0xffff88001b6d1f48) |
| 2270 | at fs/proc/inode.c:163 |
| 2271 | #4 0xffffffff810df784 in vfs_read (file=0xffff88001aeda840, |
| 2272 | buf=0x2398000 "stack: 1\n", count=9, pos=0xffff88001b6d1f48) |
| 2273 | at fs/read_write.c:310 |
| 2274 | #5 0xffffffff810dfa2b in sys_read (fd=<value optimized out>, |
| 2275 | buf=0x2398000 "stack: 1\n", count=32768) at fs/read_write.c:400 |
| 2276 | #6 0xffffffff810029eb in ?? () |
| 2277 | #7 0x0000000000000246 in ?? () |
| 2278 | #8 0x00007fffe2db44a0 in ?? () |
| 2279 | #9 0x0000000000000000 in ?? () |
| 2280 | (gdb) c |
| 2281 | Continuing. |
| 2282 | |
| 2283 | (gdb) d |
| 2284 | Delete all breakpoints? (y or n) y |
| 2285 | (gdb) b stackmod.c:144 |
| 2286 | |
| 2287 | Breakpoint 2 at 0xffffffffa0056216: file /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c, line 144. |
| 2288 | (gdb) c |
| 2289 | Continuing. |
| 2290 | }}} |
| 2291 | |
| 2292 | * s0711489@ubuntu-lucid64:~$ echo hoge > /dev/stack |
| 2293 | * s0711489@ubuntu-lucid64:~$ echo hoge > /dev/stack |
| 2294 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2295 | {{{ |
| 2296 | stack: 3 |
| 2297 | }}} |
| 2298 | {{{ |
| 2299 | Breakpoint 2, stackmod_proc_read (page=<value optimized out>, |
| 2300 | start=<value optimized out>, off=<value optimized out>, |
| 2301 | count=<value optimized out>, eof=0xffff88001ee0de9c, |
| 2302 | data=<value optimized out>) |
| 2303 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:146 |
| 2304 | 146 } |
| 2305 | (gdb) p len |
| 2306 | No symbol "len" in current context. |
| 2307 | (gdb) p outlen |
| 2308 | $13 = <value optimized out> |
| 2309 | (gdb) p page |
| 2310 | $14 = <value optimized out> |
| 2311 | (gdb) finish |
| 2312 | Run till exit from #0 stackmod_proc_read (page=<value optimized out>, |
| 2313 | start=<value optimized out>, off=<value optimized out>, |
| 2314 | count=<value optimized out>, eof=0xffff88001ee0de9c, |
| 2315 | data=<value optimized out>) |
| 2316 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:146 |
| 2317 | __proc_file_read (file=<value optimized out>, |
| 2318 | buf=0x659000 <Address 0x659000 out of bounds>, nbytes=32768, |
| 2319 | ppos=0xffff88001ee0df48) at fs/proc/generic.c:125 |
| 2320 | 125 if (n == 0) /* end of file */ |
| 2321 | Could not fetch register "orig_rax"; remote failure reply 'E00' |
| 2322 | (gdb) c |
| 2323 | Continuing. |
| 2324 | |
| 2325 | Breakpoint 2, stackmod_proc_read (page=<value optimized out>, |
| 2326 | start=<value optimized out>, off=<value optimized out>, |
| 2327 | count=<value optimized out>, eof=0xffff88001ee0de9c, |
| 2328 | data=<value optimized out>) |
| 2329 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:146 |
| 2330 | 146 } |
| 2331 | (gdb) c |
| 2332 | Continuing. |
| 2333 | |
| 2334 | (gdb) d |
| 2335 | Delete all breakpoints? (y or n) y |
| 2336 | (gdb) b stackmod_proc_read |
| 2337 | |
| 2338 | Breakpoint 3 at 0xffffffffa00561e0: file /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c, line 137. |
| 2339 | (gdb) c |
| 2340 | Continuing. |
| 2341 | }}} |
| 2342 | |
| 2343 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2344 | {{{ |
| 2345 | stack: 3 |
| 2346 | }}} |
| 2347 | {{{ |
| 2348 | Breakpoint 3, stackmod_proc_read (page=0xffff88001f792000 "stack: 3\n", |
| 2349 | start=0xffff88001b669e90, off=0, count=3072, eof=0xffff88001b669e9c, |
| 2350 | data=0x0) |
| 2351 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2352 | 137 ) { |
| 2353 | (gdb) p outlen |
| 2354 | $15 = <value optimized out> |
| 2355 | (gdb) ret |
| 2356 | Make stackmod_proc_read return now? (y or n) y |
| 2357 | Could not fetch register "orig_rax"; remote failure reply 'E00' |
| 2358 | (gdb) c |
| 2359 | Continuing. |
| 2360 | |
| 2361 | Breakpoint 3, stackmod_proc_read (page=0xffff88001f792000 "stack: 3\n", |
| 2362 | start=0xffff88001b669e90, off=9, count=3072, eof=0xffff88001b669e9c, |
| 2363 | data=0x0) |
| 2364 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2365 | 137 ) { |
| 2366 | (gdb) c |
| 2367 | Continuing. |
| 2368 | }}} |
| 2369 | |
| 2370 | * s0711489@ubuntu-lucid64:~$ echo hoge > /dev/stack |
| 2371 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2372 | {{{ |
| 2373 | stack: 4 |
| 2374 | }}} |
| 2375 | {{{ |
| 2376 | Breakpoint 3, stackmod_proc_read (page=0xffff88001f792000 "stack: 3\n", |
| 2377 | start=0xffff88001b669e90, off=0, count=3072, eof=0xffff88001b669e9c, |
| 2378 | data=0x0) |
| 2379 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2380 | 137 ) { |
| 2381 | (gdb) p stack |
| 2382 | $16 = {buffer = 0xffff88001b6e5000, depth = 4, errno = 0} |
| 2383 | (gdb) p/x stack.buffer |
| 2384 | $17 = 0xffff88001b6e5000 |
| 2385 | (gdb) p/x stack.buffer[0] |
| 2386 | $18 = 0xffff880017ea1340 |
| 2387 | (gdb) p/x stack.buffer[4] |
| 2388 | $19 = 0x0 |
| 2389 | (gdb) p stack.buffer[0] |
| 2390 | $20 = 0xffff880017ea1340 "hoge\n\210\377\377" |
| 2391 | (gdb) p stack.buffer[1] |
| 2392 | $21 = 0xffff880017ea1640 "hoge\n\210\377\377" |
| 2393 | (gdb) p stack.buffer[2] |
| 2394 | $22 = 0xffff880017ea1200 "hoge\n\210\377\377" |
| 2395 | (gdb) p stack.buffer[3] |
| 2396 | $23 = 0xffff88001ef2cd80 "hoge\n\210\377\377\210\315\362\036" |
| 2397 | (gdb) p stack.buffer[4] |
| 2398 | $24 = 0x0 |
| 2399 | (gdb) c |
| 2400 | Continuing. |
| 2401 | |
| 2402 | Breakpoint 3, stackmod_proc_read (page=0xffff88001f792000 "stack: 4\n", |
| 2403 | start=0xffff88001b669e90, off=9, count=3072, eof=0xffff88001b669e9c, |
| 2404 | data=0x0) |
| 2405 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2406 | 137 ) { |
| 2407 | (gdb) c |
| 2408 | Continuing. |
| 2409 | }}} |
| 2410 | |
| 2411 | * s0711489@ubuntu-lucid64:~$ cat /dev/stack |
| 2412 | {{{ |
| 2413 | hoge |
| 2414 | ������hoge |
| 2415 | ���hoge |
| 2416 | ���hoge |
| 2417 | ���s0711489@ubuntu-lucid64:~$ |
| 2418 | }}} |
| 2419 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2420 | {{{ |
| 2421 | stack: 0 |
| 2422 | }}} |
| 2423 | {{{ |
| 2424 | Breakpoint 3, stackmod_proc_read (page=0xffff88001f792000 "stack: 4\n", |
| 2425 | start=0xffff88001afd5e90, off=0, count=3072, eof=0xffff88001afd5e9c, |
| 2426 | data=0x0) |
| 2427 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2428 | 137 ) { |
| 2429 | (gdb) p stack |
| 2430 | $25 = {buffer = 0xffff88001b6e5000, depth = 0, errno = 0} |
| 2431 | (gdb) p stack.buffer[0] |
| 2432 | $26 = 0x0 |
| 2433 | (gdb) p stack.buffer[3] |
| 2434 | $27 = 0x0 |
| 2435 | (gdb) c |
| 2436 | Continuing. |
| 2437 | |
| 2438 | Breakpoint 3, stackmod_proc_read (page=0xffff88001f792000 "stack: 0\n", |
| 2439 | start=0xffff88001afd5e90, off=9, count=3072, eof=0xffff88001afd5e9c, |
| 2440 | data=0x0) |
| 2441 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:137 |
| 2442 | 137 ) { |
| 2443 | (gdb) c |
| 2444 | Continuing. |
| 2445 | }}} |