Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1834626imm; Mon, 3 Sep 2018 10:38:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZq2+OU/1Qv8rm+KNGNkDrEEOsuadT4lyaj0Cz4gt3fhvC6frBu+gvePxma8U4Y/Luv7l+h X-Received: by 2002:a62:1219:: with SMTP id a25-v6mr30549623pfj.104.1535996309648; Mon, 03 Sep 2018 10:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535996309; cv=none; d=google.com; s=arc-20160816; b=agK6svfqIQr13vChuKU3cO9vQssGgw3VZzHGKy0+ld4c6aS5U9ruqGYtx7JbjdYiRL kg+HdD2WDqTTld36rBBi6jO5qIE9M1mahCJ5kS5rw3GcoDb3vyosX1SkpthrtVDt+3Ea vIn/MY6EjH/vK4OOrXqcZsk/7e3BcF493E88rERYz+tI0d+CNmxz5BQPuAsVbIlZGLHQ wGhy4wsdFv8ZcOKQs1/RJOBvaeEcg30BzU+lmwhuYdIMgZReeXSlDMNZ372+gr6zAomc K/2hwkjS206b7NRfDWP+57Cu8FtMqP0n/QLwPdjEiKM1ZeLOVWdNRXzJx99MerLvKUpK Bo2Q== 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=i2jZUw1b7mx30LQsHV2eonMDr+nmjgtYPAXgJ9ZO710=; b=oiE/K6m1ulglSEMkdsFih85Bv3j62HRynVLTRGAmcTnoacwMWPE/isotsJw8J7wCo5 ylUfMJ8kndCSmXR5MbkyskMAinpSEVuqWv4n9teP0P97qKTsyNYeAgue+D8piL0a6w3I 7Y2tdPjKvlPrxuEHfXZvQAswoAvvx6FVU0jJr8TZTP1VdOFS6P8VJv8nuMiyvgc2HHac WWgp0jvGnBiCFpqPHcLyeirgkxwdeaYwGz1fPmasqtTB/TmxMcE9yAFAAPmwN/jBLIvG o/2sa+KHs7CDi/dPk0hPMehC2Gm427lXtw3JXGfjimboJ6dgGqgd4n/r862eGrAWgQSv 0zLQ== 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 q20-v6si18120924pgb.596.2018.09.03.10.38.14; Mon, 03 Sep 2018 10:38:29 -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 S1731677AbeICV6V (ORCPT + 99 others); Mon, 3 Sep 2018 17:58:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48674 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728430AbeICV6U (ORCPT ); Mon, 3 Sep 2018 17:58:20 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1612DA95; Mon, 3 Sep 2018 17:37:09 +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.18 085/123] x86/entry/64: Wipe KASAN stack shadow before rewind_stack_do_exit() Date: Mon, 3 Sep 2018 18:57:09 +0200 Message-Id: <20180903165723.128204100@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165719.499675257@linuxfoundation.org> References: <20180903165719.499675257@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.18-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 @@ -356,7 +357,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);