From patchwork Thu Feb 16 18:29:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 9578037 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 39591600C5 for ; Thu, 16 Feb 2017 18:29:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A710284D1 for ; Thu, 16 Feb 2017 18:29:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C20C2863C; Thu, 16 Feb 2017 18:29:51 +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 83619284D1 for ; Thu, 16 Feb 2017 18:29:48 +0000 (UTC) Received: (qmail 13850 invoked by uid 550); 16 Feb 2017 18:29:47 -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 13830 invoked from network); 16 Feb 2017 18:29:46 -0000 From: James Morse To: kernel-hardening@lists.openwall.com Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Catalin Marinas , keescook@chromium.org, Mark Rutland , panand@redhat.com, keun-o.park@darkmatter.ae Date: Thu, 16 Feb 2017 18:29:14 +0000 Message-Id: <20170216182917.19637-1-james.morse@arm.com> X-Mailer: git-send-email 2.10.1 Subject: [kernel-hardening] [PATCH v4 0/3] arm64: usercopy: Implement stack frame object validation X-Virus-Scanned: ClamAV using ClamSMTP Hi all, This version of Sahara's arch_within_stack_frames() series replaces the open-coded stack walker with a call to arm64's existing walker. Patch 2 can be tested independently with this change[0]. lkdtm's use of unallocated stack regions is a separate problem, patch 3 tries to address this. Sahara, it would be good to get your review of this! I'm afraid I omitted your patch-3 as it stopped the lkdtm test from working, I suspect its not tricking the compiler, but I haven't investigated. Thanks, James [0] Change to lkdtm to generate accesses that overlap stack frames. --------------%<-------------- --------------%<-------------- James Morse (2): arm64: Add arch_within_stack_frames() for hardened usercopy arm64/uaccess: Add hardened usercopy check for bad stack accesses Sahara (1): usercopy: create enum stack_type arch/arm64/Kconfig | 1 + arch/arm64/include/asm/thread_info.h | 7 ++++- arch/arm64/include/asm/uaccess.h | 20 +++++++++++++ arch/arm64/kernel/stacktrace.c | 54 ++++++++++++++++++++++++++++++++++-- arch/x86/include/asm/thread_info.h | 19 +++++++------ include/linux/thread_info.h | 13 +++++++-- mm/usercopy.c | 8 +----- 7 files changed, 99 insertions(+), 23 deletions(-) diff --git a/drivers/misc/lkdtm_usercopy.c b/drivers/misc/lkdtm_usercopy.c index 1dd611423d8b..fcbba3a14387 100644 --- a/drivers/misc/lkdtm_usercopy.c +++ b/drivers/misc/lkdtm_usercopy.c @@ -57,7 +57,8 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame) /* This is a pointer to outside our current stack frame. */ if (bad_frame) { - bad_stack = do_usercopy_stack_callee((uintptr_t)&bad_stack); + bad_stack = __builtin_frame_address(0); + bad_stack -= sizeof(good_stack)/2; } else { /* Put start address just inside stack. */ bad_stack = task_stack_page(current) + THREAD_SIZE;