Patchwork mips64: fix clobbering s0 in setjmp() [BZ #22624]

login
register
mail settings
Submitter slyich@gmail.com
Date Dec. 18, 2017, 6:08 p.m.
Message ID <20171218180829.795db346@sf>
Download mbox | patch
Permalink /patch/24992/
State New
Headers show

Comments

slyich@gmail.com - Dec. 18, 2017, 6:08 p.m.
On Mon, 18 Dec 2017 17:24:03 +0000
Joseph Myers <joseph@codesourcery.com> wrote:

> Thanks, committed.

Thank you! I've also noticed that mips32 has exactly the same problem
as it copies the same code. Attached patch.
Joseph Myers - Dec. 18, 2017, 6:27 p.m.
On Mon, 18 Dec 2017, Sergei Trofimovich wrote:

> On Mon, 18 Dec 2017 17:24:03 +0000
> Joseph Myers <joseph@codesourcery.com> wrote:
> 
> > Thanks, committed.
> 
> Thank you! I've also noticed that mips32 has exactly the same problem
> as it copies the same code. Attached patch.

Thanks, committed that as well.

Patch

From bbfc828f8f8404b2d5f37f59a3186e4fc4d278a4 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyfox@gentoo.org>
Date: Sun, 17 Dec 2017 09:51:34 +0000
Subject: [PATCH] mips32: fix clobbering s0 in setjmp() [BZ #22624]

Similar to commit 1ab47db00dfbc0128119e3503d3ed640ffc4830b
("mips64: fix clobbering s0 in setjmp() [BZ #22624]")
as sysdeps/mips/setjmp_aux.c is almost an identical copy
of sysdeps/mips/mips64/setjmp_aux.c.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 sysdeps/mips/setjmp_aux.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sysdeps/mips/setjmp_aux.c b/sysdeps/mips/setjmp_aux.c
index 0052e0c4a4..176243bc51 100644
--- a/sysdeps/mips/setjmp_aux.c
+++ b/sysdeps/mips/setjmp_aux.c
@@ -23,7 +23,12 @@ 
    pointer.  We do things this way because it's difficult to reliably
    access them in C.  */
 
+/* Stack protection is disabled to avoid changing s0 (or any other
+   caller-save register) before storing it to environment.
+   See BZ #22624.  */
+
 int __attribute__ ((nomips16))
+inhibit_stack_protector
 __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
 {
 #ifdef __mips_hard_float
-- 
2.15.1