mywiki:linux:linuxstack
This is an old revision of the document!
Table of Contents
Linux Stack Overflow and Buffer Over
| Reference | Linux Kernel Stack |
kernel Stack
exception/hard IRQ/soft IRQ stack
hardware stack: hardirt_stack array softIRQ stack: softirt_stack array
kernel Stack OverFlow
Tools
checkstack.pl
$(CROSS_COMPILE)objdump -d vmlinux | scripts/checkstack.pl [arch]
$ arm-eabi-objdummp -d vmlinux -o vmlinux-arm.S $ cat vmlinux-arm.S | scripts/checkstack.pl arm
0x0012c858 nlmclnt_reclaim [vmlinux-arm.o]: 720 0x0025748c do_tcp_getsockopt.clone.11 [vmlinux-arm.o]: 552 0x00258d04 do_tcp_setsockopt.clone.14 [vmlinux-arm.o]: 544 0x000b2db4 do_sys_poll [vmlinux-arm.o]: 532 0x00138744 semctl_main.clone.7 [vmlinux-arm.o]: 532 0x00138ec4 sys_semtimedop [vmlinux-arm.o]: 484 0x000c5618 default_file_splice_read [vmlinux-arm.o]: 436 0x00251de4 do_ip_setsockopt.clone.22 [vmlinux-arm.o]: 416 0x00191fd4 extract_buf [vmlinux-arm.o]: 408 0x0019bc24 loop_get_status_old [vmlinux-arm.o]: 396 0x000e6f88 do_task_stat [vmlinux-arm.o]: 380 0x0019b8f0 loop_set_status_old [vmlinux-arm.o]: 380 0x002078f0 snd_ctl_elem_add_user [vmlinux-arm.o]: 376 0x0026267c tcp_make_synack [vmlinux-arm.o]: 372 0x00127be4 nfs_dns_parse [vmlinux-arm.o]: 368 0x000b2240 do_select [vmlinux-arm.o]: 340 0x001f6f10 mmc_blk_issue_rw_rq [vmlinux-arm.o]: 340 0x001726a0 fb_set_var [vmlinux-arm.o]: 336 0x000c58d0 __generic_file_splice_read [vmlinux-arm.o]: 316 0x0022a074 dev_seq_printf_stats [vmlinux-arm.o]: 316 0x0006383c tracing_splice_read_pipe [vmlinux-arm.o]: 308 0x000c53c8 vmsplice_to_pipe [vmlinux-arm.o]: 308 0x002512b4 do_ip_getsockopt [vmlinux-arm.o]: 304 0x00225f68 skb_splice_bits [vmlinux-arm.o]: 300
stack_size
Below are some results for static analysis of function stack depth in the Linux kernel, using 'stack_size'. (stack_size is a custom tool written by Tim Bird, before he found out about checkstack.pl.) https://lkml.org/lkml/2011/10/18/479
$ ./stack_size vmlinux-arm
============ RESULTS =============== number of functions = 14371 max function stack depth= 736 function with max depth = nlmclnt_reclaim Function Name Stack Depth ===================== =========== __generic_file_splice_read 352 do_select 376 loop_set_status_old 392 snd_ctl_elem_add_user 408 extract_buf 432 default_file_splice_read 472 sys_semtimedop 520 semctl_main.clone.7 560 do_sys_poll 568 nlmclnt_reclaim 736
CONFIG_DEBUG_STACK_USAGE / CONFIG_DEBUG_STACKOVERFLOW
# dmesg | grep greatest
kworker/u:0 used greatest stack depth: 10564 bytes left busybox used greatest stack depth: 9512 bytes left busybox used greatest stack depth: 9504 bytes left grep used greatest stack depth: 9372 bytes left init used greatest stack depth: 9028 bytes left
#echo t >/proc/sysrq-trigger #dmesg | grep -v [[]
task PC stack pid father init S 802af8b0 932 1 0 0x00000000 kthreadd S 802af8b0 2496 2 0 0x00000000 ksoftirqd/0 S 802af8b0 2840 3 2 0x00000000 kworker/0:0 S 802af8b0 2776 4 2 0x00000000 kworker/u:0 S 802af8b0 2548 5 2 0x00000000 migration/0 S 802af8b0 2704 6 2 0x00000000 migration/1 S 802af8b0 2704 7 2 0x00000000 kworker/1:0 S 802af8b0 2560 8 2 0x00000000 ksoftirqd/1 S 802af8b0 3024 9 2 0x00000000 khelper S 802af8b0 2824 10 2 0x00000000 sync_supers S 802af8b0 2872 11 2 0x00000000 bdi-default S 802af8b0 2584 12 2 0x00000000 kblockd S 802af8b0 2824 13 2 0x00000000 khubd S 802af8b0 2744 14 2 0x00000000
mywiki/linux/linuxstack.1405868011.txt.gz · Last modified: (external edit)


