From: Benjamin LaHaise <bcrl@redhat.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@transmeta.com>
Subject: [RFC] stack check patch for x86
Date: Tue, 4 Jun 2002 23:05:23 -0400 [thread overview]
Message-ID: <20020604230523.G9111@redhat.com> (raw)
Hey all,
This patch builds upon the 4KB stack patch by adding a stack check
debug option. It is set to trigger if less than 512 bytes of the
stack are remaining, and hooks into code by means of gcc's -p option,
which inserts calls to the mcount function. When an overflow is
detected, the code switches to a safety stack, and then proceeds
to dump a backtrace and panic. Comments?
-ben
--
"You will be reincarnated as a toad; and you will be much happier."
:r ~/patches/v2.5.20/v2.5.20-stackcheck-A0.diff
diff -urN smallstack-2.5.20.diff/arch/i386/Makefile stackcheck-2.5.20.diff/arch/i386/Makefile
--- smallstack-2.5.20.diff/arch/i386/Makefile Fri May 31 23:16:35 2002
+++ stackcheck-2.5.20.diff/arch/i386/Makefile Tue Jun 4 21:10:16 2002
@@ -86,6 +86,10 @@
CFLAGS += -march=i586
endif
+ifdef CONFIG_X86_STACK_CHECK
+CFLAGS += -p
+endif
+
HEAD := arch/i386/kernel/head.o arch/i386/kernel/init_task.o
SUBDIRS += arch/i386/kernel arch/i386/mm arch/i386/lib
diff -urN smallstack-2.5.20.diff/arch/i386/boot/compressed/misc.c stackcheck-2.5.20.diff/arch/i386/boot/compressed/misc.c
--- smallstack-2.5.20.diff/arch/i386/boot/compressed/misc.c Mon Nov 12 12:59:43 2001
+++ stackcheck-2.5.20.diff/arch/i386/boot/compressed/misc.c Tue Jun 4 21:11:22 2002
@@ -381,3 +381,7 @@
if (high_loaded) close_output_buffer_if_we_run_high(mv);
return high_loaded;
}
+
+/* We don't actually check for stack overflows this early. */
+__asm__(".globl mcount ; mcount: ret\n");
+
diff -urN smallstack-2.5.20.diff/arch/i386/kernel/i386_ksyms.c stackcheck-2.5.20.diff/arch/i386/kernel/i386_ksyms.c
--- smallstack-2.5.20.diff/arch/i386/kernel/i386_ksyms.c Fri May 31 23:16:35 2002
+++ stackcheck-2.5.20.diff/arch/i386/kernel/i386_ksyms.c Tue Jun 4 21:29:09 2002
@@ -176,3 +176,8 @@
EXPORT_SYMBOL(is_sony_vaio_laptop);
EXPORT_SYMBOL(__PAGE_KERNEL);
+
+#ifdef CONFIG_X86_STACK_CHECK
+extern void mcount(void);
+EXPORT_SYMBOL(mcount);
+#endif
next reply other threads:[~2002-06-05 3:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-05 3:05 Benjamin LaHaise [this message]
2002-06-05 3:30 ` [RFC] stack check patch for x86 Benjamin LaHaise
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=20020604230523.G9111@redhat.com \
--to=bcrl@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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