Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp16290844ybl; Wed, 1 Jan 2020 02:11:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwtlpxnMDpZVrvWBWbXZhOpIRAFELYq8rqNPbnENsh4eWcRYrMc1VTwKpOej5qxg3zqT/Jm X-Received: by 2002:a17:907:2081:: with SMTP id pv1mr79407765ejb.152.1577873464238; Wed, 01 Jan 2020 02:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577873464; cv=none; d=google.com; s=arc-20160816; b=Li0fMg20gzpkhShIoizeUTf+Ug3hX+Hdmwg+DvIa6OKxQJCAyc2mrm8O5Mvq/rfWRK dAX4vheQ4u0g2PtUCAdkqz2z47ecerJ78mW5PTvbBisauXqONmXQWI1+3ZUOYFdg1XFN 8Tqxk2Ithuy4Z5lltXGnV8PpwKrGShSz47K8sVFBr5zBnNjQbgRXDZUmqsx7AWsBNVc7 fFgRN3GoxcZQmlVKzyB9jWSsGGYMcNCtv29cv7bLc+/0JifaulwCyJO3K8r6+1QisqYG lcMn4vSCXa1zY9yGpxbtNzhZARrnkLWW2612b8JOXrNmn0FtOPDAJzX3F1pscPtgyrIC c1Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=d3+bpax9WGs7ZYjnPN6v5g5h7WK/ETmXRELFstNlTA0=; b=PkFhTSrlWbQL/TMWtTEFjpDYqiMzWZVSNWbYPlXsnDq43/7n8iR8gla0yhbX2xPs5L kTy8wUAJl08MI5p5m3QWzm1C+riEUvNjfdg+6T2BypkxRWq7YjXhh6PClluBWiFFLLvR b9qkHsIWrC3AxaZ2KKOm0FtqHcbu2qhq0GyScjwNCoBttVqGSNtL1umPkEKGCMVI73EN ONwpqsrnPKxgCrkNXrRYIMb6HAp5FCFChdMHlG8EUrBp1Tq/J3QVyDO7K6boLlVw63pF BRSEVekRwhbFnF7++y3hzqlgi//9A2xiLJnpWNL7za104hA8yVav+wbkAeuw5PJaHyx6 DGDw== 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 e21si21107008ejt.130.2020.01.01.02.10.40; Wed, 01 Jan 2020 02:11:04 -0800 (PST) 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 S1726170AbgAAKH2 (ORCPT + 99 others); Wed, 1 Jan 2020 05:07:28 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:52315 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgAAKH1 (ORCPT ); Wed, 1 Jan 2020 05:07:27 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1imauH-0004P3-LA; Wed, 01 Jan 2020 11:07:13 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 456A41C2C2B; Wed, 1 Jan 2020 11:07:13 +0100 (CET) Date: Wed, 01 Jan 2020 10:07:13 -0000 From: "tip-bot2 for Jann Horn" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] x86/dumpstack: Introduce die_addr() for die() with #GP fault address Cc: Jann Horn , Borislav Petkov , Alexander Potapenko , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Dmitry Vyukov , "Eric W. Biederman" , "H. Peter Anvin" , Ingo Molnar , kasan-dev@googlegroups.com, Masami Hiramatsu , "Peter Zijlstra (Intel)" , Sean Christopherson , Thomas Gleixner , "x86-ml" , LKML In-Reply-To: <20191218231150.12139-3-jannh@google.com> References: <20191218231150.12139-3-jannh@google.com> MIME-Version: 1.0 Message-ID: <157787323316.30329.2945432496766517547.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/core branch of tip: Commit-ID: aa49f20462c90df4150f33d245cbcfe0d9c80350 Gitweb: https://git.kernel.org/tip/aa49f20462c90df4150f33d245cbcfe0d9c80350 Author: Jann Horn AuthorDate: Thu, 19 Dec 2019 00:11:49 +01:00 Committer: Borislav Petkov CommitterDate: Tue, 31 Dec 2019 13:11:35 +01:00 x86/dumpstack: Introduce die_addr() for die() with #GP fault address Split __die() into __die_header() and __die_body(). This allows inserting extra information below the header line that initiates the bug report. Introduce a new function die_addr() that behaves like die(), but is for faults only and uses __die_header() and __die_body() so that a future commit can print extra information after the header line. [ bp: Comment the KASAN-specific usage of gp_addr. ] Signed-off-by: Jann Horn Signed-off-by: Borislav Petkov Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Andy Lutomirski Cc: Dmitry Vyukov Cc: "Eric W. Biederman" Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: kasan-dev@googlegroups.com Cc: Masami Hiramatsu Cc: "Peter Zijlstra (Intel)" Cc: Sean Christopherson Cc: Thomas Gleixner Cc: x86-ml Link: https://lkml.kernel.org/r/20191218231150.12139-3-jannh@google.com --- arch/x86/include/asm/kdebug.h | 1 + arch/x86/kernel/dumpstack.c | 24 +++++++++++++++++++++++- arch/x86/kernel/traps.c | 9 ++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kdebug.h b/arch/x86/include/asm/kdebug.h index 75f1e35..247ab14 100644 --- a/arch/x86/include/asm/kdebug.h +++ b/arch/x86/include/asm/kdebug.h @@ -33,6 +33,7 @@ enum show_regs_mode { }; extern void die(const char *, struct pt_regs *,long); +void die_addr(const char *str, struct pt_regs *regs, long err, long gp_addr); extern int __must_check __die(const char *, struct pt_regs *, long); extern void show_stack_regs(struct pt_regs *regs); extern void __show_regs(struct pt_regs *regs, enum show_regs_mode); diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index e07424e..8995bf1 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -365,7 +365,7 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr) } NOKPROBE_SYMBOL(oops_end); -int __die(const char *str, struct pt_regs *regs, long err) +static void __die_header(const char *str, struct pt_regs *regs, long err) { const char *pr = ""; @@ -384,7 +384,11 @@ int __die(const char *str, struct pt_regs *regs, long err) IS_ENABLED(CONFIG_KASAN) ? " KASAN" : "", IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION) ? (boot_cpu_has(X86_FEATURE_PTI) ? " PTI" : " NOPTI") : ""); +} +NOKPROBE_SYMBOL(__die_header); +static int __die_body(const char *str, struct pt_regs *regs, long err) +{ show_regs(regs); print_modules(); @@ -394,6 +398,13 @@ int __die(const char *str, struct pt_regs *regs, long err) return 0; } +NOKPROBE_SYMBOL(__die_body); + +int __die(const char *str, struct pt_regs *regs, long err) +{ + __die_header(str, regs, err); + return __die_body(str, regs, err); +} NOKPROBE_SYMBOL(__die); /* @@ -410,6 +421,17 @@ void die(const char *str, struct pt_regs *regs, long err) oops_end(flags, regs, sig); } +void die_addr(const char *str, struct pt_regs *regs, long err, long gp_addr) +{ + unsigned long flags = oops_begin(); + int sig = SIGSEGV; + + __die_header(str, regs, err); + if (__die_body(str, regs, err)) + sig = 0; + oops_end(flags, regs, sig); +} + void show_regs(struct pt_regs *regs) { show_regs_print_info(KERN_DEFAULT); diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 108ab1e..2afd7d8 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -619,7 +619,14 @@ dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code) "maybe for address", gp_addr); - die(desc, regs, error_code); + /* + * KASAN is interested only in the non-canonical case, clear it + * otherwise. + */ + if (hint != GP_NON_CANONICAL) + gp_addr = 0; + + die_addr(desc, regs, error_code, gp_addr); return; }