From: Arjan van de Ven <arjanv@redhat.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
kronos@kronoz.cjb.net, linux-kernel@vger.kernel.org
Subject: Re: [4KSTACK][2.6.6] Stack overflow in radeonfb
Date: Fri, 14 May 2004 11:49:23 +0200 [thread overview]
Message-ID: <20040514094923.GB29106@devserv.devel.redhat.com> (raw)
In-Reply-To: <20040513182153.1feb488b.akpm@osdl.org>
On Fri, May 14, 2004 at 11:47:39AM +0200, Andrew Morton wrote:
> There's a `make buildcheck' target in -mm (from Arjan) into which we could
> integrate such a tool. Although probably it should be a different make
> target.
I added it to buildcheck for now, based on Keith Owens' check-stack.sh
script. I added a tiny bit of perl (shudder) to it to
1) Make it print in decimal not hex
2) Filter the stack users to users of 400 bytes and higher
I arbitrarily used 400; that surely is debatable.
Greetings,
Arjan van de Ven
diff -purN linux-2.6.6/Makefile linux/Makefile
--- linux-2.6.6/Makefile 2004-05-14 09:22:43.735077088 +0200
+++ linux/Makefile 2004-05-14 11:44:40.277365864 +0200
@@ -1061,6 +1061,8 @@ versioncheck:
buildcheck:
$(PERL) scripts/reference_discarded.pl
+ sh scripts/check-stack.sh vmlinux
+ find -name "*.ko" | xargs sh scripts/check-stack.sh
endif #ifeq ($(config-targets),1)
endif #ifeq ($(mixed-targets),1)
diff -purN linux-2.6.6/scripts/check-stack.sh linux/scripts/check-stack.sh
--- linux-2.6.6/scripts/check-stack.sh 1970-01-01 01:00:00.000000000 +0100
+++ linux/scripts/check-stack.sh 2004-05-14 11:43:12.484712376 +0200
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# Written by Keith Owens, modified by Arjan van de Ven to output in deciman
+#
+# Usage : check-stack.sh vmlinux $(/sbin/modprobe -l)
+#
+# Run a compiled ix86 kernel and print large local stack usage.
+#
+# />:/{s/[<>:]*//g; h; } On lines that contain '>:' (headings like
+# c0100000 <_stext>:), remove <, > and : and hold the line. Identifies
+# the procedure and its start address.
+#
+# /subl\?.*\$0x[^,][^,][^,].*,%esp/{ Select lines containing
+# subl\?...0x...,%esp but only if there are at least 3 digits between 0x and
+# ,%esp. These are local stacks of at least 0x100 bytes.
+#
+# s/.*$0x\([^,]*\).*/\1/; Extract just the stack adjustment
+# /^[89a-f].......$/d; Ignore line with 8 digit offsets that are
+# negative. Some compilers adjust the stack on exit, seems to be related
+# to goto statements
+# G; Append the held line (procedure and start address).
+# s/\(.*\)\n.* \(.*\)/\1 \2/; Remove the newline and procedure start
+# address. Leaves just stack size and procedure name.
+# p; }; Print stack size and procedure name.
+#
+# /subl\?.*%.*,%esp/{ Selects adjustment of %esp by register, dynamic
+# arrays on stack.
+# G; Append the held line (procedure and start address).
+# s/\(.*\)\n\(.*\)/Dynamic \2 \1/; Reformat to "Dynamic", procedure
+# start address, procedure name and the instruction that adjusts the
+# stack, including its offset within the proc.
+# p; }; Print the dynamic line.
+#
+#
+# Leading spaces in the sed string are required.
+#
+# first check if it's x86, since only that arch works for now
+file vmlinux | grep 80386 > /dev/null || exit
+#
+objdump --disassemble "$@" | \
+sed -ne '/>:/{s/[<>:]*//g; h; }
+ /subl\?.*\$0x[^,][^,][^,].*,%esp/{
+ s/.*\$0x\([^,]*\).*/\1/; /^[89a-f].......$/d; G; s/\(.*\)\n.* \(.*\)/\1 \2/; p; };
+ /subl\?.*%.*,%esp/{ G; s/\(.*\)\n\(.*\)/Dynamic \2 \1/; p; }; ' | \
+ sort | \
+perl -e 'while (<>) { if (/^([0-9a-f]+)(.*)/) { $decn = hex("0x" . $1); if ($decn > 400) { print "$decn $2\n";} } }'
+
next prev parent reply other threads:[~2004-05-14 9:50 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-13 13:48 [4KSTACK][2.6.6] Stack overflow in radeonfb Kronos
2004-05-13 14:03 ` Kronos
2004-05-13 14:56 ` Kronos
2004-05-13 15:15 ` Jörn Engel
2004-05-13 15:36 ` Valdis.Kletnieks
2004-05-13 16:02 ` Jörn Engel
2004-05-13 22:56 ` Benjamin Herrenschmidt
2004-05-14 10:00 ` Jörn Engel
2004-05-13 22:55 ` Benjamin Herrenschmidt
2004-05-14 1:21 ` Andrew Morton
2004-05-14 3:26 ` Randy.Dunlap
2004-05-14 9:49 ` Arjan van de Ven [this message]
2004-05-14 11:47 ` Jörn Engel
2004-05-14 22:15 ` Andrew Morton
2004-05-14 22:56 ` Chris Wright
2004-05-14 23:18 ` Andrew Morton
2004-05-14 23:19 ` Chris Wright
2004-05-14 23:48 ` Andrew Morton
2004-05-17 10:53 ` Jörn Engel
2004-05-15 7:19 ` Arjan van de Ven
2004-05-17 23:35 ` Matt Mackall
2004-05-17 23:59 ` Andrew Morton
2004-05-26 10:06 ` Jörn Engel
2004-05-26 10:08 ` Jörn Engel
2004-05-19 10:28 ` William Lee Irwin III
2004-05-19 12:01 ` William Lee Irwin III
2004-05-26 10:17 ` Jörn Engel
[not found] ` <20040518051745.GK2151@krispykreme>
[not found] ` <20040518171136.GC28735@waste.org>
[not found] ` <20040518171959.GQ2151@krispykreme>
[not found] ` <20040518174734.GE28735@waste.org>
2004-05-26 10:14 ` Jörn Engel
2004-05-14 16:41 ` Kronos
2004-05-14 21:48 ` Benjamin Herrenschmidt
2004-05-14 22:34 ` Andrew Morton
2004-05-14 22:36 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040514094923.GB29106@devserv.devel.redhat.com \
--to=arjanv@redhat.com \
--cc=akpm@osdl.org \
--cc=benh@kernel.crashing.org \
--cc=kronos@kronoz.cjb.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox