From owner-svn-src-head@freebsd.org Thu Aug 6 17:49:20 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 988723A7C11; Thu, 6 Aug 2020 17:49:20 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BMwwc3Zk9z4PR1; Thu, 6 Aug 2020 17:49:20 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 594B1AD18; Thu, 6 Aug 2020 17:49:20 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 076HnKXh003458; Thu, 6 Aug 2020 17:49:20 GMT (envelope-from bdragon@FreeBSD.org) Received: (from bdragon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 076HnKxX003457; Thu, 6 Aug 2020 17:49:20 GMT (envelope-from bdragon@FreeBSD.org) Message-Id: <202008061749.076HnKxX003457@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdragon set sender to bdragon@FreeBSD.org using -f From: Brandon Bergren Date: Thu, 6 Aug 2020 17:49:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363972 - head/lib/libc/powerpc64/gen X-SVN-Group: head X-SVN-Commit-Author: bdragon X-SVN-Commit-Paths: head/lib/libc/powerpc64/gen X-SVN-Commit-Revision: 363972 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2020 17:49:20 -0000 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);