git: 34005cb7d5ca - main - powerpc64: don't reserve the red zone on the alternate signal stack
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 14 Nov 2026 00:17:53 UTC
The branch main has been updated by pkubaj:
URL: https://cgit.FreeBSD.org/src/commit/?id=34005cb7d5caeee3f3073cbc2adc3b2841ef54d7
commit 34005cb7d5caeee3f3073cbc2adc3b2841ef54d7
Author: Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-10-18 10:41:37 +0000
Commit: Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-11-14 00:17:45 +0000
powerpc64: don't reserve the red zone on the alternate signal stack
A 64-bit signal frame is 1552 bytes; rounded up and with the 512 byte
red zone added it needs 2096 bytes, more than MINSIGSTKSZ (2048), so a
handler on a minimum size alternate stack had its frame start 48 bytes
below the stack. The red zone only exists below the interrupted code's
stack pointer, so skip it only when the frame goes on that stack.
A handler on a MINSIGSTKSZ alternate stack overwrote the 48 bytes below
it; the frame stays within the stack now.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61519
---
sys/powerpc/powerpc/exec_machdep.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c
index 66ee64554965..3fa136372c9b 100644
--- a/sys/powerpc/powerpc/exec_machdep.c
+++ b/sys/powerpc/powerpc/exec_machdep.c
@@ -213,11 +213,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
sfp = (caddr_t)&sf;
sfpsize = sizeof(sf);
#ifdef __powerpc64__
- /*
- * 64-bit PPC defines a 512 byte red zone below
- * the existing stack (ELF ABI v2 §2.2.2.4)
- */
- rndfsize = 512 + roundup(sizeof(sf), 48);
+ rndfsize = roundup(sizeof(sf), 48);
#else
rndfsize = roundup(sizeof(sf), 16);
#endif
@@ -252,6 +248,14 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
usfp = (void *)(((uintptr_t)td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - rndfsize) & ~0xFul);
} else {
+ #ifdef __powerpc64__
+ /*
+ * 64-bit PPC defines a 512 byte red zone below
+ * the existing stack (ELF ABI v2 §2.2.2.4)
+ */
+ if (!SV_PROC_FLAG(p, SV_ILP32))
+ sp -= 512;
+ #endif
usfp = (void *)((sp - rndfsize) & ~0xFul);
}