From patchwork Wed Jun 16 16:25:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 12325627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56BD5C48BE6 for ; Wed, 16 Jun 2021 16:25:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC7656128B for ; Wed, 16 Jun 2021 16:25:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC7656128B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7AB466B0036; Wed, 16 Jun 2021 12:25:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75B706B006E; Wed, 16 Jun 2021 12:25:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D3FC6B0070; Wed, 16 Jun 2021 12:25:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id 255DE6B0036 for ; Wed, 16 Jun 2021 12:25:58 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B644CAD5A for ; Wed, 16 Jun 2021 16:25:57 +0000 (UTC) X-FDA: 78260113554.25.02660A4 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by imf28.hostedemail.com (Postfix) with ESMTP id 08770200109C for ; Wed, 16 Jun 2021 16:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1623860757; x=1655396757; h=from:to:cc:subject:date:message-id:mime-version; bh=3+Q6ffjeuIyWeUXeB/hUGVYYFCK/LW+an/k3cvbcW7E=; b=XNiR9jxF4UYs8HOc7EKDLFVJxe98y9IPLZnyEomCqrUoLJGFO1AQliZs gkc3HTaOtQRy9ysAfVhX0Rw5pbfiIJQCqgwsyoGWTHbSVpsTq6CKMEpaG G/nUxA33MvTzOehXVsYPNui/UIDzsL80zwhw5n08pIAJHSZvKa0NVj0k9 k=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 16 Jun 2021 09:25:55 -0700 X-QCInternal: smtphost Received: from nasanexm03e.na.qualcomm.com ([10.85.0.48]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/AES256-SHA; 16 Jun 2021 09:25:53 -0700 Received: from th-lint-040.qualcomm.com (10.80.80.8) by nasanexm03e.na.qualcomm.com (10.85.0.48) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 16 Jun 2021 09:25:51 -0700 From: Georgi Djakov To: , , , , , CC: , , Subject: [PATCH] mm/slub: Add taint after the errors are printed Date: Wed, 16 Jun 2021 09:25:38 -0700 Message-ID: <1623860738-146761-1-git-send-email-quic_c_gdjako@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanexm03e.na.qualcomm.com (10.85.0.48) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=XNiR9jxF; spf=pass (imf28.hostedemail.com: domain of quic_c_gdjako@quicinc.com designates 199.106.114.38 as permitted sender) smtp.mailfrom=quic_c_gdjako@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com X-Stat-Signature: 4t1x3duahowyusbjqgyph8jgh7rmqj7q X-Rspamd-Queue-Id: 08770200109C X-Rspamd-Server: rspam06 X-HE-Tag: 1623860746-61731 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When running the kernel with panic_on_taint, the usual slub debug error messages are not being printed when object corruption happens. That's because we panic in add_taint(), which is called before printing the additional information. This is a bit unfortunate as the error messages are actually very useful, especially before a panic. Let's fix this by moving add_taint() after the errors are printed on the console. Signed-off-by: Georgi Djakov Acked-by: Rafael Aquini Reviewed-by: Aaron Tomlin Acked-by: Vlastimil Babka Acked-by: David Rientjes --- mm/slub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index a8b0daa1a307..ce7b8e4551b5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -719,8 +719,6 @@ static void slab_bug(struct kmem_cache *s, char *fmt, ...) pr_err("=============================================================================\n"); pr_err("BUG %s (%s): %pV\n", s->name, print_tainted(), &vaf); pr_err("-----------------------------------------------------------------------------\n\n"); - - add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); va_end(args); } @@ -801,6 +799,7 @@ void object_err(struct kmem_cache *s, struct page *page, slab_bug(s, "%s", reason); print_trailer(s, page, object); + add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); } static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page, @@ -818,6 +817,7 @@ static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page, slab_bug(s, "%s", buf); print_page_info(page); dump_stack(); + add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); } static void init_object(struct kmem_cache *s, void *object, u8 val) @@ -869,6 +869,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page, fault, end - 1, fault - addr, fault[0], value); print_trailer(s, page, object); + add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); skip_bug_print: restore_bytes(s, what, value, fault, end);