Changes between Version 2 and Version 3 of Dev/KernelHack/COINS/worklog/201111


Ignore:
Timestamp:
Nov 9, 2011 1:32:48 PM (13 years ago)
Author:
mitty
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Dev/KernelHack/COINS/worklog/201111

    v2 v3  
    7676 * define as '''static''' char !__log_buf[!__LOG_BUF_LEN] in printk.c 
    7777 * sys_clock_gettime uses copy_to_user in its code 
     78 
     79 = 11/08 = 
     80 * new_debug() が正常に動作したりしなかったりする 
     81  * 結論 -> staticで確保していなかったのが良くない 
     82 
     83 == char message[!__LOG_BUF_LEN]; == 
     84 * windell46:i386 s0711489$ ./build 
     85{{{ 
     86press enter key to make with i386 kernel 
     87 
     88Kernel: arch/x86/boot/bzImage is ready  (#6) 
     89}}} 
     90 * windell46:i386 s0711489$ make modules 
     91 
     92 * s0711489@ubuntu-lucid:~$ sudo /mnt/hgfs/tools/install.sh 
     93 
     94 * s0711489@ubuntu-lucid:~$ sudo reboot 
     95{{{ 
     96Linux ubuntu-lucid 2.6.35.14 #6 SMP Tue Nov 8 17:26:43 JST 2011 i686 GNU/Linux 
     97}}} 
     98 * windell46:~ s0711489$ scp -r .subversion/ 172.16.237.130:~ 
     99 
     100 * s0711489@ubuntu-lucid:~$ svn co https://XXXXXXXXXXXX/trunk/coursework/KernelHack/03/ 
     101{{{ 
     102Checked out revision 1387. 
     103}}} 
     104 
     105 * s0711489@ubuntu-lucid:~/03$ gcc -I /lib/modules/2.6.35.14/build/arch/x86/include/ new_debug-sys.c 
     106 * s0711489@ubuntu-lucid:~/03$ ./a.out 
     107{{{ 
     108new_debug with argv[i]: Bad address 
     109}}} 
     110 * s0711489@ubuntu-lucid:~/03$ ./a.out 1 2 
     111{{{ 
     112new_debug with argv[i]: Bad address 
     113new_debug with argv[i]: Bad address 
     114}}} 
     115 
     116 === gdb === 
     117 * viola06:i386 s0711489$ gdb 
     118{{{ 
     119 
     120(gdb) file vmlinux 
     121Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/vmlinux...(no debugging symbols found)...done. 
     122(gdb) b sys_new_debug 
     123Breakpoint 1 at 0xc101d89f: file arch/x86/kernel/new_debug.c, line 9. 
     124(gdb) target remote windell46:8832 
     125Remote debugging using windell46:8832 
     1260xc1007cdf in native_safe_halt () at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/arch/x86/include/asm/irqflags.h:49 
     12749              asm volatile("sti; hlt": : :"memory"); 
     128(gdb) c 
     129Continuing. 
     130}}} 
     131 
     132 * s0711489@ubuntu-lucid:~/03$ ./a.out 1 2 
     133{{{ 
     134Breakpoint 1, sys_new_debug (message_user=0xbfc6499e "1", tp_user=0xbfc63804) at arch/x86/kernel/new_debug.c:9 
     1359       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     136(gdb) l 
     1374       #include <linux/time.h> 
     1385 
     1396       /* from kernel/printk.c */ 
     1407       #define __LOG_BUF_LEN   (1 << CONFIG_LOG_BUF_SHIFT) 
     1418 
     1429       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     14310              int errno; 
     14411              char message[__LOG_BUF_LEN]; 
     14512              struct timespec ts; 
     14613 
     147(gdb) 
     14814              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     14915                      errno = -EFAULT; 
     15016                      goto out; 
     15117              } 
     15218 
     15319              if (message == NULL) { 
     15420                      errno = -EINVAL; 
     15521                      goto out; 
     15622              } 
     15723              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     158(gdb) 
     15924                      errno = -EFAULT; 
     16025                      goto out; 
     16126              } 
     16227              message[sizeof(message) - 1] = '\0'; 
     16328 
     16429              printk(KERN_DEBUG "%s\n", message); 
     16530 
     16631              if (tp_user != NULL) { 
     16732                      sys_clock_gettime(CLOCK_REALTIME, &ts); 
     16833                      if (copy_to_user(tp_user, &ts, sizeof(ts)) != 0) { 
     169(gdb) 
     17034                              errno = -EFAULT; 
     17135                              goto out; 
     17236                      } 
     17337              } 
     17438 
     17539              errno = 0; 
     17640 
     17741      out: 
     17842              return errno; 
     17943      } 
     180(gdb) 
     181Line number 44 out of range; arch/x86/kernel/new_debug.c has 43 lines. 
     182(gdb) s 
     18314              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     184(gdb) 
     18541      out: 
     186(gdb) 
     18743      } 
     188(gdb) p errno 
     189$1 = -14 
     190(gdb) finish 
     191Run till exit from #0  sys_new_debug (message_user=0xbfc6499e "1", tp_user=0xbfc63804) at arch/x86/kernel/new_debug.c:43 
     1920xc100288c in ?? () 
     193Value returned is $2 = -14 
     194(gdb) c 
     195Continuing. 
     196 
     197Breakpoint 1, sys_new_debug (message_user=0xbfc649a0 "2", tp_user=0xbfc63804) at arch/x86/kernel/new_debug.c:9 
     1989       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     199(gdb) s 
     20014              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     201(gdb) 
     20241      out: 
     203(gdb) finish 
     204Run till exit from #0  sys_new_debug (message_user=0xbfc649a0 "2", tp_user=0xbfc63804) at arch/x86/kernel/new_debug.c:41 
     2050xc100288c in ?? () 
     206Value returned is $3 = -14 
     207(gdb) c 
     208Continuing. 
     209}}} 
     210  * s0711489@ubuntu-lucid:~/03$ ./a.out 1 2 
     211{{{ 
     212new_debug with argv[i]: Bad address 
     213new_debug with argv[i]: Bad address 
     214}}} 
     215 
     216 * s0711489@ubuntu-lucid:~/03$ ./a.out 
     217{{{ 
     218(gdb) file vmlinux 
     219Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/vmlinux...(no debugging symbols found)...done. 
     220(gdb) b sys_new_debug 
     221Breakpoint 1 at 0xc101d89f: file arch/x86/kernel/new_debug.c, line 9. 
     222(gdb) target remote windell46:8832 
     223Remote debugging using windell46:8832 
     2240xc1007cdf in native_safe_halt () at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/arch/x86/include/asm/irqflags.h:49 
     22549              asm volatile("sti; hlt": : :"memory"); 
     226(gdb) c 
     227Continuing. 
     228 
     229Breakpoint 1, sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:9 
     2309       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     231(gdb) l 
     2324       #include <linux/time.h> 
     2335 
     2346       /* from kernel/printk.c */ 
     2357       #define __LOG_BUF_LEN   (1 << CONFIG_LOG_BUF_SHIFT) 
     2368 
     2379       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     23810              int errno; 
     23911              char message[__LOG_BUF_LEN]; 
     24012              struct timespec ts; 
     24113 
     242(gdb) 
     24314              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     24415                      errno = -EFAULT; 
     24516                      goto out; 
     24617              } 
     24718 
     24819              if (message == NULL) { 
     24920                      errno = -EINVAL; 
     25021                      goto out; 
     25122              } 
     25223              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     253(gdb) 
     25424                      errno = -EFAULT; 
     25525                      goto out; 
     25626              } 
     25727              message[sizeof(message) - 1] = '\0'; 
     25828 
     25929              printk(KERN_DEBUG "%s\n", message); 
     26030 
     26131              if (tp_user != NULL) { 
     26232                      sys_clock_gettime(CLOCK_REALTIME, &ts); 
     26333                      if (copy_to_user(tp_user, &ts, sizeof(ts)) != 0) { 
     264(gdb) s 
     26514              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     266(gdb) 
     26723              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     268(gdb) 
     269strncpy_from_user (dst=0xdf275f9c "", src=0x8048646 "new_debug()", count=262143) at arch/x86/lib/usercopy_32.c:114 
     270114     { 
     271(gdb) l 
     272109      * If @count is smaller than the length of the string, copies @count bytes 
     273110      * and returns @count. 
     274111      */ 
     275112     long 
     276113     strncpy_from_user(char *dst, const char __user *src, long count) 
     277114     { 
     278115             long res = -EFAULT; 
     279116             if (access_ok(VERIFY_READ, src, 1)) 
     280117                     __do_strncpy_from_user(dst, src, count, res); 
     281118             return res; 
     282(gdb) 
     283119     } 
     284120     EXPORT_SYMBOL(strncpy_from_user); 
     285121 
     286122     /* 
     287123      * Zero Userspace 
     288124      */ 
     289125 
     290126     #define __do_clear_user(addr,size)                                      \ 
     291127     do {                                                                    \ 
     292128             int __d0;                                                       \ 
     293(gdb) 
     294129             might_fault();                                                  \ 
     295130             __asm__ __volatile__(                                           \ 
     296131                     "0:     rep; stosl\n"                                   \ 
     297132                     "       movl %2,%0\n"                                   \ 
     298133                     "1:     rep; stosb\n"                                   \ 
     299134                     "2:\n"                                                  \ 
     300135                     ".section .fixup,\"ax\"\n"                              \ 
     301136                     "3:     lea 0(%2,%0,4),%0\n"                            \ 
     302137                     "       jmp 2b\n"                                       \ 
     303138                     ".previous\n"                                           \ 
     304(gdb) 
     305139                     _ASM_EXTABLE(0b,3b)                                     \ 
     306140                     _ASM_EXTABLE(1b,2b)                                     \ 
     307141                     : "=&c"(size), "=&D" (__d0)                             \ 
     308142                     : "r"(size & 3), "0"(size / 4), "1"(addr), "a"(0));     \ 
     309143     } while (0) 
     310144 
     311145     /** 
     312146      * clear_user: - Zero a block of memory in user space. 
     313147      * @to:   Destination address, in user space. 
     314148      * @n:    Number of bytes to zero. 
     315(gdb) s 
     316116             if (access_ok(VERIFY_READ, src, 1)) 
     317(gdb) 
     318119     } 
     319(gdb) p src 
     320$1 = 0x8048646 "new_debug()" 
     321(gdb) p dst 
     322$2 = 0xdf275f9c "" 
     323(gdb) p count 
     324$3 = 262143 
     325(gdb) p res 
     326$4 = -14 
     327(gdb) finish 
     328Run till exit from #0  strncpy_from_user (dst=0xdf275f9c "", src=0x8048646 "new_debug()", count=262143) at arch/x86/lib/usercopy_32.c:119 
     3290xc101d8d3 in sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:23 
     33023              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     331Value returned is $5 = -14 
     332(gdb) s 
     33341      out: 
     334(gdb) 
     33543      } 
     336(gdb) finish 
     337Run till exit from #0  sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:43 
     3380xc100288c in ?? () 
     339Value returned is $6 = -14 
     340(gdb) s 
     341Cannot find bounds of current function 
     342(gdb) c 
     343Continuing. 
     344}}} 
     345  * s0711489@ubuntu-lucid:~/03$ ./a.out 
     346{{{ 
     347new_debug with argv[i]: Bad address 
     348}}} 
     349 
     350 * s0711489@ubuntu-lucid:~/03$ ./a.out 
     351{{{ 
     352 
     353(gdb) file vmlinux 
     354Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/vmlinux...(no debugging symbols found)...done. 
     355(gdb) b sys_new_debug 
     356Breakpoint 1 at 0xc101d89f: file arch/x86/kernel/new_debug.c, line 9. 
     357(gdb) target remote windell46:8832 
     358Remote debugging using windell46:8832 
     3590xc1007cdf in native_safe_halt () at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/arch/x86/include/asm/irqflags.h:49 
     36049              asm volatile("sti; hlt": : :"memory"); 
     361(gdb) c 
     362Continuing. 
     363 
     364Breakpoint 1, sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:9 
     3659       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     366(gdb) s 
     36714              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     368(gdb) 
     36923              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     370(gdb) 
     371strncpy_from_user ( 
     372    dst=0xdc3d9f9c "\210\035i\b\250\035i\b\330\035i\b\250\270L\b\b\036i\b\030\036i\b\350\343O\b8\036i\bX\036i\bx\036i\b\270\036i\b\350\036i\b\330\036i\b\370\036i\b\b\037i\b\350\036i\b(\037i\b8\037i\bH\037i\bh\037i\b\210\037i\b\250\037i\b\350\037i\bX\021W\b\310\037i\bp\200h\b", src=0x8048646 "new_debug()", 
     373    count=262143) at arch/x86/lib/usercopy_32.c:114 
     374114     { 
     375(gdb) 
     376116             if (access_ok(VERIFY_READ, src, 1)) 
     377(gdb) 
     378119     } 
     379(gdb) finish 
     380Run till exit from #0  strncpy_from_user ( 
     381    dst=0xdc3d9f9c "\210\035i\b\250\035i\b\330\035i\b\250\270L\b\b\036i\b\030\036i\b\350\343O\b8\036i\bX\036i\bx\036i\b\270\036i\b\350\036i\b\330\036i\b\370\036i\b\b\037i\b\350\036i\b(\037i\b8\037i\bH\037i\bh\037i\b\210\037i\b\250\037i\b\350\037i\bX\021W\b\310\037i\bp\200h\b", src=0x8048646 "new_debug()", 
     382    count=262143) at arch/x86/lib/usercopy_32.c:119 
     3830xc101d8d3 in sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:23 
     38423              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     385Value returned is $1 = -14 
     386(gdb) 
     387Run till exit from #0  0xc101d8d3 in sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:23 
     3880xc100288c in ?? () 
     389Value returned is $2 = -14 
     390(gdb) 
     391Run till exit from #0  0xc100288c in ?? () 
     392}}} 
     393 
     394 * gdbでステップ実行していると、finishで関数から抜けようとした際に、以下のようにkernel panicを起こすことが多々あった[[br]][[Image(WS002510.png,33%)]][[Image(WS002511.png,33%)]] 
     395 
     396 * まれにうまく動作した場合、message[]はstaticでは無いのに前のデータが残っていることがある模様 
     397  * guest 
     398{{{ 
     399s0711489@ubuntu-lucid:~/03$ ./a.out 
     400new_debug() 
     401s0711489@ubuntu-lucid:~/03$ ./a.out 
     402}}} 
     403  * gdb 
     404{{{ 
     405Breakpoint 1, sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:9 
     4069       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     407(gdb) s 
     40814              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     409(gdb) 
     41023              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     411(gdb) 
     412strncpy_from_user (dst=0xdc569f9c "new_debug()", src=0x8048646 "new_debug()", count=262143) at arch/x86/lib/usercopy_32.c:114 
     413114     { 
     414(gdb) finish 
     415Run till exit from #0  strncpy_from_user (dst=0xdc569f9c "new_debug()", src=0x8048646 "new_debug()", count=262143) at arch/x86/lib/usercopy_32.c:114 
     416}}} 
     417  * [[Image(WS002512.png,33%)]] 
     418 
     419 == len = strnlen_user == 
     420 * vim arch/x86/kernel/new_debug.c 
     421{{{#!diff 
     422Index: arch/x86/kernel/new_debug.c 
     423=================================================================== 
     424--- arch/x86/kernel/new_debug.c (リビジョン 1381) 
     425+++ arch/x86/kernel/new_debug.c (作業コピー) 
     426@@ -10,16 +10,22 @@ 
     427         int errno; 
     428         char message[__LOG_BUF_LEN]; 
     429         struct timespec ts; 
     430+        long len = 0; 
     431          
     432         if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     433                 errno = -EFAULT; 
     434                 goto out; 
     435         } 
     436          
     437-        if (message == NULL) { 
     438+        if (message_user == NULL) { 
     439                 errno = -EINVAL; 
     440                 goto out; 
     441         } 
     442+        len = strnlen_user(message_user, __LOG_BUF_LEN); 
     443+        if (len == 0 || len > __LOG_BUF_LEN) { 
     444+                errno = -EINVAL; 
     445+                goto out; 
     446+        } 
     447         if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     448                 errno = -EFAULT; 
     449                 goto out; 
     450}}} 
     451 
     452 * windell46:i386 s0711489$ ./build 
     453{{{ 
     454Kernel: arch/x86/boot/bzImage is ready  (#7) 
     455}}} 
     456 
     457 * s0711489@ubuntu-lucid:~$ sudo reboot 
     458 
     459 * s0711489@ubuntu-lucid:~/03$ ./a.out 
     460{{{ 
     461new_debug with argv[i]: Invalid argument 
     462}}} 
     463 * s0711489@ubuntu-lucid:~/03$ ./a.out 
     464{{{ 
     465 
     466Breakpoint 1, sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:9 
     4679       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     468(gdb) s 
     46915              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     470(gdb) 
     47120              if (message_user == NULL) { 
     472(gdb) 
     47324              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     474(gdb) 
     475strnlen_user (s=0x8048646 "new_debug()", n=262144) at arch/x86/lib/usercopy_32.c:196 
     476196     { 
     477(gdb) 
     478197             unsigned long mask = -__addr_ok(s); 
     479(gdb) finish 
     480Run till exit from #0  strnlen_user (s=0x8048646 "new_debug()", n=262144) at arch/x86/lib/usercopy_32.c:197 
     481 
     482Program received signal SIGINT, Interrupt. 
     4830xc1332240 in __ticket_spin_lock () at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/arch/x86/include/asm/spinlock.h:65 
     48465              asm volatile ( 
     485(gdb) detach 
     486Ending remote debugging. 
     487}}} 
     488  * [[Image(WS002515.png,33%)]] 
     489 
     490 == !__LOG_BUF_LEN      1024 == 
     491 * vim arch/x86/kernel/new_debug.c 
     492{{{#!diff 
     493Index: arch/x86/kernel/new_debug.c 
     494=================================================================== 
     495--- arch/x86/kernel/new_debug.c (リビジョン 1388) 
     496+++ arch/x86/kernel/new_debug.c (作業コピー) 
     497@@ -4,7 +4,7 @@ 
     498 #include <linux/time.h> 
     499  
     500 /* from kernel/printk.c */ 
     501-#define __LOG_BUF_LEN  (1 << CONFIG_LOG_BUF_SHIFT) 
     502+#define __LOG_BUF_LEN  1024 
     503  
     504 SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     505         int errno; 
     506}}} 
     507 
     508 * windell46:i386 s0711489$ ./build 
     509{{{ 
     510Kernel: arch/x86/boot/bzImage is ready  (#8) 
     511}}} 
     512 
     513 * windell46:i386 s0711489$ make modules 
     514 
     515 * s0711489@ubuntu-lucid:~$ sudo /mnt/hgfs/tools/install.sh 
     516 
     517 * gdb 
     518{{{ 
     519(gdb) file vmlinux 
     520Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/vmlinux...(no debugging symbols found)...done. 
     521(gdb) b sys_new_debug 
     522Breakpoint 1 at 0xc101d8a0: file arch/x86/kernel/new_debug.c, line 9. 
     523(gdb) target remote windell46:8832 
     524Remote debugging using windell46:8832 
     5250xc1007cdf in native_safe_halt () at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/arch/x86/include/asm/irqflags.h:49 
     52649              asm volatile("sti; hlt": : :"memory"); 
     527(gdb) c 
     528Continuing. 
     529 
     530Breakpoint 1, sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:9 
     5319       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     532(gdb) l 
     5334       #include <linux/time.h> 
     5345 
     5356       /* from kernel/printk.c */ 
     5367       #define __LOG_BUF_LEN   1024 
     5378 
     5389       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     53910              int errno; 
     54011              char message[__LOG_BUF_LEN]; 
     54112              struct timespec ts; 
     54213              long len = 0; 
     543(gdb) 
     54414 
     54515              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     54616                      errno = -EFAULT; 
     54717                      goto out; 
     54818              } 
     54919 
     55020              if (message_user == NULL) { 
     55121                      errno = -EINVAL; 
     55222                      goto out; 
     55323              } 
     554(gdb) 
     55524              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     55625              if (len == 0 || len > __LOG_BUF_LEN) { 
     55726                      errno = -EINVAL; 
     55827                      goto out; 
     55928              } 
     56029              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     56130                      errno = -EFAULT; 
     56231                      goto out; 
     56332              } 
     56433              message[sizeof(message) - 1] = '\0'; 
     565(gdb) 
     56634 
     56735              printk(KERN_DEBUG "%s\n", message); 
     56836 
     56937              if (tp_user != NULL) { 
     57038                      sys_clock_gettime(CLOCK_REALTIME, &ts); 
     57139                      if (copy_to_user(tp_user, &ts, sizeof(ts)) != 0) { 
     57240                              errno = -EFAULT; 
     57341                              goto out; 
     57442                      } 
     57543              } 
     576(gdb) 
     57744 
     57845              errno = 0; 
     57946 
     58047      out: 
     58148              return errno; 
     58249      } 
     583(gdb) s 
     58415              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     585(gdb) 
     58620              if (message_user == NULL) { 
     587(gdb) 
     58824              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     589(gdb) 
     590strnlen_user (s=0x8048646 "new_debug()", n=1024) at arch/x86/lib/usercopy_32.c:196 
     591196     { 
     592(gdb) 
     593197             unsigned long mask = -__addr_ok(s); 
     594(gdb) finish 
     595Run till exit from #0  strnlen_user (s=0x8048646 "new_debug()", n=1024) at arch/x86/lib/usercopy_32.c:197 
     596sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:25 
     59725              if (len == 0 || len > __LOG_BUF_LEN) { 
     598Value returned is $1 = 12 
     599(gdb) s 
     60029              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     601(gdb) p message 
     602$2 = '\000' <repeats 176 times>, "\022\002\000\000[\356U鬜\354\335,\236\354\335\060\236\354\335\064\236\354\335\070\236\354\335<\236\354\335\220\216NN\224O\377\206\002\222\374\302[\356U\351\203\002a\033\336\314}\350\002\222\374\302\b\301\261\215P\000\000\000\000\000\000\000 \000\000\000,\236\354\335L\236\354\335;^\035\301\354\235\354\335,\236\354\335b\236\354\335\250\026\367\337\331\377\377\377\000\000\000\000\000\177\300\301\000\000\000\000Ȝ\354\335\037p\000\301\020\235\354\335\223\206\004\301\254a\a\371F\000\000\000\374`\a\371F\000\000\000\374`\a\371F\000\000\000@\204\300\301@\177\300\301C\224)*\017H\017\000\000\000\000\000\034T\215\337\017H\017\000\070\235\354݄c\002\301t\235\354\335,b\004\301F\000\000\000\360S\215\337\017H\017\000\000\000\000\000R\334\070*\003\000\000\000\300\344\063\301@B\017\000\000\000\000\000@>\300\301\200\235\354\335|v\004\301@B\017\000\000\000\000\000@`\374\370F\000\000\000t\235\354\335X\235\354\335d\235\354\335\250d\001\301l\235\354\335\304f\001\301\220\235\354\335\063\352\004\301\063`\016\001\000\000\000\000\v\026\341\226w\004\000\000\200\242\v\371F\000\000\000\002\000\000\000\230"... 
     603(gdb) p message_user 
     604$3 = 0x8048646 "new_debug()" 
     605(gdb) s 
     606strncpy_from_user (dst=0xddec9b98 "", src=0x8048646 "new_debug()", count=1023) at arch/x86/lib/usercopy_32.c:114 
     607114     { 
     608(gdb) finish 
     609Run till exit from #0  strncpy_from_user (dst=0xddec9b98 "", src=0x8048646 "new_debug()", count=1023) at arch/x86/lib/usercopy_32.c:114 
     6100xc101d8f1 in sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:29 
     61129              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     612Value returned is $4 = 11 
     613(gdb) p message_user 
     614$5 = 0x8048646 "new_debug()" 
     615(gdb) p message 
     616$6 = "new_debug()", '\000' <repeats 165 times>, "\022\002\000\000[\356U鬜\354\335,\236\354\335\060\236\354\335\064\236\354\335\070\236\354\335<\236\354\335\220\216NN\224O\377\206\002\222\374\302[\356U\351\203\002a\033\336\314}\350\002\222\374\302\b\301\261\215P\000\000\000\000\000\000\000 \000\000\000,\236\354\335L\236\354\335;^\035\301\354\235\354\335,\236\354\335b\236\354\335\250\026\367\337\331\377\377\377\000\000\000\000\000\177\300\301\000\000\000\000Ȝ\354\335\037p\000\301\020\235\354\335\223\206\004\301\254a\a\371F\000\000\000\374`\a\371F\000\000\000\374`\a\371F\000\000\000@\204\300\301@\177\300\301C\224)*\017H\017\000\000\000\000\000\034T\215\337\017H\017\000\070\235\354݄c\002\301t\235\354\335,b\004\301F\000\000\000\360S\215\337\017H\017\000\000\000\000\000R\334\070*\003\000\000\000\300\344\063\301@B\017\000\000\000\000\000@>\300\301\200\235\354\335|v\004\301@B\017\000\000\000\000\000@`\374\370F\000\000\000t\235\354\335X\235\354\335d\235\354\335\250d\001\301l\235\354\335\304f\001\301\220\235\354\335\063\352\004\301\063`\016\001\000\000\000\000\v\026\341\226w"... 
     617(gdb) s 
     61835              printk(KERN_DEBUG "%s\n", message); 
     619(gdb) 
     62033              message[sizeof(message) - 1] = '\0'; 
     621(gdb) 
     62235              printk(KERN_DEBUG "%s\n", message); 
     623(gdb) n 
     62437              if (tp_user != NULL) { 
     625(gdb) s 
     62649      } 
     627(gdb) finish 
     628Run till exit from #0  sys_new_debug (message_user=0x8048646 "new_debug()", tp_user=0x0) at arch/x86/kernel/new_debug.c:49 
     6290xc100288c in ?? () 
     630Value returned is $7 = 0 
     631(gdb) c 
     632Continuing. 
     633}}} 
     634 
     635 * s0711489@ubuntu-lucid:~/03$ ./a.out 
     636{{{ 
     637new_debug() 
     638}}} 
     639 
     640 * 期待通りの挙動を示した 
     641 
     642 == static char message [] == 
     643 * vim arch/x86/kernel/new_debug.c 
     644{{{#!diff 
     645Index: arch/x86/kernel/new_debug.c 
     646=================================================================== 
     647--- arch/x86/kernel/new_debug.c (リビジョン 1388) 
     648+++ arch/x86/kernel/new_debug.c (作業コピー) 
     649@@ -8,7 +8,7 @@ 
     650  
     651 SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     652         int errno; 
     653-        char message[__LOG_BUF_LEN]; 
     654+        static char message[__LOG_BUF_LEN]; 
     655         struct timespec ts; 
     656         long len = 0; 
     657          
     658}}} 
     659 
     660 * windell46:i386 s0711489$ ./build 
     661{{{ 
     662Kernel: arch/x86/boot/bzImage is ready  (#9) 
     663}}} 
     664 * windell46:i386 s0711489$ make modules 
     665 
     666 * s0711489@ubuntu-lucid:~$ sudo /mnt/hgfs/tools/install.sh 
     667 
     668 * gdb 
     669{{{ 
     670(gdb) file vmlinux 
     671Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/vmlinux...(no debugging symbols found)...done. 
     672(gdb) b sys_new_debug 
     673Breakpoint 1 at 0xc101d89c: file arch/x86/kernel/new_debug.c, line 9. 
     674(gdb) target remote windell46:8832 
     675Remote debugging using windell46:8832 
     6760xc1007cdf in native_safe_halt () at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/arch/x86/include/asm/irqflags.h:49 
     67749              asm volatile("sti; hlt": : :"memory"); 
     678(gdb) c 
     679Continuing. 
     680 
     681Breakpoint 1, sys_new_debug (message_user=0xbf8b099c "1", tp_user=0xbf8af014) at arch/x86/kernel/new_debug.c:9 
     6829       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     683(gdb) l 
     6844       #include <linux/time.h> 
     6855 
     6866       /* from kernel/printk.c */ 
     6877       #define __LOG_BUF_LEN   (1 << CONFIG_LOG_BUF_SHIFT) 
     6888 
     6899       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     69010              int errno; 
     69111              static char message[__LOG_BUF_LEN]; 
     69212              struct timespec ts; 
     69313              long len = 0; 
     694(gdb) 
     69514 
     69615              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     69716                      errno = -EFAULT; 
     69817                      goto out; 
     69918              } 
     70019 
     70120              if (message_user == NULL) { 
     70221                      errno = -EINVAL; 
     70322                      goto out; 
     70423              } 
     705(gdb) 
     70624              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     70725              if (len == 0 || len > __LOG_BUF_LEN) { 
     70826                      errno = -EINVAL; 
     70927                      goto out; 
     71028              } 
     71129              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     71230                      errno = -EFAULT; 
     71331                      goto out; 
     71432              } 
     71533              message[sizeof(message) - 1] = '\0'; 
     716(gdb) 
     71734 
     71835              printk(KERN_DEBUG "%s\n", message); 
     71936 
     72037              if (tp_user != NULL) { 
     72138                      sys_clock_gettime(CLOCK_REALTIME, &ts); 
     72239                      if (copy_to_user(tp_user, &ts, sizeof(ts)) != 0) { 
     72340                              errno = -EFAULT; 
     72441                              goto out; 
     72542                      } 
     72643              } 
     727(gdb) 
     72844 
     72945              errno = 0; 
     73046 
     73147      out: 
     73248              return errno; 
     73349      } 
     734(gdb) s 
     73515              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     736(gdb) 
     73720              if (message_user == NULL) { 
     738(gdb) 
     73924              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     740(gdb) 
     741strnlen_user (s=0xbf8b099c "1", n=262144) at arch/x86/lib/usercopy_32.c:196 
     742196     { 
     743(gdb) finish 
     744Run till exit from #0  strnlen_user (s=0xbf8b099c "1", n=262144) at arch/x86/lib/usercopy_32.c:196 
     745sys_new_debug (message_user=0xbf8b099c "1", tp_user=0xbf8af014) at arch/x86/kernel/new_debug.c:25 
     74625              if (len == 0 || len > __LOG_BUF_LEN) { 
     747Value returned is $1 = 2 
     748(gdb) s 
     74929              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     750(gdb) 
     751strncpy_from_user (dst=0xc158da00 "fuga", src=0xbf8b099c "1", count=262143) at arch/x86/lib/usercopy_32.c:114 
     752114     { 
     753(gdb) finish 
     754Run till exit from #0  strncpy_from_user (dst=0xc158da00 "fuga", src=0xbf8b099c "1", count=262143) at arch/x86/lib/usercopy_32.c:114 
     7550xc101d8ea in sys_new_debug (message_user=0xbf8b099c "1", tp_user=0xbf8af014) at arch/x86/kernel/new_debug.c:29 
     75629              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     757Value returned is $2 = 1 
     758(gdb) s 
     75935              printk(KERN_DEBUG "%s\n", message); 
     760(gdb) 
     76133              message[sizeof(message) - 1] = '\0'; 
     762(gdb) 
     76335              printk(KERN_DEBUG "%s\n", message); 
     764(gdb) p message 
     765$3 = "1\000ga\000ebug()", '\000' <repeats 262132 times> 
     766(gdb) n 
     76737              if (tp_user != NULL) { 
     768(gdb) s 
     76938                      sys_clock_gettime(CLOCK_REALTIME, &ts); 
     770(gdb) p ts 
     771$4 = {tv_sec = -598564864, tv_nsec = -1217056780} 
     772(gdb) n 
     77339                      if (copy_to_user(tp_user, &ts, sizeof(ts)) != 0) { 
     774(gdb) p ts 
     775$5 = {tv_sec = -598564864, tv_nsec = -1217056780} 
     776(gdb) n 
     77749      } 
     778(gdb) p ts_user 
     779No symbol "ts_user" in current context. 
     780(gdb) p tp_ 
     781tp_event               tp_perf_event_destroy  tp_probes              tp_user 
     782(gdb) p tp_user 
     783$6 = (struct timespec *) 0xbf8af014 
     784(gdb) p errno 
     785$7 = 0 
     786(gdb) finish 
     787Run till exit from #0  sys_new_debug (message_user=0xbf8b099c "1", tp_user=0xbf8af014) at arch/x86/kernel/new_debug.c:49 
     7880xc100288c in ?? () 
     789Value returned is $8 = 0 
     790(gdb) c 
     791Continuing. 
     792 
     793Breakpoint 1, sys_new_debug (message_user=0xbf8b099e "2", tp_user=0xbf8af014) at arch/x86/kernel/new_debug.c:9 
     7949       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     795(gdb) c 
     796Continuing. 
     797 
     798Breakpoint 1, sys_new_debug (message_user=0xbf8b09a0 "3", tp_user=0xbf8af014) at arch/x86/kernel/new_debug.c:9 
     7999       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     800(gdb) c 
     801Continuing. 
     802 
     803Breakpoint 1, sys_new_debug (message_user=0xbfc1e99c "1", tp_user=0xbfc1d654) at arch/x86/kernel/new_debug.c:9 
     8049       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     805(gdb) c 
     806Continuing. 
     807 
     808Breakpoint 1, sys_new_debug (message_user=0xbfc1e99e "2", tp_user=0xbfc1d654) at arch/x86/kernel/new_debug.c:9 
     8099       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     810(gdb) s 
     81115              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     812(gdb) 
     81320              if (message_user == NULL) { 
     814(gdb) n 
     81524              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     816(gdb) 
     81725              if (len == 0 || len > __LOG_BUF_LEN) { 
     818(gdb) 
     81929              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     820(gdb) 
     82135              printk(KERN_DEBUG "%s\n", message); 
     822(gdb) 
     82333              message[sizeof(message) - 1] = '\0'; 
     824(gdb) 
     82535              printk(KERN_DEBUG "%s\n", message); 
     826(gdb) 
     82737              if (tp_user != NULL) { 
     828(gdb) p tp_user 
     829$9 = (struct timespec *) 0xbfc1d654 
     830(gdb) p ts 
     831$10 = {tv_sec = 0, tv_nsec = 0} 
     832(gdb) n 
     83338                      sys_clock_gettime(CLOCK_REALTIME, &ts); 
     834(gdb) 
     83539                      if (copy_to_user(tp_user, &ts, sizeof(ts)) != 0) { 
     836(gdb) 
     83749      } 
     838(gdb) finish 
     839Run till exit from #0  sys_new_debug (message_user=0xbfc1e99e "2", tp_user=0xbfc1d654) at arch/x86/kernel/new_debug.c:49 
     8400xc100288c in ?? () 
     841Value returned is $11 = 0 
     842(gdb) c 
     843Continuing. 
     844 
     845Breakpoint 1, sys_new_debug (message_user=0xbfc1e9a0 "3", tp_user=0xbfc1d654) at arch/x86/kernel/new_debug.c:9 
     8469       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     847(gdb) c 
     848Continuing. 
     849}}} 
     850 
     851 * s0711489@ubuntu-lucid:~/03$ ./a.out hoge fuga 
     852{{{ 
     853[-598562624.-1216589836] hoge 
     854[0.000000000] fuga 
     855}}} 
     856 * s0711489@ubuntu-lucid:~/03$ ./a.out 1 2 3 
     857{{{ 
     858[-598564864.-1217056780] 1 
     859[0.000000000] 2 
     860[0.000000000] 3 
     861}}} 
     862 * s0711489@ubuntu-lucid:~/03$ ./a.out 1 2 3 
     863{{{ 
     864[-598564864.-1215885324] 1 
     865[0.000000000] 2 
     866[0.000000000] 3 
     867}}} 
     868 
     869 * こちらも問題無く動作した 
     870 
     871 == very long argument == 
     872 * gdb 
     873{{{ 
     874(gdb) target remote windell46:8832 
     875Remote debugging using windell46:8832 
     8760xc1007cdf in native_safe_halt () at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/arch/x86/include/asm/irqflags.h:49 
     87749              asm volatile("sti; hlt": : :"memory"); 
     878(gdb) c 
     879Continuing. 
     880 
     881Breakpoint 1, sys_new_debug (message_user=0xbfcf7619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"..., tp_user=0xbfcf62d4) 
     882    at arch/x86/kernel/new_debug.c:9 
     8839       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     884(gdb) s 
     88515              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     886(gdb) 
     88720              if (message_user == NULL) { 
     888(gdb) p message 
     889$12 = '\000' <repeats 262143 times> 
     890(gdb) p message_user 
     891$13 = 0xbfcf7619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"... 
     892(gdb) p tp_user 
     893$14 = (struct timespec *) 0xbfcf62d4 
     894(gdb) s 
     89524              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     896(gdb) p len 
     897$15 = <value optimized out> 
     898(gdb) n 
     89925              if (len == 0 || len > __LOG_BUF_LEN) { 
     900(gdb) s 
     90129              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     902(gdb) 
     903strncpy_from_user (dst=0xc158da00 "", src=0xbfcf7619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"..., count=262143) 
     904    at arch/x86/lib/usercopy_32.c:114 
     905114     { 
     906(gdb) finish 
     907Run till exit from #0  strncpy_from_user (dst=0xc158da00 "", src=0xbfcf7619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"..., count=262143) 
     908    at arch/x86/lib/usercopy_32.c:114 
     9090xc101d8ea in sys_new_debug (message_user=0xbfcf7619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"..., tp_user=0xbfcf62d4) 
     910    at arch/x86/kernel/new_debug.c:29 
     91129              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     912Value returned is $16 = 5000 
     913(gdb) p message 
     914$17 = '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "2", '0' <repeats 99 times>, "3", '0' <repeats 99 times>, "4", '0' <repeats 99 times>, "5", '0' <repeats 99 times>, "6", '0' <repeats 99 times>, "7", '0' <repeats 99 times>, "8", '0' <repeats 99 times>, "9", '0' <repeats 98 times>, "1", '0' <repeats 99 times>, "11", '0' <repeats 98 times>, "12", '0' <repeats 98 times>, "13", '0' <repeats 98 times>, "14", '0' <repeats 98 times>, "15", '0' <repeats 98 times>, "16", '0' <repeats 98 times>, "17", '0' <repeats 98 times>... 
     915(gdb) s 
     91635              printk(KERN_DEBUG "%s\n", message); 
     917(gdb) n 
     91833              message[sizeof(message) - 1] = '\0'; 
     919(gdb) p sizeof(message) 
     920$18 = 262144 
     921(gdb) n 
     92235              printk(KERN_DEBUG "%s\n", message); 
     923(gdb) 
     92437              if (tp_user != NULL) { 
     925(gdb) 
     92638                      sys_clock_gettime(CLOCK_REALTIME, &ts); 
     927(gdb) p ts 
     928$19 = {tv_sec = -598614528, tv_nsec = -1216688140} 
     929(gdb) n 
     93039                      if (copy_to_user(tp_user, &ts, sizeof(ts)) != 0) { 
     931(gdb) 
     93249      } 
     933(gdb) finish 
     934Run till exit from #0  sys_new_debug (message_user=0xbfcf7619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"..., tp_user=0xbfcf62d4) 
     935    at arch/x86/kernel/new_debug.c:49 
     9360xc100288c in ?? () 
     937Value returned is $20 = 0 
     938(gdb) c 
     939Continuing. 
     940}}} 
     941 
     942 * s0711489@ubuntu-lucid:~/03$ ./a.out 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000210000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000270000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000390000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000 
     943{{{ 
     944[-598614528.-1216688140] 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000210000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000270000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000390000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000 
     945}}} 
     946 * s0711489@ubuntu-lucid:~/03$ dmesg | tail -n 2 
     947{{{ 
     948[    6.197442] vmblock: version magic '2.6.32-33-generic SMP mod_unload modversions 586 ' should be '2.6.35.14 SMP mod_unload 686 ' 
     949[  276.962399] 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000 
     950}}} 
     951 
     952 * printk() 
     953{{{ 
     954Breakpoint 1, sys_new_debug (message_user=0xbfee1619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"..., tp_user=0xbfedfda4) 
     955    at arch/x86/kernel/new_debug.c:9 
     9569       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     957(gdb) n 
     95815              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     959(gdb) 
     96020              if (message_user == NULL) { 
     961(gdb) 
     96224              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     963(gdb) 
     96425              if (len == 0 || len > __LOG_BUF_LEN) { 
     965(gdb) 
     96629              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     967(gdb) 
     96835              printk(KERN_DEBUG "%s\n", message); 
     969(gdb) s 
     97033              message[sizeof(message) - 1] = '\0'; 
     971(gdb) 
     97235              printk(KERN_DEBUG "%s\n", message); 
     973(gdb) 
     974printk (fmt=0xc1449542 "<7>%s\n") at kernel/printk.c:614 
     975614             va_start(args, fmt); 
     976(gdb) finish 
     977Run till exit from #0  printk (fmt=0xc1449542 "<7>%s\n") at kernel/printk.c:614 
     978sys_new_debug (message_user=0xbfee1619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"..., tp_user=0xbfedfda4) 
     979    at arch/x86/kernel/new_debug.c:37 
     98037              if (tp_user != NULL) { 
     981Value returned is $21 = 1041 
     982(gdb) 
     983Run till exit from #0  sys_new_debug (message_user=0xbfee1619 '0' <repeats 97 times>, "1", '0' <repeats 99 times>, "200"..., tp_user=0xbfedfda4) 
     984    at arch/x86/kernel/new_debug.c:37 
     9850xc100288c in ?? () 
     986Value returned is $22 = 0 
     987(gdb) c 
     988Continuing. 
     989}}} 
     990 
     991 == shorten message[] == 
     992 * printk()は1020文字程度しか出力してくれない(Ubuntu 10.04 i386)ので、バッファイサイズをずっと短くする 
     993 
     994 * vim arch/x86/kernel/new_debug.c 
     995{{{#!diff 
     996Index: arch/x86/kernel/new_debug.c 
     997=================================================================== 
     998--- arch/x86/kernel/new_debug.c (リビジョン 1389) 
     999+++ arch/x86/kernel/new_debug.c (作業コピー) 
     1000@@ -4,7 +4,7 @@ 
     1001 #include <linux/time.h> 
     1002  
     1003 /* from kernel/printk.c */ 
     1004-#define __LOG_BUF_LEN  (1 << CONFIG_LOG_BUF_SHIFT) 
     1005+#define __LOG_BUF_LEN 1024 
     1006  
     1007 SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     1008         int errno; 
     1009}}} 
     1010 
     1011 * windell46:i386 s0711489$ ./build 
     1012{{{ 
     1013Kernel: arch/x86/boot/bzImage is ready  (#11) 
     1014}}} 
     1015 * windell46:i386 s0711489$ make modules 
     1016 
     1017 * s0711489@ubuntu-lucid:~$ sudo /mnt/hgfs/tools/install.sh 
     1018 
     1019 * s0711489@ubuntu-lucid:~/03$ ./a.out 
     1020{{{ 
     1021new_debug() 
     1022}}} 
     1023 * s0711489@ubuntu-lucid:~/03$ ./a.out 1 2 3 4 
     1024{{{ 
     1025[-572681344.-1217335308] 1 
     1026[0.000000000] 2 
     1027[0.000000000] 3 
     1028[0.000000000] 4 
     1029}}} 
     1030 * s0711489@ubuntu-lucid:~/03$ ./a.out 1 2 3 4 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000020 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000020123 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000201234 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000002012345 
     1031{{{ 
     1032[-572680448.-1215909900] 1 
     1033[0.000000000] 2 
     1034[0.000000000] 3 
     1035[0.000000000] 4 
     1036[0.000000000] 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000 
     1037[0.000000000] 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000020 
     1038[0.000000000] 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000020123 
     1039new_debug with argv[i]: Invalid argument 
     1040new_debug with argv[i]: Invalid argument 
     1041}}} 
     1042 
     1043 * gdb 
     1044{{{ 
     1045(gdb) file vmlinux 
     1046Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/vmlinux...(no debugging symbols found)...done. 
     1047b sys_new_debug 
     1048(gdb) b sys_new_debug 
     1049Breakpoint 1 at 0xc101d89c: file arch/x86/kernel/new_debug.c, line 9. 
     1050(gdb) target remote windell46:8832 
     1051Remote debugging using windell46:8832 
     10520xc1007cdf in native_safe_halt () at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/i386/arch/x86/include/asm/irqflags.h:49 
     105349              asm volatile("sti; hlt": : :"memory"); 
     1054(gdb) c 
     1055Continuing. 
     1056 
     1057Breakpoint 1, sys_new_debug (message_user=0xbfa735b9 '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:9 
     10589       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     1059(gdb) n 
     106015              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     1061(gdb) 
     106220              if (message_user == NULL) { 
     1063(gdb) 
     106424              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     1065(gdb) s 
     1066strnlen_user (s=0xbfa735b9 '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1067196     { 
     1068(gdb) finish 
     1069Run till exit from #0  strnlen_user (s=0xbfa735b9 '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1070sys_new_debug (message_user=0xbfa735b9 '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:25 
     107125              if (len == 0 || len > __LOG_BUF_LEN) { 
     1072Value returned is $1 = 1001 
     1073(gdb) c 
     1074Continuing. 
     1075 
     1076Breakpoint 1, sys_new_debug (message_user=0xbfa739a2 '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:9 
     10779       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     1078(gdb) n 
     107915              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     1080(gdb) 
     108120              if (message_user == NULL) { 
     1082(gdb) 
     108324              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     1084(gdb) s 
     1085strnlen_user (s=0xbfa739a2 '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1086196     { 
     1087(gdb) finish 
     1088Run till exit from #0  strnlen_user (s=0xbfa739a2 '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1089sys_new_debug (message_user=0xbfa739a2 '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:25 
     109025              if (len == 0 || len > __LOG_BUF_LEN) { 
     1091Value returned is $2 = 1021 
     1092(gdb) s 
     109329              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     1094(gdb) 
     1095strncpy_from_user (dst=0xc158da00 '0' <repeats 200 times>..., src=0xbfa739a2 '0' <repeats 200 times>..., count=1023) at arch/x86/lib/usercopy_32.c:114 
     1096114     { 
     1097(gdb) finish 
     1098Run till exit from #0  strncpy_from_user (dst=0xc158da00 '0' <repeats 200 times>..., src=0xbfa739a2 '0' <repeats 200 times>..., count=1023) 
     1099    at arch/x86/lib/usercopy_32.c:114 
     11000xc101d8ea in sys_new_debug (message_user=0xbfa739a2 '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:29 
     110129              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     1102Value returned is $3 = 1020 
     1103(gdb) c 
     1104Continuing. 
     1105 
     1106Breakpoint 1, sys_new_debug (message_user=0xbfa73d9f '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:9 
     11079       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     1108(gdb) n 
     110915              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     1110(gdb) 
     111120              if (message_user == NULL) { 
     1112(gdb) 
     111324              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     1114(gdb) s 
     1115strnlen_user (s=0xbfa73d9f '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1116196     { 
     1117(gdb) finish 
     1118Run till exit from #0  strnlen_user (s=0xbfa73d9f '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1119sys_new_debug (message_user=0xbfa73d9f '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:25 
     112025              if (len == 0 || len > __LOG_BUF_LEN) { 
     1121Value returned is $4 = 1024 
     1122(gdb) s 
     112329              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     1124(gdb) 
     1125strncpy_from_user (dst=0xc158da00 '0' <repeats 200 times>..., src=0xbfa73d9f '0' <repeats 200 times>..., count=1023) at arch/x86/lib/usercopy_32.c:114 
     1126114     { 
     1127(gdb) finish 
     1128Run till exit from #0  strncpy_from_user (dst=0xc158da00 '0' <repeats 200 times>..., src=0xbfa73d9f '0' <repeats 200 times>..., count=1023) 
     1129    at arch/x86/lib/usercopy_32.c:114 
     11300xc101d8ea in sys_new_debug (message_user=0xbfa73d9f '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:29 
     113129              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     1132Value returned is $5 = 1023 
     1133(gdb) c 
     1134Continuing. 
     1135 
     1136Breakpoint 1, sys_new_debug (message_user=0xbfa7419f '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:9 
     11379       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     1138(gdb) n 
     113915              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     1140(gdb) 
     114120              if (message_user == NULL) { 
     1142(gdb) 
     114324              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     1144(gdb) s 
     1145strnlen_user (s=0xbfa7419f '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1146196     { 
     1147(gdb) finish 
     1148Run till exit from #0  strnlen_user (s=0xbfa7419f '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1149sys_new_debug (message_user=0xbfa7419f '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:25 
     115025              if (len == 0 || len > __LOG_BUF_LEN) { 
     1151Value returned is $6 = 1025 
     1152(gdb) s 
     115349      } 
     1154(gdb) l 25 
     115520              if (message_user == NULL) { 
     115621                      errno = -EINVAL; 
     115722                      goto out; 
     115823              } 
     115924              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     116025              if (len == 0 || len > __LOG_BUF_LEN) { 
     116126                      errno = -EINVAL; 
     116227                      goto out; 
     116328              } 
     116429              if (strncpy_from_user(message, message_user, sizeof(message) - 1) < 0) { 
     1165(gdb) p errno 
     1166$7 = -22 
     1167(gdb) finish 
     1168Run till exit from #0  sys_new_debug (message_user=0xbfa7419f '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:49 
     11690xc100288c in ?? () 
     1170Value returned is $8 = -22 
     1171(gdb) c 
     1172Continuing. 
     1173 
     1174Breakpoint 1, sys_new_debug (message_user=0xbfa745a0 '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:9 
     11759       SYSCALL_DEFINE2(new_debug, const char *, message_user, struct timespec*, tp_user) { 
     1176(gdb) n 
     117715              if(tp_user != NULL && ! access_ok(VERIFY_WRITE, tp_user, sizeof(*tp_user)) ) { 
     1178(gdb) 
     117920              if (message_user == NULL) { 
     1180(gdb) 
     118124              len = strnlen_user(message_user, __LOG_BUF_LEN); 
     1182(gdb) s 
     1183strnlen_user (s=0xbfa745a0 '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1184196     { 
     1185(gdb) finish 
     1186Run till exit from #0  strnlen_user (s=0xbfa745a0 '0' <repeats 200 times>..., n=1024) at arch/x86/lib/usercopy_32.c:196 
     1187sys_new_debug (message_user=0xbfa745a0 '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:25 
     118825              if (len == 0 || len > __LOG_BUF_LEN) { 
     1189Value returned is $9 = 1025 
     1190(gdb) s 
     119149      } 
     1192(gdb) p errno 
     1193$10 = -22 
     1194(gdb) finish 
     1195Run till exit from #0  sys_new_debug (message_user=0xbfa745a0 '0' <repeats 200 times>..., tp_user=0xbfa716a4) at arch/x86/kernel/new_debug.c:49 
     11960xc100288c in ?? () 
     1197Value returned is $11 = -22 
     1198(gdb) c 
     1199Continuing. 
     1200}}} 
     1201  * s0711489@ubuntu-lucid:~/03$ ./a.out 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000020 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000020123 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000201234 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000002012345 
     1202{{{ 
     1203[-593455808.-1216405516] 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000 
     1204[0.000000000] 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000020 
     1205[0.000000000] 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000020123 
     1206new_debug with argv[i]: Invalid argument 
     1207new_debug with argv[i]: Invalid argument 
     1208}}}