Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

powerpc: Increase stack redzone for 64-bit userspace to 512 bytes

The new ELFv2 little-endian ABI increases the stack redzone -- the
area below the stack pointer that can be used for storing data --
from 288 bytes to 512 bytes. This means that we need to allow more
space on the user stack when delivering a signal to a 64-bit process.

To make the code a bit clearer, we define new USER_REDZONE_SIZE and
KERNEL_REDZONE_SIZE symbols in ptrace.h. For now, we leave the
kernel redzone size at 288 bytes, since increasing it to 512 bytes
would increase the size of interrupt stack frames correspondingly.

Gcc currently only makes use of 288 bytes of redzone even when
compiling for the new little-endian ABI, and the kernel cannot
currently be compiled with the new ABI anyway.

In the future, hopefully gcc will provide an option to control the
amount of redzone used, and then we could reduce it even more.

This also changes the code in arch_compat_alloc_user_space() to
preserve the expanded redzone. It is not clear why this function would
ever be used on a 64-bit process, though.

Signed-off-by: Paul Mackerras <paulus@samba.org>
CC: <stable@vger.kernel.org> [v3.13]
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Paul Mackerras and committed by
Benjamin Herrenschmidt
573ebfa6 a95fc585

+20 -5
+3 -2
arch/powerpc/include/asm/compat.h
··· 200 200 201 201 /* 202 202 * We can't access below the stack pointer in the 32bit ABI and 203 - * can access 288 bytes in the 64bit ABI 203 + * can access 288 bytes in the 64bit big-endian ABI, 204 + * or 512 bytes with the new ELFv2 little-endian ABI. 204 205 */ 205 206 if (!is_32bit_task()) 206 - usp -= 288; 207 + usp -= USER_REDZONE_SIZE; 207 208 208 209 return (void __user *) (usp - len); 209 210 }
+15 -1
arch/powerpc/include/asm/ptrace.h
··· 28 28 29 29 #ifdef __powerpc64__ 30 30 31 + /* 32 + * Size of redzone that userspace is allowed to use below the stack 33 + * pointer. This is 288 in the 64-bit big-endian ELF ABI, and 512 in 34 + * the new ELFv2 little-endian ABI, so we allow the larger amount. 35 + * 36 + * For kernel code we allow a 288-byte redzone, in order to conserve 37 + * kernel stack space; gcc currently only uses 288 bytes, and will 38 + * hopefully allow explicit control of the redzone size in future. 39 + */ 40 + #define USER_REDZONE_SIZE 512 41 + #define KERNEL_REDZONE_SIZE 288 42 + 31 43 #define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */ 32 44 #define STACK_FRAME_LR_SAVE 2 /* Location of LR in stack frame */ 33 45 #define STACK_FRAME_REGS_MARKER ASM_CONST(0x7265677368657265) 34 46 #define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + \ 35 - STACK_FRAME_OVERHEAD + 288) 47 + STACK_FRAME_OVERHEAD + KERNEL_REDZONE_SIZE) 36 48 #define STACK_FRAME_MARKER 12 37 49 38 50 /* Size of dummy stack frame allocated when calling signal handler. */ ··· 53 41 54 42 #else /* __powerpc64__ */ 55 43 44 + #define USER_REDZONE_SIZE 0 45 + #define KERNEL_REDZONE_SIZE 0 56 46 #define STACK_FRAME_OVERHEAD 16 /* size of minimum stack frame */ 57 47 #define STACK_FRAME_LR_SAVE 1 /* Location of LR in stack frame */ 58 48 #define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773)
+2 -2
arch/powerpc/kernel/signal_64.c
··· 65 65 struct siginfo __user *pinfo; 66 66 void __user *puc; 67 67 struct siginfo info; 68 - /* 64 bit ABI allows for 288 bytes below sp before decrementing it. */ 69 - char abigap[288]; 68 + /* New 64 bit little-endian ABI allows redzone of 512 bytes below sp */ 69 + char abigap[USER_REDZONE_SIZE]; 70 70 } __attribute__ ((aligned (16))); 71 71 72 72 static const char fmt32[] = KERN_INFO \