Date: Thu, 6 Aug 2020 17:49:20 +0000 (UTC) From: Brandon Bergren <bdragon@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363972 - head/lib/libc/powerpc64/gen Message-ID: <202008061749.076HnKxX003457@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdragon Date: Thu Aug 6 17:49:19 2020 New Revision: 363972 URL: https://svnweb.freebsd.org/changeset/base/363972 Log: [POWERPC] Fix ppc64 makecontext() parameter overflow handling. On ELFv2, the overflow parameters in the stack frame are at a different offset from sp than ELFv1. Adjust code to use the correct offset in all cases. This had resulted in argv[8] and up being copied to the incorrect address in the new context's initial stack frame. This is not necessarily the only bug in this function, I need to do a full review still and ensure the rest of the math is sane for ELFv2 stack frames. Reported by: pherde (Probably. My notes are a bit unclear.) Reviewed by: jhibbits (in irc) Sponsored by: Tag1 Consulting, Inc. Modified: head/lib/libc/powerpc64/gen/makecontext.c Modified: head/lib/libc/powerpc64/gen/makecontext.c ============================================================================== --- head/lib/libc/powerpc64/gen/makecontext.c Thu Aug 6 16:44:24 2020 (r363971) +++ head/lib/libc/powerpc64/gen/makecontext.c Thu Aug 6 17:49:19 2020 (r363972) @@ -102,7 +102,11 @@ __makecontext(ucontext_t *ucp, void (*start)(void), in uint64_t *argp; /* Skip past frame pointer and saved LR */ +#if !defined(_CALL_ELF) || _CALL_ELF == 1 argp = (uint64_t *)sp + 6; +#else + argp = (uint64_t *)sp + 4; +#endif for (i = 0; i < stackargs; i++) *argp++ = va_arg(ap, uint64_t);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008061749.076HnKxX003457>