From patchwork Tue Dec 10 17:28:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 22225 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3CCF5202E6 for ; Tue, 10 Dec 2013 17:28:09 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id vb8sf385483obc.0 for ; Tue, 10 Dec 2013 09:28:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=YUkvtLKmvwe4PIFkgRvSXI9wDVeDA+FB/dB1c+eTQ2k=; b=F2CJ7YwebTbjlRzs3veTIXTHOHUy0XKAqXyrIq6PZbjUKi51xQZ/a5BpS+N9KNa+ae 1WWJLMZJJIjH88RHtALsHhPYfTA3Bsw5+6NynvW3rZ9vCbgEHCgMfDp0lLUqApV3pLVc LDTGaH/w5HtEclvDXsrKTSbJ2p78dYc49MLLBJ78qLF1AjRKEOYEoybKV08TrkaEfFB/ bG+uw0qcxaRd2zNxnR4dJi8CH8Z1i12PnbkzI+RcA0s78epLz7sWxK8IdZirLchxXVeN k4T1Wm1xNYR4lwq0f8IK8VUnGPi4Q4EBzJ9OILDyD3TlseBRu2KelhhvVpdvLmOXu/UA FkXA== X-Gm-Message-State: ALoCoQmMR+k85K0F9g2N5HxbsSoCy3C+kNkKI13U6zQ+bmk4WMPOpO9UaCJKxeyXfLY5zpfyGHzU X-Received: by 10.43.76.6 with SMTP id zc6mr15178367icb.26.1386696489112; Tue, 10 Dec 2013 09:28:09 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.116.108 with SMTP id jv12ls798317qeb.18.gmail; Tue, 10 Dec 2013 09:28:08 -0800 (PST) X-Received: by 10.220.170.68 with SMTP id c4mr322003vcz.41.1386696488959; Tue, 10 Dec 2013 09:28:08 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id ta5si5330748veb.107.2013.12.10.09.28.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Dec 2013 09:28:08 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so5061955veb.16 for ; Tue, 10 Dec 2013 09:28:08 -0800 (PST) X-Received: by 10.58.178.239 with SMTP id db15mr14301997vec.9.1386696488794; Tue, 10 Dec 2013 09:28:08 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp205658vcz; Tue, 10 Dec 2013 09:28:08 -0800 (PST) X-Received: by 10.14.88.134 with SMTP id a6mr19309404eef.5.1386696487092; Tue, 10 Dec 2013 09:28:07 -0800 (PST) Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by mx.google.com with ESMTPS id h45si15257173eeo.151.2013.12.10.09.28.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Dec 2013 09:28:07 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.49 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=74.125.83.49; Received: by mail-ee0-f49.google.com with SMTP id c41so2374618eek.22 for ; Tue, 10 Dec 2013 09:28:06 -0800 (PST) X-Received: by 10.15.74.200 with SMTP id j48mr9609004eey.102.1386696486564; Tue, 10 Dec 2013 09:28:06 -0800 (PST) Received: from localhost.localdomain (cpc6-seac21-2-0-cust453.7-2.cable.virginm.net. [82.1.113.198]) by mx.google.com with ESMTPSA id o47sm43701092eem.21.2013.12.10.09.28.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 10 Dec 2013 09:28:05 -0800 (PST) Message-ID: <52A74F24.8000805@linaro.org> Date: Tue, 10 Dec 2013 17:28:04 +0000 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: libc-ports@sourceware.org CC: Patch Tracking Subject: [PATCH] ARM: Don't apply pointer encryption to the frame pointer X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The frame pointer register is rarely used for that purpose on ARM and applications that look at the contents of the jmp_buf may be relying on reading the value. Ruby uses the contents of jmp_buf to find the root set for garbage collection so relies on this pointer value being unencrypted. ports/ChangeLog.arm: 2013-12-10 Will Newton * sysdeps/arm/__longjmp.S: Don't apply pointer encryption to fp register. * sysdeps/arm/setjmp.S: Likewise. * sysdeps/arm/include/bits/setjmp.h (JMP_BUF_REGLIST): Add fp to register list, remove a4. * sysdeps/unix/sysv/linux/arm/sysdep.h: (PTR_MANGLE_LOAD): New macro. --- ports/sysdeps/arm/__longjmp.S | 4 +--- ports/sysdeps/arm/include/bits/setjmp.h | 5 ++--- ports/sysdeps/arm/setjmp.S | 4 +--- ports/sysdeps/unix/sysv/linux/arm/sysdep.h | 8 ++++++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ports/sysdeps/arm/__longjmp.S b/ports/sysdeps/arm/__longjmp.S index 894c121..aaa2d3d 100644 --- a/ports/sysdeps/arm/__longjmp.S +++ b/ports/sysdeps/arm/__longjmp.S @@ -41,14 +41,12 @@ ENTRY (__longjmp) sfi_sp sfi_breg ip, \ ldmia \B!, JMP_BUF_REGLIST #ifdef PTR_DEMANGLE - PTR_DEMANGLE (fp, a4, a3, a2) ldr a4, [ip], #4 - PTR_DEMANGLE2 (a4, a4, a3) + PTR_DEMANGLE (a4, a4, a3, a2) mov sp, a4 ldr a4, [ip], #4 PTR_DEMANGLE2 (lr, a4, a3) #else - mov fp, a4 ldr sp, [ip], #4 ldr lr, [ip], #4 #endif diff --git a/ports/sysdeps/arm/include/bits/setjmp.h b/ports/sysdeps/arm/include/bits/setjmp.h index 64505dc..7bb4f00 100644 --- a/ports/sysdeps/arm/include/bits/setjmp.h +++ b/ports/sysdeps/arm/include/bits/setjmp.h @@ -26,9 +26,8 @@ #ifndef _ISOMAC /* Register list for a ldm/stm instruction to load/store - the general registers from a __jmp_buf. The a4 register - contains fp at this point. */ -# define JMP_BUF_REGLIST {a4, v1-v6, sl} + the general registers from a __jmp_buf. */ +# define JMP_BUF_REGLIST {v1-v6, sl, fp} /* Index of __jmp_buf where the sp register resides. */ # define __JMP_BUF_SP 8 diff --git a/ports/sysdeps/arm/setjmp.S b/ports/sysdeps/arm/setjmp.S index fedd994..803591e 100644 --- a/ports/sysdeps/arm/setjmp.S +++ b/ports/sysdeps/arm/setjmp.S @@ -23,9 +23,7 @@ ENTRY (__sigsetjmp) #ifdef PTR_MANGLE - PTR_MANGLE (a4, fp, a3, ip) -#else - mov a4, fp + PTR_MANGLE_LOAD (a3, ip) #endif mov ip, r0 diff --git a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h index 6cfe4e0..ccab57e 100644 --- a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -439,8 +439,10 @@ __local_syscall_error: \ #if (defined NOT_IN_libc && defined IS_IN_rtld) || \ (!defined SHARED && (!defined NOT_IN_libc || defined IS_IN_libpthread)) # ifdef __ASSEMBLER__ +# define PTR_MANGLE_LOAD(guard, tmp) \ + LDST_PCREL(ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local)); # define PTR_MANGLE(dst, src, guard, tmp) \ - LDST_PCREL(ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local)); \ + PTR_MANGLE_LOAD(guard, tmp); \ PTR_MANGLE2(dst, src, guard) /* Use PTR_MANGLE2 for efficiency if guard is already loaded. */ # define PTR_MANGLE2(dst, src, guard) \ @@ -457,8 +459,10 @@ extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden; # endif #else # ifdef __ASSEMBLER__ +# define PTR_MANGLE_LOAD(guard, tmp) \ + LDST_GLOBAL(ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard)); # define PTR_MANGLE(dst, src, guard, tmp) \ - LDST_GLOBAL(ldr, guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard)); \ + PTR_MANGLE_LOAD(guard, tmp); \ PTR_MANGLE2(dst, src, guard) /* Use PTR_MANGLE2 for efficiency if guard is already loaded. */ # define PTR_MANGLE2(dst, src, guard) \