Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1827969imm; Mon, 3 Sep 2018 10:28:31 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYf9Hfe9EM99OGD02hkthILaFvCjKfXdErh9DtBanMasT6ZltETmqKSmwjvEy8i0T7C5Trs X-Received: by 2002:a62:565c:: with SMTP id k89-v6mr30435840pfb.212.1535995711411; Mon, 03 Sep 2018 10:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995711; cv=none; d=google.com; s=arc-20160816; b=MDhgBJkRykc6//SZdHhtlYwhkgNIwJkuPaq9dYB+EXdAcvgCFPZSpLwSGhlLT+/YFO QXie0ENvUtb+kBc9I1K1X9rwl1QQDYVMmZwheeDoRq7NEgiIVoy/ooaU4k4V6CN3dFLf 6OgFlvMUI7NBZ5CUU6LAR8xhushyJQ04QdE1bV2MBn1TEEi6T4h0htj2vjL4itA9z+cc 6g5rf+t7+AaKT86ETRvWiE9HyJMIUk8Tuvvqq6L1BbrBjdeaBOjRuvZQX+BsIpDz5S63 lovCVYIHEd+FS4S0+2/gJDUpQIl3FV1EE+pD+ZdNSlU//9NOOVeiuPBR0cULcpO7L/4d w9Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+NIP599C6h+Xs/euIdGYizbAiv8JIh2Jidzp5RncsUc=; b=Nc950IW1COlfTlgz8DxeuRg9A9Zev4g8uI+0SEQ8uSqTp/21UAM44XlXTVEpJe8mMx tyrgv7CcM5FzvcOEJsPTzcnyRG7VG1tqlZNEYI/X6cIvmSJ8cUvWXJpuCM4RSe4NP0E3 WgVhIHn5OpdD55FbCsVEDMQKUAh9dFWxlud6knqkBQ9Um5w7mcejYfhgH/FQbVrlbU4a mI8P5Jq6kV+N7NRbn/vfM3x7GbIj8rfMKdY6RsM//p9o5iRWKs3jXfcE9jUZP1eu+CCl URC7k3N3K/HQ1AF4hMMRwkJ+o4bPg4RF+OWWtkfrI6pOpQWb4fnQnwR/Jn55GEIgyj5g a2Vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30-v6si19980260pld.452.2018.09.03.10.28.16; Mon, 03 Sep 2018 10:28:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730873AbeICVr5 (ORCPT + 99 others); Mon, 3 Sep 2018 17:47:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45944 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728587AbeICVr4 (ORCPT ); Mon, 3 Sep 2018 17:47:56 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 84F85D37; Mon, 3 Sep 2018 17:26:48 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jann Horn , Thomas Gleixner , Andrey Ryabinin , Andy Lutomirski , Dmitry Vyukov , Alexander Potapenko , Kees Cook , kasan-dev@googlegroups.com Subject: [PATCH 4.14 141/165] x86/entry/64: Wipe KASAN stack shadow before rewind_stack_do_exit() Date: Mon, 3 Sep 2018 18:57:07 +0200 Message-Id: <20180903165702.609367627@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jann Horn commit f12d11c5c184626b4befdee3d573ec8237405a33 upstream. Reset the KASAN shadow state of the task stack before rewinding RSP. Without this, a kernel oops will leave parts of the stack poisoned, and code running under do_exit() can trip over such poisoned regions and cause nonsensical false-positive KASAN reports about stack-out-of-bounds bugs. This does not wipe the exception stacks; if an oops happens on an exception stack, it might result in random KASAN false-positives from other tasks afterwards. This is probably relatively uninteresting, since if the kernel oopses on an exception stack, there are most likely bigger things to worry about. It'd be more interesting if vmapped stacks and KASAN were compatible, since then handle_stack_overflow() would oops from exception stack context. Fixes: 2deb4be28077 ("x86/dumpstack: When OOPSing, rewind the stack before do_exit()") Signed-off-by: Jann Horn Signed-off-by: Thomas Gleixner Acked-by: Andrey Ryabinin Cc: Andy Lutomirski Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Kees Cook Cc: kasan-dev@googlegroups.com Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20180828184033.93712-1-jannh@google.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/dumpstack.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -298,7 +299,10 @@ void oops_end(unsigned long flags, struc * We're not going to return, but we might be on an IST stack or * have very little stack space left. Rewind the stack and kill * the task. + * Before we rewind the stack, we have to tell KASAN that we're going to + * reuse the task stack and that existing poisons are invalid. */ + kasan_unpoison_task_stack(current); rewind_stack_do_exit(signr); } NOKPROBE_SYMBOL(oops_end);