From patchwork Wed Mar 8 21:38:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9612025 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 033B860414 for ; Wed, 8 Mar 2017 21:39:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E97962862A for ; Wed, 8 Mar 2017 21:39:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD6DB28635; Wed, 8 Mar 2017 21:39:36 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 244EE2862A for ; Wed, 8 Mar 2017 21:39:35 +0000 (UTC) Received: (qmail 15569 invoked by uid 550); 8 Mar 2017 21:39:17 -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 15476 invoked from network); 8 Mar 2017 21:39:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IEHGAvXSMSXhZeJ56h3ThlgUWdXHsFK5Jou6IF9c2Ak=; b=EuiqjjWlif3i29S4SVBzFZgYET+i1TVe7nxULqFcipMu2Lg4o5vcUaZ5WIYvN+G9Q0 CW120njIMq4iH/t2oe9lkFyonTcK4gOKlAl2TQKDxqVdazV8yI44G95mKHC/6+fg3dKV HdqtQBjIInpZFww4lnWMbtwz9JZvuUQFN3hlWQLbRCG///8KWM4PzIy3d9B3ktopXdhQ nnxNNR8CcyvgZUvB1adbpUOKHZ4K2C7NfqFhzEi9OlbxYhzKCCe2vkDmZKkAOuS2K8zp t81K2xKhg0vTbiujv9MAPlW596FhFfkkA4IcQLi4hMfsPLxxWMMGIa96jkO402t1SRLg +WjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IEHGAvXSMSXhZeJ56h3ThlgUWdXHsFK5Jou6IF9c2Ak=; b=oPS9pQMUo34/IjQSYCei2hcVKjhmTZDd/L3oXD0ZF2tChAn/WOuFdkDD27NKfYg7Vd ZXgNf1WRhsmEkkrj60MQ06iZEMHMrGOuTuqxy9sSvbSMCJGH9dWxwKQhykEuAuP5w0DQ KBTJQfDBhxwCRYMuGs/GwPKVuLjq9yak813Q3UHOVduvMU2kDYoxgZnDDFuOTFqFdqyT cJi1D4zvKbAW5fyCAc7CL30vwmE8ScEQTD6kjqTTR3na6ltOktEo42P6sCcbzTnKRBTw +WqAsK6WJF13KYGMdox9T5frmwOmK7VAzMfUjSHv8Gcs4kScLhpU72L9f8Gazs0eJvFT pmpw== X-Gm-Message-State: AMke39nm7sOnJlpHyK+KjyFJE9+PCVnBLTvkV705MgldydxnscwABgBTBBYv+qu4fW7VMB22 X-Received: by 10.99.160.17 with SMTP id r17mr9412846pge.39.1489009141603; Wed, 08 Mar 2017 13:39:01 -0800 (PST) From: Thomas Garnier To: Arnd Bergmann , David Howells , Al Viro , Dave Hansen , Thomas Garnier , =?UTF-8?q?Ren=C3=A9=20Nyffenegger?= , Andrew Morton , Kees Cook , "Paul E . McKenney" , Petr Mladek , Andy Lutomirski , Ard Biesheuvel , Nicolas Pitre , Sebastian Andrzej Siewior , Sergey Senozhatsky , Helge Deller , Rik van Riel , Ingo Molnar , John Stultz , Thomas Gleixner , Oleg Nesterov , Stanislav Kinsburskiy , Pavel Tikhomirov , Stephen Smalley , Frederic Weisbecker , Ingo Molnar , "H . Peter Anvin" , Paolo Bonzini , Dmitry Safonov , Borislav Petkov , Josh Poimboeuf , Brian Gerst , Alexander Potapenko , Jan Beulich , Russell King , Will Deacon , Catalin Marinas , Mark Rutland , James Morse , Chris Metcalf , Laura Abbott , Andre Przywara Cc: linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com Date: Wed, 8 Mar 2017 13:38:43 -0800 Message-Id: <20170308213844.131877-3-thgarnie@google.com> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170308213844.131877-1-thgarnie@google.com> References: <20170308213844.131877-1-thgarnie@google.com> Subject: [kernel-hardening] [PATCH v1 3/4] arm/syscalls: Specific usage of verify_pre_usermode_state X-Virus-Scanned: ClamAV using ClamSMTP Implement specific usage of verify_pre_usermode_state for user-mode returns for arm. --- Based on next-20170308 --- arch/arm/Kconfig | 1 + arch/arm/kernel/entry-common.S | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 0d4e71b42c77..704fd8f197fa 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -12,6 +12,7 @@ config ARM select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_MIGHT_HAVE_PC_PARPORT + select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7 select ARCH_SUPPORTS_ATOMIC_RMW diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index eb5cd77bf1d8..80cfdc7fabde 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -39,6 +39,9 @@ ret_fast_syscall: UNWIND(.fnstart ) UNWIND(.cantunwind ) + push {r0} @ save returned r0 + bl verify_pre_usermode_state + pop {r0} @ restore r0 disable_irq_notrace @ disable interrupts ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK @@ -65,6 +68,7 @@ ret_fast_syscall: UNWIND(.fnstart ) UNWIND(.cantunwind ) str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 + bl verify_pre_usermode_state disable_irq_notrace @ disable interrupts ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK @@ -263,6 +267,7 @@ __sys_trace: __sys_trace_return: str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 + bl verify_pre_usermode_state mov r0, sp bl syscall_trace_exit b ret_slow_syscall