Received: by 10.213.65.68 with SMTP id h4csp465977imn; Tue, 13 Mar 2018 09:56:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELtIq8IPBtncm3Yqtn4hGWjTl+udpxKjHR9TMr/wVbJ6JcROlDHuckJDwGhi1uhNKsxtuQg/ X-Received: by 10.101.85.2 with SMTP id f2mr1070336pgr.210.1520960208299; Tue, 13 Mar 2018 09:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520960208; cv=none; d=google.com; s=arc-20160816; b=eXxWLvs9e65422F4BvzbFSnoFLjGw+RIIDrOTDioKbVDf2p7fGAuOTnYnYyYOhpAiu ZqhUv2nYsp4w12dt+nVjANYrKhzBPfsb6II2EQoiHB0CT3iswiPnUMxvIoczC/pS0amZ DHC/feRctuOE6XjHc08TaczvyjbYjieVPZ+fREU0gELPxhxHHyseKSYKQmZFvrxn6Kn4 jIfsYxsW4vAm/nVp8JqqFrUd3V91tzLino0Qj16MGGXrkDkWAxShuaVYtAd61JVEbfCc sXx1V7NZAdQZ7/AxO+S8h+5nu1odmTmZK1/nJTLqHat50aD1gqlPuCC32VYuVtiX7ALI nhOQ== 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=k+Y5/q6WzdN/jVxsqcDaUFI/dRuOCEqy4nZEswiizeI=; b=dWk0d/MdBClrqQR3BbqdalCfHBCU9SS6na4xfGaviKdJ25PjXBFkFBCO9MXzd/x9kY NHphN5XNBUn8gIqaJDy1jE7c0YSCVglSk0pe2fT/wygDUNbyPNVyafCkIAKNMz4CPBET lvkJze1kf172VKOxh9wlowSuRHFXF9S6kRVHNZjwCbBgoxOBMHd6CIMOoTqdqe0Issd0 Su5PR7KoM6HgNf9QIZHnCADt/GiNJNW+2WIa9W9XIYRH84vysgS31njQEBCbpXmnmS6n g8aypccGYPpP3kHv8VF3hrlQBhoa6PWP39ljkGBwdGW6TWMh0i5fY3kpn5G+LFUKJaGg N0Ug== 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 k196si343819pgc.775.2018.03.13.09.56.33; Tue, 13 Mar 2018 09:56:48 -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 S1752977AbeCMQxh (ORCPT + 99 others); Tue, 13 Mar 2018 12:53:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58934 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752333AbeCMPas (ORCPT ); Tue, 13 Mar 2018 11:30:48 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A663311A9; Tue, 13 Mar 2018 15:30:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Borislav Petkov , Richard Weinberger , Andrew Morton , Linus Torvalds Subject: [PATCH 4.15 047/146] lib/bug.c: exclude non-BUG/WARN exceptions from report_bug() Date: Tue, 13 Mar 2018 16:23:34 +0100 Message-Id: <20180313152324.265311551@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook commit 1b4cfe3c0a30dde968fb43c577a8d7e262a145ee upstream. Commit b8347c219649 ("x86/debug: Handle warnings before the notifier chain, to fix KGDB crash") changed the ordering of fixups, and did not take into account the case of x86 processing non-WARN() and non-BUG() exceptions. This would lead to output of a false BUG line with no other information. In the case of a refcount exception, it would be immediately followed by the refcount WARN(), producing very strange double-"cut here": lkdtm: attempting bad refcount_inc() overflow ------------[ cut here ]------------ Kernel BUG at 0000000065f29de5 [verbose debug info unavailable] ------------[ cut here ]------------ refcount_t overflow at lkdtm_REFCOUNT_INC_OVERFLOW+0x6b/0x90 in cat[3065], uid/euid: 0/0 WARNING: CPU: 0 PID: 3065 at kernel/panic.c:657 refcount_error_report+0x9a/0xa4 ... In the prior ordering, exceptions were searched first: do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str, ... if (fixup_exception(regs, trapnr)) return 0; - if (fixup_bug(regs, trapnr)) - return 0; - As a result, fixup_bugs()'s is_valid_bugaddr() didn't take into account needing to search the exception list first, since that had already happened. So, instead of searching the exception list twice (once in is_valid_bugaddr() and then again in fixup_exception()), just add a simple sanity check to report_bug() that will immediately bail out if a BUG() (or WARN()) entry is not found. Link: http://lkml.kernel.org/r/20180301225934.GA34350@beast Fixes: b8347c219649 ("x86/debug: Handle warnings before the notifier chain, to fix KGDB crash") Signed-off-by: Kees Cook Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Richard Weinberger Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- lib/bug.c | 2 ++ 1 file changed, 2 insertions(+) --- a/lib/bug.c +++ b/lib/bug.c @@ -150,6 +150,8 @@ enum bug_trap_type report_bug(unsigned l return BUG_TRAP_TYPE_NONE; bug = find_bug(bugaddr); + if (!bug) + return BUG_TRAP_TYPE_NONE; file = NULL; line = 0;