From patchwork Sun Oct 1 16:15:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 23273 Received: (qmail 109783 invoked by alias); 1 Oct 2017 16:16:03 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 109773 invoked by uid 89); 1 Oct 2017 16:16:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=secondly X-HELO: mtlfep02.bell.net From: John David Anglin Date: Sun, 1 Oct 2017 12:15:58 -0400 Subject: [committed] hppa: Save return pointer and correct PIC register restore in __getcontext and __setcontext To: GNU C Library Message-Id: Mime-Version: 1.0 (Apple Message framework v1085) In fixing BZ libc/22165, I noticed a couple of issues with __getcontext and __setcontext. We don't save the return pointer in either of these routines. Thus, if the epilogue is entered, we will likely fault or return to the wrong location. Secondly, the PIC register, %r19, is restored from the wrong offset in __setcontext. The attached patch fixes these issues. However, stdlib/tst-setcontext2 still fails. Dave --- John David Anglin dave.anglin@bell.net 2017-10-01 John David Anglin * sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext): Save return pointer in frame. * sysdeps/unix/sysv/linux/hppa/setcontext.S (__setcontext): Likewise. Correct offset used to restore PIC register. diff --git a/sysdeps/unix/sysv/linux/hppa/getcontext.S b/sysdeps/unix/sysv/linux/hppa/getcontext.S index b201d8fda2..79a59cd557 100644 --- a/sysdeps/unix/sysv/linux/hppa/getcontext.S +++ b/sysdeps/unix/sysv/linux/hppa/getcontext.S @@ -129,6 +129,8 @@ ENTRY(__getcontext) fstds %fr31, 0(%r1) /* Prologue */ + stw %r2, -20(%sp) + .cfi_offset 2, -20 stwm %r4, 64(%sp) .cfi_def_cfa_offset -64 .cfi_offset 4, 0 diff --git a/sysdeps/unix/sysv/linux/hppa/setcontext.S b/sysdeps/unix/sysv/linux/hppa/setcontext.S index 92cb204f8d..78357941b3 100644 --- a/sysdeps/unix/sysv/linux/hppa/setcontext.S +++ b/sysdeps/unix/sysv/linux/hppa/setcontext.S @@ -25,6 +25,8 @@ ENTRY(__setcontext) /* Prologue */ + stw %r2, -20(%sp) + .cfi_offset 2, -20 stwm %r3, 64(%sp) .cfi_def_cfa_offset -64 .cfi_offset 3, 0 @@ -151,7 +153,7 @@ ENTRY(__setcontext) /* Epilogue */ ldw -84(%r30), %r2 #ifdef PIC - ldw -96(%r30), %r19 + ldw -32(%r30), %r19 #endif bv %r0(%r2) ldwm -64(%r30), %r3