| 2446 | |
| 2447 | = 11/23 = |
| 2448 | == instead of char*, use typedef struct DATA == |
| 2449 | * s0711489@ubuntu-lucid64:~$ sudo insmod stackmod.ko |
| 2450 | {{{ |
| 2451 | Nov 23 01:54:02 ubuntu-lucid64 kernel: [ 242.821597] stackmod is loaded |
| 2452 | Nov 23 01:54:02 ubuntu-lucid64 kernel: [ 242.821601] stackmod: 128 entry, major is 251, minor is 0 |
| 2453 | Nov 23 01:54:02 ubuntu-lucid64 kernel: [ 242.821616] stackmod: create /proc/stackmod |
| 2454 | Nov 23 01:54:02 ubuntu-lucid64 kernel: [ 242.821618] stackmod is added successfully |
| 2455 | }}} |
| 2456 | |
| 2457 | * s0711489@ubuntu-lucid64:~$ sudo mknod /dev/stack c 251 0 |
| 2458 | * s0711489@ubuntu-lucid64:~$ sudo chmod 666 /dev/stack |
| 2459 | |
| 2460 | * s0711489@ubuntu-lucid64:~$ echo hoge > /dev/stack |
| 2461 | {{{ |
| 2462 | Nov 23 01:55:26 ubuntu-lucid64 kernel: [ 327.080724] stackmod is opened |
| 2463 | Nov 23 01:55:26 ubuntu-lucid64 kernel: [ 327.080773] stackmod is written |
| 2464 | Nov 23 01:55:26 ubuntu-lucid64 kernel: [ 327.080784] stackmod is released |
| 2465 | }}} |
| 2466 | |
| 2467 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2468 | {{{ |
| 2469 | stack: 1 |
| 2470 | }}} |
| 2471 | {{{ |
| 2472 | Nov 23 01:55:44 ubuntu-lucid64 kernel: [ 344.897310] /proc/stackmod is read |
| 2473 | Nov 23 01:55:44 ubuntu-lucid64 kernel: [ 344.897328] /proc/stackmod is read |
| 2474 | }}} |
| 2475 | |
| 2476 | * s0711489@ubuntu-lucid64:~$ cat /dev/stack |
| 2477 | {{{ |
| 2478 | cat: /dev/stack: Bad address |
| 2479 | }}} |
| 2480 | {{{ |
| 2481 | Nov 23 01:56:09 ubuntu-lucid64 kernel: [ 370.036240] stackmod is opened |
| 2482 | Nov 23 01:56:09 ubuntu-lucid64 kernel: [ 370.036253] stackmod is read |
| 2483 | Nov 23 01:56:09 ubuntu-lucid64 kernel: [ 370.036346] stackmod: copy_to_user failed |
| 2484 | Nov 23 01:56:09 ubuntu-lucid64 kernel: [ 370.036471] stackmod is released |
| 2485 | }}} |
| 2486 | * buggy |
| 2487 | |
| 2488 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2489 | {{{ |
| 2490 | stack: 1 |
| 2491 | }}} |
| 2492 | |
| 2493 | === check what is bug with gdb === |
| 2494 | * s0711489@ubuntu-lucid64:~$ sudo insmod stackmod.ko entry=4 |
| 2495 | * s0711489@ubuntu-lucid64:~$ sudo mknod /dev/stack c 251 0 |
| 2496 | * s0711489@ubuntu-lucid64:~$ sudo chmod 666 /dev/stack |
| 2497 | |
| 2498 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.text |
| 2499 | {{{ |
| 2500 | 0xffffffffa0056000 |
| 2501 | }}} |
| 2502 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.data |
| 2503 | {{{ |
| 2504 | 0xffffffffa00566b8 |
| 2505 | }}} |
| 2506 | * s0711489@ubuntu-lucid64:~$ cat /sys/module/stackmod/sections/.bss |
| 2507 | {{{ |
| 2508 | 0xffffffffa00568f0 |
| 2509 | }}} |
| 2510 | |
| 2511 | * gdb |
| 2512 | {{{ |
| 2513 | (gdb) file vmlinux |
| 2514 | Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/x86_64/vmlinux...(no debugging symbols found)...done. |
| 2515 | (gdb) add-symbol-file ../../04/stackmod/stackmod.o 0xffffffffa0056000 -s .data 0xffffffffa00566b8 -s .bss 0xffffffffa00568f0 |
| 2516 | add symbol table from file "../../04/stackmod/stackmod.o" at |
| 2517 | .text_addr = 0xffffffffa0056000 |
| 2518 | .data_addr = 0xffffffffa00566b8 |
| 2519 | .bss_addr = 0xffffffffa00568f0 |
| 2520 | (y or n) y |
| 2521 | Reading symbols from /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.o...done. |
| 2522 | (gdb) target remote localhost:8864 |
| 2523 | Remote debugging using localhost:8864 |
| 2524 | 0xffffffff810097a9 in native_safe_halt () |
| 2525 | at /home/ugrad/07/s0711489/coursework/KernelHack/linux-2.6.35.14/x86_64/arch/x86/include/asm/irqflags.h:49 |
| 2526 | 49 asm volatile("sti; hlt": : :"memory"); |
| 2527 | (gdb) b stackmod_read |
| 2528 | Breakpoint 1 at 0xffffffffa00560b4: file /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c, line 62. |
| 2529 | (gdb) b stackmod_write |
| 2530 | Breakpoint 2 at 0xffffffffa00561e0: file /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c, line 105. |
| 2531 | (gdb) b stackmod_proc_read |
| 2532 | Breakpoint 3 at 0xffffffffa00561a3: file /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c, line 153. |
| 2533 | (gdb) c |
| 2534 | Continuing. |
| 2535 | }}} |
| 2536 | |
| 2537 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2538 | {{{ |
| 2539 | stack: 0 |
| 2540 | }}} |
| 2541 | {{{ |
| 2542 | Breakpoint 3, stackmod_proc_read (page=0xffff88001d9a9000 "p\227\232\035", |
| 2543 | start=0xffff88001b95fe90, off=0, count=3072, eof=0xffff88001b95fe9c, |
| 2544 | data=0x0) |
| 2545 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:153 |
| 2546 | 153 ) { |
| 2547 | (gdb) p stack |
| 2548 | $1 = {data = 0xffff88001b7c7940, depth = 0, errno = 0} |
| 2549 | (gdb) p stack.data |
| 2550 | $2 = (DATA *) 0xffff88001b7c7940 |
| 2551 | (gdb) ptype stack.data |
| 2552 | type = struct kernel_module_stack_data { |
| 2553 | int length; |
| 2554 | char *content; |
| 2555 | } * |
| 2556 | (gdb) ptype stack.data[0] |
| 2557 | type = struct kernel_module_stack_data { |
| 2558 | int length; |
| 2559 | char *content; |
| 2560 | } |
| 2561 | (gdb) p stack.data[0] |
| 2562 | $3 = {length = 461142784, content = 0xffff88001b7c7988 "\210y|\033"} |
| 2563 | (gdb) p stack.data[1] |
| 2564 | $4 = {length = 0, content = 0x0} |
| 2565 | (gdb) p stack.data[2] |
| 2566 | $5 = {length = 0, |
| 2567 | content = 0x2e2e02020010e071 <Address 0x2e2e02020010e071 out of bounds>} |
| 2568 | (gdb) c |
| 2569 | Continuing. |
| 2570 | |
| 2571 | Breakpoint 3, stackmod_proc_read (page=0xffff88001d9a9000 "stack: 0\n", |
| 2572 | start=0xffff88001b95fe90, off=9, count=3072, eof=0xffff88001b95fe9c, |
| 2573 | data=0x0) |
| 2574 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:153 |
| 2575 | 153 ) { |
| 2576 | (gdb) finish |
| 2577 | Run till exit from #0 stackmod_proc_read ( |
| 2578 | page=0xffff88001d9a9000 "stack: 0\n", start=0xffff88001b95fe90, off=9, |
| 2579 | count=3072, eof=0xffff88001b95fe9c, data=0x0) |
| 2580 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:153 |
| 2581 | __proc_file_read (file=<value optimized out>, buf=0x1420000 "stack: 0\n", |
| 2582 | nbytes=32768, ppos=0xffff88001b95ff48) at fs/proc/generic.c:125 |
| 2583 | 125 if (n == 0) /* end of file */ |
| 2584 | Could not fetch register "orig_rax"; remote failure reply 'E00' |
| 2585 | (gdb) c |
| 2586 | Continuing. |
| 2587 | }}} |
| 2588 | |
| 2589 | * s0711489@ubuntu-lucid64:~$ cat /dev/stack |
| 2590 | {{{ |
| 2591 | Nov 23 02:43:46 ubuntu-lucid64 kernel: [ 2449.923317] stackmod is opened |
| 2592 | Nov 23 02:43:46 ubuntu-lucid64 kernel: [ 2514.778526] stackmod is read |
| 2593 | Nov 23 02:43:46 ubuntu-lucid64 kernel: [ 2538.311203] stackmod is released |
| 2594 | }}} |
| 2595 | {{{ |
| 2596 | Breakpoint 1, stackmod_read (filep=0xffff88001b90a240, |
| 2597 | buf_user=0x189a000 <Address 0x189a000 out of bounds>, size=32768, |
| 2598 | offset=0xffff88001bb19f48) |
| 2599 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:62 |
| 2600 | 62 ) { |
| 2601 | (gdb) p p |
| 2602 | $6 = <value optimized out> |
| 2603 | (gdb) p stack.depth |
| 2604 | $7 = 0 |
| 2605 | |
| 2606 | (snip) |
| 2607 | |
| 2608 | (gdb) n |
| 2609 | 66 printk(KERN_DEBUG MODNAME " is read\n"); |
| 2610 | (gdb) |
| 2611 | 62 ) { |
| 2612 | (gdb) |
| 2613 | 66 printk(KERN_DEBUG MODNAME " is read\n"); |
| 2614 | (gdb) |
| 2615 | 68 if (size == 0) { |
| 2616 | (gdb) |
| 2617 | 71 if (stack.depth == 0) { |
| 2618 | (gdb) |
| 2619 | 101 } |
| 2620 | (gdb) |
| 2621 | vfs_read (file=0xffff88001b90a240, |
| 2622 | buf=0x189a000 <Address 0x189a000 out of bounds>, |
| 2623 | count=<value optimized out>, pos=0xffff88001bb19f48) at fs/read_write.c:313 |
| 2624 | 313 if (ret > 0) { |
| 2625 | (gdb) c |
| 2626 | Continuing. |
| 2627 | }}} |
| 2628 | |
| 2629 | * s0711489@ubuntu-lucid64:~$ echo depth=0 > /dev/stack |
| 2630 | {{{ |
| 2631 | Nov 23 02:47:16 ubuntu-lucid64 kernel: [ 2651.841249] stackmod is opened |
| 2632 | Nov 23 02:47:41 ubuntu-lucid64 kernel: [ 2724.502176] stackmod is written |
| 2633 | Nov 23 02:50:07 ubuntu-lucid64 kernel: [ 2916.725803] stackmod is released |
| 2634 | }}} |
| 2635 | {{{ |
| 2636 | Breakpoint 2, stackmod_write (filep=0xffff88001b984240, |
| 2637 | buf_user=0x126ac08 "depth=0\n /usr/bin/xzdec\nusr/sbin/update-alternatives\n\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337", <incomplete sequence \337>..., size=8, |
| 2638 | offset=0xffff88001b8dff48) |
| 2639 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:105 |
| 2640 | 105 ) { |
| 2641 | (gdb) p p |
| 2642 | $8 = <value optimized out> |
| 2643 | (gdb) p stack |
| 2644 | $9 = {data = 0xffff88001b7c7940, depth = 0, errno = 0} |
| 2645 | (gdb) p stack.data[0] |
| 2646 | $10 = {length = 461142784, content = 0xffff88001b7c7988 "\210y|\033"} |
| 2647 | (gdb) n |
| 2648 | 108 printk(KERN_DEBUG MODNAME " is written\n"); |
| 2649 | (gdb) |
| 2650 | 105 ) { |
| 2651 | (gdb) |
| 2652 | 108 printk(KERN_DEBUG MODNAME " is written\n"); |
| 2653 | (gdb) |
| 2654 | 110 if (size == 0) { |
| 2655 | (gdb) |
| 2656 | 113 if (stack.depth >= entry) { |
| 2657 | (gdb) |
| 2658 | 117 if (buf_user == NULL) { |
| 2659 | (gdb) |
| 2660 | 122 p.content = (char *) kmalloc(size * sizeof(char), GFP_KERNEL); |
| 2661 | (gdb) |
| 2662 | 123 if (p.content == NULL) { |
| 2663 | (gdb) |
| 2664 | 122 p.content = (char *) kmalloc(size * sizeof(char), GFP_KERNEL); |
| 2665 | (gdb) |
| 2666 | 123 if (p.content == NULL) { |
| 2667 | (gdb) |
| 2668 | 129 if (copy_from_user(p.content, buf_user, size) != 0) { |
| 2669 | (gdb) p stack.data[0] |
| 2670 | $11 = {length = 461142784, content = 0xffff88001b7c7988 "\210y|\033"} |
| 2671 | (gdb) n |
| 2672 | 136 stack.depth++; |
| 2673 | (gdb) p stack.data[0] |
| 2674 | $12 = {length = 461142784, content = 0xffff88001b7c7988 "\210y|\033"} |
| 2675 | (gdb) p stack.data[0].content |
| 2676 | $13 = 0xffff88001b7c7988 "\210y|\033" |
| 2677 | (gdb) p size |
| 2678 | $14 = 0 |
| 2679 | (gdb) p buf_user |
| 2680 | $15 = 0x126ac08 "depth=0\n /usr/bin/xzdec\nusr/sbin/update-alternatives\n\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337", <incomplete sequence \337>... |
| 2681 | (gdb) n |
| 2682 | 140 return size; |
| 2683 | (gdb) p stack |
| 2684 | $16 = {data = 0xffff88001b7c7940, depth = 1, errno = 0} |
| 2685 | (gdb) p stack.data[0] |
| 2686 | $17 = {length = 461142784, content = 0xffff88001b7c7988 "\210y|\033"} |
| 2687 | (gdb) c |
| 2688 | Continuing. |
| 2689 | }}} |
| 2690 | |
| 2691 | * s0711489@ubuntu-lucid64:~$ echo depth=1 > /dev/stack |
| 2692 | {{{ |
| 2693 | Nov 23 02:51:53 ubuntu-lucid64 kernel: [ 2955.599055] stackmod is opened |
| 2694 | Nov 23 02:51:53 ubuntu-lucid64 kernel: [ 2986.156722] stackmod is written |
| 2695 | Nov 23 02:53:51 ubuntu-lucid64 kernel: [ 3139.258180] stackmod is released |
| 2696 | }}} |
| 2697 | {{{ |
| 2698 | Breakpoint 2, stackmod_write (filep=0xffff88001b80e9c0, |
| 2699 | buf_user=0x126ac08 "depth=1\n /usr/bin/xzdec\nusr/sbin/update-alternatives\n\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337", <incomplete sequence \337>..., size=8, |
| 2700 | offset=0xffff88001b8dff48) |
| 2701 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:105 |
| 2702 | 105 ) { |
| 2703 | (gdb) p size |
| 2704 | $18 = 8 |
| 2705 | (gdb) n |
| 2706 | 108 printk(KERN_DEBUG MODNAME " is written\n"); |
| 2707 | (gdb) |
| 2708 | 105 ) { |
| 2709 | (gdb) |
| 2710 | 108 printk(KERN_DEBUG MODNAME " is written\n"); |
| 2711 | (gdb) |
| 2712 | 110 if (size == 0) { |
| 2713 | (gdb) |
| 2714 | 113 if (stack.depth >= entry) { |
| 2715 | (gdb) |
| 2716 | 117 if (buf_user == NULL) { |
| 2717 | (gdb) |
| 2718 | 122 p.content = (char *) kmalloc(size * sizeof(char), GFP_KERNEL); |
| 2719 | (gdb) l |
| 2720 | 117 if (buf_user == NULL) { |
| 2721 | 118 return -EINVAL; |
| 2722 | 119 } |
| 2723 | 120 |
| 2724 | 121 p = stack.data[stack.depth]; |
| 2725 | 122 p.content = (char *) kmalloc(size * sizeof(char), GFP_KERNEL); |
| 2726 | 123 if (p.content == NULL) { |
| 2727 | 124 printk(KERN_WARNING MODNAME ": (char *) kmalloc failed\n"); |
| 2728 | 125 return -ENOMEM; |
| 2729 | 126 } |
| 2730 | (gdb) n |
| 2731 | 123 if (p.content == NULL) { |
| 2732 | (gdb) p p.content |
| 2733 | $19 = 0x0 |
| 2734 | (gdb) n |
| 2735 | 122 p.content = (char *) kmalloc(size * sizeof(char), GFP_KERNEL); |
| 2736 | (gdb) |
| 2737 | 123 if (p.content == NULL) { |
| 2738 | (gdb) p p.content |
| 2739 | $20 = 0x0 |
| 2740 | (gdb) n |
| 2741 | 129 if (copy_from_user(p.content, buf_user, size) != 0) { |
| 2742 | (gdb) |
| 2743 | 136 stack.depth++; |
| 2744 | (gdb) p p.content |
| 2745 | $21 = 0x0 |
| 2746 | (gdb) p size |
| 2747 | $22 = 0 |
| 2748 | (gdb) p p |
| 2749 | $23 = <value optimized out> |
| 2750 | (gdb) p stack.data |
| 2751 | $24 = (DATA *) 0xffff88001b7c7940 |
| 2752 | (gdb) p stack |
| 2753 | $25 = {data = 0xffff88001b7c7940, depth = 1, errno = 0} |
| 2754 | (gdb) p stack[1] |
| 2755 | Structure has no component named operator[]. |
| 2756 | (gdb) p stack.data[1] |
| 2757 | $26 = {length = 0, content = 0x0} |
| 2758 | (gdb) n |
| 2759 | 140 return size; |
| 2760 | (gdb) p size |
| 2761 | $27 = 0 |
| 2762 | (gdb) finish |
| 2763 | Run till exit from #0 stackmod_write (filep=<value optimized out>, |
| 2764 | buf_user=0x126ac08 "depth=1\n /usr/bin/xzdec\nusr/sbin/update-alternatives\n\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337", <incomplete sequence \337>..., size=0, |
| 2765 | offset=0xffff88001b8dff48) |
| 2766 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:140 |
| 2767 | 0xffffffff810df5a3 in vfs_write (file=0xffff88001b80e9c0, |
| 2768 | buf=0x126ac08 "depth=1\n /usr/bin/xzdec\nusr/sbin/update-alternatives\n\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337\337", <incomplete sequence \337>..., |
| 2769 | count=<value optimized out>, pos=0xffff88001b8dff48) at fs/read_write.c:366 |
| 2770 | 366 ret = file->f_op->write(file, buf, count, pos); |
| 2771 | Could not fetch register "orig_rax"; remote failure reply 'E00' |
| 2772 | (gdb) c |
| 2773 | Continuing. |
| 2774 | }}} |
| 2775 | |
| 2776 | * s0711489@ubuntu-lucid64:~$ cat /proc/stackmod |
| 2777 | {{{ |
| 2778 | stack: 2 |
| 2779 | }}} |
| 2780 | {{{ |
| 2781 | Breakpoint 3, stackmod_proc_read (page=0xffff88001d9a9000 "stack: 0\n", |
| 2782 | start=0xffff88001b8ade90, off=0, count=3072, eof=0xffff88001b8ade9c, |
| 2783 | data=0x0) |
| 2784 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:153 |
| 2785 | 153 ) { |
| 2786 | (gdb) p stack |
| 2787 | $28 = {data = 0xffff88001b7c7940, depth = 2, errno = 0} |
| 2788 | (gdb) p stack.data[0] |
| 2789 | $29 = {length = 461142784, content = 0xffff88001b7c7988 "\210y|\033"} |
| 2790 | (gdb) p stack.data[1] |
| 2791 | $30 = {length = 0, content = 0x0} |
| 2792 | (gdb) p stack.data[2] |
| 2793 | $31 = {length = 0, |
| 2794 | content = 0x2e2e02020010e071 <Address 0x2e2e02020010e071 out of bounds>} |
| 2795 | (gdb) ptype stack |
| 2796 | type = struct kernel_module_stack { |
| 2797 | DATA *data; |
| 2798 | int depth; |
| 2799 | int errno; |
| 2800 | } |
| 2801 | (gdb) ptype stack.data |
| 2802 | type = struct kernel_module_stack_data { |
| 2803 | int length; |
| 2804 | char *content; |
| 2805 | } * |
| 2806 | (gdb) ptype stack.data[0] |
| 2807 | type = struct kernel_module_stack_data { |
| 2808 | int length; |
| 2809 | char *content; |
| 2810 | } |
| 2811 | (gdb) ptype stack.data[0].content |
| 2812 | type = char * |
| 2813 | (gdb) c |
| 2814 | Continuing. |
| 2815 | |
| 2816 | Breakpoint 3, stackmod_proc_read (page=0xffff88001d9a9000 "stack: 2\n", |
| 2817 | start=0xffff88001b8ade90, off=9, count=3072, eof=0xffff88001b8ade9c, |
| 2818 | data=0x0) |
| 2819 | at /home/ugrad/07/s0711489/coursework/KernelHack/04/stackmod/stackmod.c:153 |
| 2820 | 153 ) { |
| 2821 | (gdb) c |
| 2822 | Continuing. |
| 2823 | }}} |