Date: Thu, 11 Jul 2019 03:29:25 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r349906 - head/sys/powerpc/powerpc Message-ID: <201907110329.x6B3TPvv019035@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Thu Jul 11 03:29:25 2019 New Revision: 349906 URL: https://svnweb.freebsd.org/changeset/base/349906 Log: powerpc: Only worry about the lower 32 bits of SP in a 32-bit process Summary: Running a 32-bit process on a 64-bit POWER CPU may still use all 64-bits in calculations, while ignoring the upper 32 bits for addressing storage. It so happens that some processes end up with r1 (SP) having bit 31 set in some cases (33-bit address). Writing out to this 33-bit address obviosly fails. Since the CPU ignores the upper bits, we should as well. sendsig() and cpu_fetch_syscall_args() appear to be the only functions that actually rely on userspace register values for copy in/out, and cpu_fetch_syscall_args() doesn't seem to be bitten in practice yet. Reviewed By: luporl Differential Revision: https://reviews.freebsd.org/D20896 Modified: head/sys/powerpc/powerpc/exec_machdep.c Modified: head/sys/powerpc/powerpc/exec_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/exec_machdep.c Thu Jul 11 02:43:23 2019 (r349905) +++ head/sys/powerpc/powerpc/exec_machdep.c Thu Jul 11 03:29:25 2019 (r349906) @@ -144,6 +144,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask #endif size_t sfpsize; caddr_t sfp, usfp; + register_t sp; int oonstack, rndfsize; int sig; int code; @@ -155,7 +156,6 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask psp = p->p_sigacts; mtx_assert(&psp->ps_mtx, MA_OWNED); tf = td->td_frame; - oonstack = sigonstack(tf->fixreg[1]); /* * Fill siginfo structure. @@ -173,6 +173,8 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask sfp = (caddr_t)&sf32; sfpsize = sizeof(sf32); rndfsize = roundup(sizeof(sf32), 16); + sp = (uint32_t)tf->fixreg[1]; + oonstack = sigonstack(sp); /* * Save user context @@ -203,6 +205,8 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask #else rndfsize = roundup(sizeof(sf), 16); #endif + sp = tf->fixreg[1]; + oonstack = sigonstack(sp); /* * Save user context @@ -232,7 +236,7 @@ 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 { - usfp = (void *)((tf->fixreg[1] - rndfsize) & ~0xFul); + usfp = (void *)((sp - rndfsize) & ~0xFul); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907110329.x6B3TPvv019035>