From patchwork Wed Mar 8 21:38:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9612027 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 4A24E60414 for ; Wed, 8 Mar 2017 21:39:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C1DF2862A for ; Wed, 8 Mar 2017 21:39:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3056628635; Wed, 8 Mar 2017 21:39:42 +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 69E442862A for ; Wed, 8 Mar 2017 21:39:41 +0000 (UTC) Received: (qmail 15612 invoked by uid 550); 8 Mar 2017 21:39:18 -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 15498 invoked from network); 8 Mar 2017 21:39:14 -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=MCVtGXS+HInCk80dLY2Q1bGnevd3gzYhGZoT2/6F4ZI=; b=N/yvQW7H/nE3bluYr5d+Dl1tJnDQ4Pw9X0YW3TNCMAPgL4kdgCgvrUoDWtvWPqOwOy rlzoCTt3fJYQztEv3Bf4SpmYjyo8dZv3DRg6RPLRXF1XSwgKs2Lx1bgWccHthUOyvEZy MHbgoLkrIEHsqAlqzKnk/cO01SVg3y+7uMUgQPSr+s2Pju5/72IIUraVhIgfATT+C+rk sX2hdXAi1/DNwO2q2iu7lmHKua77oZ+RRrMDRDqAl5KOvYOSKPCK2ouEAL2SOgF1bYdQ Wiq8SoPrHRhNvtCU1MF/gU0eOy5UZz7bEZhKvVfKHmE9Tj9fySzJie1QFWXeIxAh/2ig RwoA== 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=MCVtGXS+HInCk80dLY2Q1bGnevd3gzYhGZoT2/6F4ZI=; b=E2wG58mgPNIEmB1FkvAvIlOOjaTa6Fjk6ItYRtLDCL37dBzp9I6qmqa8OWp8PSO64R hpmK3ZbeUebo/T4/+mEkv/hd48Eoe1m17vEGsxmdjUUsDRWbp3IabdslGkIDT4ntEsmv hxigxOYE3L+8q0SjH+q6rfi8e31B3xJ+oHlVuq0BQXs/daZ5WjjaUqzG4zTsNxSqfVT7 z0Qa8NlGWURcUvtvhvCPDuEhbu10yxdjQbAp788OX6o3sW0iKmYlR5gky+lEJBeu2uDE AQnWC3Jnpvr3DFTAyBMwyzJacyI5m4xugR5PBeBPD5EKqDNDOraNBB0B6CAZq3lPH4ep jgwA== X-Gm-Message-State: AMke39ksnzVJBB6PzquPOGO6QVR9u0n2Go0qn124zwBW6H3D8txNF5DyTs9V10eX1xzJC6bY X-Received: by 10.98.103.75 with SMTP id b72mr9936464pfc.105.1489009142735; Wed, 08 Mar 2017 13:39:02 -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:44 -0800 Message-Id: <20170308213844.131877-4-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 4/4] arm64/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 arm64. --- Based on next-20170308 --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/entry.S | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 896eba61e5ed..da54774838d8 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -24,6 +24,7 @@ config ARM64 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION select ARCH_WANT_FRAME_POINTERS select ARCH_HAS_UBSAN_SANITIZE_ALL + select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE select ARM_AMBA select ARM_ARCH_TIMER select ARM_GIC diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 43512d4d7df2..b3d1d9e5c7c1 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -744,6 +744,7 @@ ENDPROC(cpu_switch_to) ret_fast_syscall: disable_irq // disable interrupts str x0, [sp, #S_X0] // returned x0 + bl verify_pre_usermode_state ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing and x2, x1, #_TIF_SYSCALL_WORK cbnz x2, ret_fast_syscall_trace @@ -771,6 +772,7 @@ work_pending: */ ret_to_user: disable_irq // disable interrupts + bl verify_pre_usermode_state ldr x1, [tsk, #TSK_TI_FLAGS] and x2, x1, #_TIF_WORK_MASK cbnz x2, work_pending