Skip to content

Commit 3e4a1af

Browse files
committed
parisc: Check user signal stack trampoline is inside TASK_SIZE
Add some additional checks to ensure the signal stack is inside userspace bounds. Signed-off-by: Helge Deller <[email protected]>
1 parent ea4b3fc commit 3e4a1af

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

arch/parisc/kernel/signal.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,22 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs,
237237
#endif
238238

239239
usp = (regs->gr[30] & ~(0x01UL));
240+
sigframe_size = PARISC_RT_SIGFRAME_SIZE;
240241
#ifdef CONFIG_64BIT
241242
if (is_compat_task()) {
242243
/* The gcc alloca implementation leaves garbage in the upper 32 bits of sp */
243244
usp = (compat_uint_t)usp;
245+
sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
244246
}
245247
#endif
246-
/*FIXME: frame_size parameter is unused, remove it. */
247-
frame = get_sigframe(&ksig->ka, usp, sizeof(*frame));
248+
frame = get_sigframe(&ksig->ka, usp, sigframe_size);
248249

249250
DBG(1,"SETUP_RT_FRAME: START\n");
250251
DBG(1,"setup_rt_frame: frame %p info %p\n", frame, ksig->info);
251252

253+
start = (unsigned long) frame;
254+
if (start >= user_addr_max() - sigframe_size)
255+
return -EFAULT;
252256

253257
#ifdef CONFIG_64BIT
254258

@@ -343,11 +347,6 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs,
343347

344348
/* The syscall return path will create IAOQ values from r31.
345349
*/
346-
sigframe_size = PARISC_RT_SIGFRAME_SIZE;
347-
#ifdef CONFIG_64BIT
348-
if (is_compat_task())
349-
sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
350-
#endif
351350
if (in_syscall) {
352351
regs->gr[31] = haddr;
353352
#ifdef CONFIG_64BIT
@@ -518,6 +517,10 @@ insert_restart_trampoline(struct pt_regs *regs)
518517
unsigned long end = (unsigned long) &usp[5];
519518
long err = 0;
520519

520+
/* check that we don't exceed the stack */
521+
if (A(&usp[0]) >= user_addr_max() - 5 * sizeof(int))
522+
return;
523+
521524
/* Setup a trampoline to restart the syscall
522525
* with __NR_restart_syscall
523526
*

0 commit comments

Comments
 (0)