From 39262cc898cdb3f6e26195aceb4e07c2b5c81df8 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 28 Mar 2011 14:44:49 -0700 Subject: [PATCH] [alpha] Fix wrong register use in ____longjmp_chk. --- ChangeLog.alpha | 5 +++++ sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S | 21 ++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ChangeLog.alpha b/ChangeLog.alpha index 82384ac..55f8768 100644 --- a/ChangeLog.alpha +++ b/ChangeLog.alpha @@ -1,3 +1,8 @@ +2011-03-28 Aurelien Jarno + + * sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S(____longjmp_chk): + Fix wrong register in stack pointer comparison. + 2011-03-01 Aurelien Jarno * sysdeps/alpha/fpu/feupdateenv.c (feupdateenv): Add libm_hidden_def. diff --git a/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S b/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S index 5194ed8..53eb0f2 100644 --- a/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S +++ b/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S @@ -1,4 +1,5 @@ -/* Copyright (C) 1992, 1994, 1997, 2006, 2010 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1994, 1997, 2006, 2010, 2011 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -58,11 +59,17 @@ ____longjmp_chk: PTR_DEMANGLE2(s3, t1) PTR_DEMANGLE2(fp, t1) #endif - cmpule t0, sp, t1 - bne t1, .Lfail + /* ??? While this is a proper test for detecting a longjmp to an + invalid frame within any given stack, the main thread stack is + located *below* almost everything in the address space. Which + means that the test at Lfail vs the signal stack will almost + certainly never pass. We ought bounds check top and bottom of + the current thread's stack. */ + cmpule s3, sp, t1 + bne t1, $Lfail .align 4 -.Lok: +$Lok: mov s0, a0 mov s1, v0 mov s3, t0 @@ -103,7 +110,7 @@ ____longjmp_chk: ret .align 4 -.Lfail: +$Lfail: cfi_restore_state lda v0, __NR_sigaltstack lda a0, 0 @@ -118,13 +125,13 @@ ____longjmp_chk: cfi_adjust_cfa_offset(-32) /* Without working sigaltstack we cannot perform the test. */ - bne a3, .Lok + bne a3, $Lok addq t0, t2, t0 /* t0 = ss_sp + ss_size */ subq t0, s3, t0 /* t0 = (ss_sp + ss_size) - new_sp */ cmpule t2, t0, t0 /* t0 = (t0 >= ss_size) */ and t0, t1, t0 /* t0 = (t0 >= ss_size) & (ss_flags & SS_ONSTACK) */ - bne t0, .Lok + bne t0, $Lok ldah a0, longjmp_msg(gp) !gprelhigh lda a0, longjmp_msg(a0) !gprellow -- 2.7.4