From patchwork Fri Jun 30 15:34:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9819857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2C50603F2 for ; Fri, 30 Jun 2017 15:35:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43F1B2869D for ; Fri, 30 Jun 2017 15:35:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 362C9286AC; Fri, 30 Jun 2017 15:35:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 538C72869D for ; Fri, 30 Jun 2017 15:35:22 +0000 (UTC) Received: (qmail 30323 invoked by uid 550); 30 Jun 2017 15:35:21 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 30288 invoked from network); 30 Jun 2017 15:35:19 -0000 From: Arnd Bergmann To: Kees Cook Cc: kernel-hardening@lists.openwall.com, Ard Biesheuvel , Arnd Bergmann , Russell King , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 30 Jun 2017 17:34:43 +0200 Message-Id: <20170630153502.3327030-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:6MGNk6l+gVdzKGRqL4UGrrM91F9IcoAVPTuEjdYc35T/qRkDQrP pFPXKyyDeCli9CmEvSvYTzwgV1OAZIc6OUx5FwJUQQ129IBlUbnx7T8t/Wl4VCOISPzIyCj VFtsMFv6Y9zhYSi+q17it5ddnTdgp8VkrJTfSiao1smKFwnbv1yHDaMSUJr4TToaXoV4KGG 3kYoDPdbFOG/3csUvZe5Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:3fEc76wvi4I=:CyY/mm/oJ0B4bW4oP8Dotj t7ar79b4j+KUHoQPx7NtLfwVtDXCSm8ik0ooGn2iVEW6LgHckJ6uQIIYVmwinMipKkxVhnuKO DHaavM7wCBg7yK9wL9YACqZctXYT6GF8UV/UUbLBau/PxA8U25DnnvpBPuPp1eAkgKXyMxs5n gf76zdd/xrbdZ4Myz/w1oDbFYsdy8GwKp1iwoe58eBbEdAN+BxTruGvgm6N2HriAIxK/P5Tnx HC76Mo17yqbg303fHmzmGwyAIDdxhpuggZfAg/AcKhFyExKhZUJIjxnSsXpzdsE8CNqjRNh3/ cazkoRBNdF08p2Eeu2QfJd4qIxyaO7oJsJdOY0IvvHxYHMAQm14I9byjTsDkX7nu4dDphR901 e8Gh6vScKyKpLGyPSlDPMU0XAvc/JI/rL6jZXe5qWI7o5oOFCq9pkFhuwYUKZYVjfdrs19gZT /EUk68sxWQXNir2YQ4gmRUgrk83hu6niO+tKGh0uCD+1ysyT9bq/fS9aDwkGdts3eVfbAtzUW ZferTkLSJGT/UttYQjGl6o45M7jzcPfIBFfrfYFtGH2u1xoXjJDAx12AZXuHo08nXQ/03kG8e asJZB7LiF/ARSsJH4X4F4ERUC9fJdBkdpFYI2+FT01wjfC2sVhpSCEESXZ9UHQ/7cRuRWA2TT fMRfGbJGyIlSaMwoOF7uvSATkR81GXZUPkV+gz6h+xclG6g30U8Bhns30GY5Cy+CGiM8= Subject: [kernel-hardening] [PATCH] ARM: fix randomized task_struct X-Virus-Scanned: ClamAV using ClamSMTP With the new task struct randomization, we can run into a build failure for certain random seeds: arch/arm/kernel/entry-armv.S: Assembler messages: arch/arm/kernel/entry-armv.S:803: Error: bad immediate value for offset (4096) Only two constants in asm-offset.h are affected, and I'm changing both of them here to work correctly in all configurations. One more macro has the problem, but is currently unused, so this removes it instead of adding complexity. Suggested-by: Ard Biesheuvel Fixes: c33d8b12fbbd ("task_struct: Allow randomized layout") Signed-off-by: Arnd Bergmann --- arch/arm/kernel/entry-armv.S | 5 ++++- arch/arm/mm/proc-macros.S | 10 ++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 9f157e7c51e7..db6d22b23bd8 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -797,7 +797,10 @@ ENTRY(__switch_to) #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) ldr r7, [r2, #TI_TASK] ldr r8, =__stack_chk_guard - ldr r7, [r7, #TSK_STACK_CANARY] + .if (TSK_STACK_CANARY > PAGE_MASK) + add r7, r7, #TSK_STACK_CANARY & PAGE_MASK + .endif + ldr r7, [r7, #TSK_STACK_CANARY & ~PAGE_MASK] #endif #ifdef CONFIG_CPU_USE_DOMAINS mcr p15, 0, r6, c3, c0, 0 @ Set domain register diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S index 0d40c285bd86..2c5f2a0a708b 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -25,11 +25,6 @@ ldr \rd, [\rn, #VMA_VM_FLAGS] .endm - .macro tsk_mm, rd, rn - ldr \rd, [\rn, #TI_TASK] - ldr \rd, [\rd, #TSK_ACTIVE_MM] - .endm - /* * act_mm - get current->active_mm */ @@ -37,7 +32,10 @@ bic \rd, sp, #8128 bic \rd, \rd, #63 ldr \rd, [\rd, #TI_TASK] - ldr \rd, [\rd, #TSK_ACTIVE_MM] + .if (TSK_ACTIVE_MM > PAGE_MASK) + add \rd, \rd, #TSK_ACTIVE_MM & PAGE_MASK + .endif + ldr \rd, [\rd, #TSK_ACTIVE_MM & ~PAGE_MASK] .endm /*