Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4166952ybl; Mon, 9 Dec 2019 06:33:04 -0800 (PST) X-Google-Smtp-Source: APXvYqy4H8+p4GfRDai8tvj4W1osFREJCvzJQZlVHyMRwdD+EuR6FnfsllyuVQm8qjpful+hJ8s8 X-Received: by 2002:a05:6808:8cd:: with SMTP id k13mr24513138oij.4.1575901984456; Mon, 09 Dec 2019 06:33:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575901984; cv=none; d=google.com; s=arc-20160816; b=dGpmnFZ749NUpAxj/PrWKT04c5sOVkIKel0GF4wlwHt5MV36Zr9nKD8Di9aFnuOet/ 2Y3bSvNUujmrVkKdAnt1gWdfumV70xpcYnsqsz9D07W/fBzCZdnqrRNt8GXgRe50xU2m tux3F/G88NNgwdfIh21yQtaknD6mvsU1oFATkhdr2WKaR2Gb1zDhRK2ClenZOXKJWS5h qUNW3huCGu1PV0GJlkl22rjeaupIZ/YqpuifMO+pqaPZXjKqVz84n73iLSHegYewXgZv TKxpiop43739uJZuSp1gPzm1ipjjDZXM54IbmMuBGPVz7UTsknhhctwWWeHBOXHVFEJE eU1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=g+A0f45IRCzFODlDzia7ir2GSqO4sEP6+0Dk2zsbcZc=; b=sjqmY+0TFF+GmG2lAOQtrUlMkZih/EFBy1OLGmuvjxNxdc1REQ6N5uaHLGErpYD1AH 0uCmEQ2azXPoq8P49Z/XAmaLZZT8e0SHSkXZ3MgTsZcijMDob4pAVaD/Kc8uCyUfra2n EonHzpgzYL9PePiH71VQ0KCxsHu0lJqs+Jb4Mhi/cQl+aJmXbwPXbVnQejiQNwpkRAjY KeXMnJKGzzcQGb8nCuPWcGv3BLT4rKjeXscSYbZojiIHnEjU0r2QtMYoo6AxWbKk89hG /Po48oO2EoFBn9P/Kl14zMOjd9EWbgJ04xqEwzjfi6VzHcvRJVCTcEMy/HAhxxVwptB2 fV+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=c7JyKFkn; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si10780605oth.136.2019.12.09.06.32.52; Mon, 09 Dec 2019 06:33: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; dkim=pass header.i=@google.com header.s=20161025 header.b=c7JyKFkn; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727669AbfLIOb6 (ORCPT + 99 others); Mon, 9 Dec 2019 09:31:58 -0500 Received: from mail-yb1-f201.google.com ([209.85.219.201]:46916 "EHLO mail-yb1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbfLIOb5 (ORCPT ); Mon, 9 Dec 2019 09:31:57 -0500 Received: by mail-yb1-f201.google.com with SMTP id o85so6026929yba.13 for ; Mon, 09 Dec 2019 06:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=g+A0f45IRCzFODlDzia7ir2GSqO4sEP6+0Dk2zsbcZc=; b=c7JyKFknTNoFsHHfV3KI79yc7otJiU8Uz/Q+2FvsP3x9h+G6tmVlpGhHKoOdu2d65j Hd4+fu0uAAQ7pQEwo3z6fZ1Jp/Se0SpE0/c4FF4Ya3uZK0Bqg9XwCaEv/dpZvIURG8Pe k+bcuwbBYP5YUyckQ02q6j2hEjugYyu2j67ALaM/lY7NCfl8+Mc65my5QZj/R591IOrj BFtsxJtu4lOii7oXXL+Cwwg4Z7SDH2cnbsLGseXXnfbNRmHdvnaiQfZJzGu2XZZDpcz7 RhFewKOfWUJArec5v99iM2cBTWJTlFKm6Lvvuf1e60sj6qEPbkAzE+MwOPXHTD7ojX2a lVFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=g+A0f45IRCzFODlDzia7ir2GSqO4sEP6+0Dk2zsbcZc=; b=ZIksCEueP1b1wXAqeL8WRtSO7WYLDsDZrDCr6/iQBQQCMLd3BGmdkndJPk9tN4/vyG vkPR3TfpYL3Iwd+Lf7feuy1r8VQxepsMh+xOmdR/oOBaKXjWLa0nh9tzS5gcxfbcJF24 Ik37ie52omcVKit509WrZLqFdAuZyMF2PiAIIRV1G2suJeWPMwTQLpwvczLA1bXryo0t H07z2MdvH2G02fjfnOCqLYWvjPGp6OUIcbmQv7b8/F5TQamYP2DsRWUzlAPK8B/acoF4 lpO8I88OufwFVYXPbaevDct2MOC3x8g5Gntk8NxxFYibPFJHs2PnmKXFk8V31c25d5Gk omXw== X-Gm-Message-State: APjAAAWpkV9Deiebr6i7ZL4YRokIg1ri+RVP/ba0tynW0bpvumoaxNKQ eG72do7s83zVfDLAoqBFxnh4pCdUDA== X-Received: by 2002:a5b:350:: with SMTP id q16mr19288549ybp.392.1575901916740; Mon, 09 Dec 2019 06:31:56 -0800 (PST) Date: Mon, 9 Dec 2019 15:31:19 +0100 In-Reply-To: <20191209143120.60100-1-jannh@google.com> Message-Id: <20191209143120.60100-3-jannh@google.com> Mime-Version: 1.0 References: <20191209143120.60100-1-jannh@google.com> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog Subject: [PATCH v6 3/4] x86/dumpstack: Split out header line printing from __die() From: Jann Horn To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev@googlegroups.com, jannh@google.com Cc: linux-kernel@vger.kernel.org, Andrey Konovalov , Andy Lutomirski , Sean Christopherson 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 Split __die() into __die_header() and __die_body(). This allows callers to insert extra information below the header line that initiates the bug report. This can e.g. be used by __die() callers to allow KASAN to print additional information below the header line of the bug report. Signed-off-by: Jann Horn --- Notes: v3: new patch v4-v6: no changes arch/x86/include/asm/kdebug.h | 3 +++ arch/x86/kernel/dumpstack.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kdebug.h b/arch/x86/include/asm/kdebug.h index 75f1e35e7c15..a0050fabce42 100644 --- a/arch/x86/include/asm/kdebug.h +++ b/arch/x86/include/asm/kdebug.h @@ -33,6 +33,9 @@ enum show_regs_mode { }; extern void die(const char *, struct pt_regs *,long); +extern void __die_header(const char *str, struct pt_regs *regs, long err); +extern int __must_check __die_body(const char *str, struct pt_regs *regs, + long err); 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 e07424e19274..6436f3f5f803 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) +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); +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); /* -- 2.24.0.393.g34dc348eaf-goog