git: ac0cfa40876b - main - powerpc: fix an off-by-one when widening 32-bit syscall arguments
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Nov 2026 20:51:13 UTC
The branch main has been updated by pkubaj:
URL: https://cgit.FreeBSD.org/src/commit/?id=ac0cfa40876b3083bbde56d67a258324eea82842
commit ac0cfa40876b3083bbde56d67a258324eea82842
Author: Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-09-23 09:29:11 +0000
Commit: Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-11-24 20:51:05 +0000
powerpc: fix an off-by-one when widening 32-bit syscall arguments
cpu_fetch_syscall_args() widens the arguments a 32-bit syscall passes on
the stack. The loop started at narg instead of narg - 1 and wrote
td_sa.args[narg], one past the end of the eight entry array, which is
td_sigblock_ptr in struct thread. NARGREG is 8, so a plain syscall never
enters the loop, but syscall(2) and __syscall(2) lower the register count
to 7 and 6, and an eight argument syscall made that way, like
freebsd32_sendfile with its two slot off_t, corrupted the pointer.
A 32-bit program calling sendfile through syscall(2) changed its own
td_sigblock_ptr (watched with DTrace on cpu_fetch_syscall_args); it
leaves it alone now.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61884
---
sys/powerpc/powerpc/trap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c
index b04506cf10d9..6fee6505817f 100644
--- a/sys/powerpc/powerpc/trap.c
+++ b/sys/powerpc/powerpc/trap.c
@@ -731,7 +731,7 @@ cpu_fetch_syscall_args(struct thread *td)
if (SV_PROC_FLAG(p, SV_ILP32) && narg > n) {
/* Expand the size of arguments copied from the stack */
- for (i = narg; i >= n; i--)
+ for (i = narg - 1; i >= n; i--)
sa->args[i] = ((uint32_t *)(&sa->args[n]))[i-n];
}
#endif