Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3aeb95d5 authored by jia zhang's avatar jia zhang Committed by Ingo Molnar
Browse files

x86_64: fix the check in stack_overflow_check



Impact: make stack overflow debug check and printout narrower

stack_overflow_check() should consider the stack usage of pt_regs, and
thus it could warn us in advance. Additionally, it looks better for
the warning time to start at INITIAL_JIFFIES.

Assuming that rsp gets close to the check point before interrupt
arrives: when interrupt really happens, thread_info will be partly
overrode.

Signed-off-by: default avatarjia zhang <jia.zhang2008@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent ca9eed76
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -29,10 +29,11 @@
static inline void stack_overflow_check(struct pt_regs *regs)
{
	u64 curbase = (u64)task_stack_page(current);
	static unsigned long warned = -60*HZ;
	static unsigned long warned = INITIAL_JIFFIES - 60*HZ;

	if (regs->sp >= curbase && regs->sp <= curbase + THREAD_SIZE &&
	    regs->sp <  curbase + sizeof(struct thread_info) + 128 &&
			regs->sp < curbase + sizeof(struct thread_info) +
			sizeof(struct pt_regs) + 128 &&
			time_after(jiffies, warned + 60*HZ)) {
		printk("do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n",
		       current->comm, curbase, regs->sp);