Skip to content

Commit 3c2fc74

Browse files
benzearichardweinberger
authored andcommitted
um: properly align signal stack on x86_64
The stack needs to be properly aligned so 16 byte memory accesses on the stack are correct. This was broken when introducing the dynamic math register sizing as the rounding was not moved appropriately. Fixes: 3f17fed ("um: switch to regset API and depend on XSTATE") Signed-off-by: Benjamin Berg <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent 8891b17 commit 3c2fc74

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/x86/um/signal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,13 @@ int setup_signal_stack_si(unsigned long stack_top, struct ksignal *ksig,
372372
int err = 0, sig = ksig->sig;
373373
unsigned long fp_to;
374374

375-
frame = (struct rt_sigframe __user *)
376-
round_down(stack_top - sizeof(struct rt_sigframe), 16);
375+
frame = (void __user *)stack_top - sizeof(struct rt_sigframe);
377376

378377
/* Add required space for math frame */
379-
frame = (struct rt_sigframe __user *)((unsigned long)frame - math_size);
378+
frame = (void __user *)((unsigned long)frame - math_size);
379+
380+
/* ABI requires 16 byte boundary alignment */
381+
frame = (void __user *)round_down((unsigned long)frame, 16);
380382

381383
/* Subtract 128 for a red zone and 8 for proper alignment */
382384
frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8);

0 commit comments

Comments
 (0)