sparc32: Fix unaligned stack handling on trap return.

When the rett stack checking code sees the stack is unaligned (in both
the sun4c and srmmu cases) it jumps to the window fault-in path.

But that just tries to page the stack pages in, it doesn't do anything
special if the stack is misaligned.

Therefore we essentially just loop forever in the trap return path.

Fix this by emitting a SIGILL in the stack fault-in code if the stack
is mis-aligned.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2010-09-23 22:06:47 -07:00
Родитель caebf9103b
Коммит 9088333e3d
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -539,6 +539,12 @@ do_sigbus:
__do_fault_siginfo(BUS_ADRERR, SIGBUS, tsk->thread.kregs, address); __do_fault_siginfo(BUS_ADRERR, SIGBUS, tsk->thread.kregs, address);
} }
static void check_stack_aligned(unsigned long sp)
{
if (sp & 0x7UL)
force_sig(SIGILL, current);
}
void window_overflow_fault(void) void window_overflow_fault(void)
{ {
unsigned long sp; unsigned long sp;
@ -547,6 +553,8 @@ void window_overflow_fault(void)
if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
force_user_fault(sp + 0x38, 1); force_user_fault(sp + 0x38, 1);
force_user_fault(sp, 1); force_user_fault(sp, 1);
check_stack_aligned(sp);
} }
void window_underflow_fault(unsigned long sp) void window_underflow_fault(unsigned long sp)
@ -554,6 +562,8 @@ void window_underflow_fault(unsigned long sp)
if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
force_user_fault(sp + 0x38, 0); force_user_fault(sp + 0x38, 0);
force_user_fault(sp, 0); force_user_fault(sp, 0);
check_stack_aligned(sp);
} }
void window_ret_fault(struct pt_regs *regs) void window_ret_fault(struct pt_regs *regs)
@ -564,4 +574,6 @@ void window_ret_fault(struct pt_regs *regs)
if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
force_user_fault(sp + 0x38, 0); force_user_fault(sp + 0x38, 0);
force_user_fault(sp, 0); force_user_fault(sp, 0);
check_stack_aligned(sp);
} }