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

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: 3f17fed21491 ("um: switch to regset API and depend on XSTATE")
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20250107133509.265576-1-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Benjamin Berg and committed by
Richard Weinberger
3c2fc743 8891b176

+5 -3
+5 -3
arch/x86/um/signal.c
··· 372 372 int err = 0, sig = ksig->sig; 373 373 unsigned long fp_to; 374 374 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); 377 376 378 377 /* 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); 380 382 381 383 /* Subtract 128 for a red zone and 8 for proper alignment */ 382 384 frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8);