Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp869068pxj; Wed, 16 Jun 2021 15:51:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSokChjd/q8p567DBq3BWs9Hdt+ZQkRZcDIMJYwA0lqiw/EX3xiGv6+cK7i7Zto5PYli3S X-Received: by 2002:a92:d20e:: with SMTP id y14mr1302711ily.21.1623883911525; Wed, 16 Jun 2021 15:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623883911; cv=none; d=google.com; s=arc-20160816; b=mJ8o8d11gU4IDWJxP04/EOJxNTKPLJWWPUt2eUYnZJPrmkx1d2TioZvqae45N3ygAO zd7KqoT22hAJm3yV1MiNhLCxDfkYyCWkQwkwxQ8j3T4XZ0Jpm+CFKZ8dj2RA23ARA/3C iYrkDRLyhdms01t49sj7QLbA+zP2qQTf4BeJ7+6xcDoSC+YKtA1XPEnH/gA0ylvdTq2I sFb/0g4NcfP7gKnTh3dc+++pzUcPFmOzJ+gev9ZjIC3HExMILPaie5yAfe1VkqkN+qAN GstHrUJrL9vFo+7+h7Q2f24Eyws2QopDpHo9s2HdgmdDXKizEK02K2ySvb7aAbLAs1Zh 1xkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=+C2lPpy1DP2wdDiyyXNK8QM0DxkX+G7aYPj0O8XRNtM=; b=xRHQV2ZUUy32RDiESEcEhcvidXiSX8EFle/zRJCesk7dPO7bLmtJPAFR0XVBdktaTb qeE+YC0MeAkBwOyFmVegMoNWwHh1JyG+jKITEHTWfeziM+WOSYRVcfDgGsz8NA89t24Z v5N322wOkM2hD95q3H/9109DYOt6rrFtRnt7hoZ37hu+BBPtaAaobLdV64bRiRsAgCBt bMg8RNRGa0QnoVPmy/oGk9zGJdcqFlTOi8zaGreaYkhZ3T9T9NI0+9pIpSiYhq6RqxPH 58Bo07eLtIuTfHQXcE/lC2BUc0DyqriRdnSkyhtUv+rDHHvHCAEqZCqOXW5hj5G0t/iP hzkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b="QL/gleAj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g76si3866607jac.120.2021.06.16.15.51.39; Wed, 16 Jun 2021 15:51:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b="QL/gleAj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235284AbhFPQ2B (ORCPT + 99 others); Wed, 16 Jun 2021 12:28:01 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:17894 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231511AbhFPQ2A (ORCPT ); Wed, 16 Jun 2021 12:28:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1623860754; x=1655396754; h=from:to:cc:subject:date:message-id:mime-version; bh=3+Q6ffjeuIyWeUXeB/hUGVYYFCK/LW+an/k3cvbcW7E=; b=QL/gleAjgIxEdlX1FMqHlL6PmsHGkAF/i6+vZABShDEXDOhh/ymi3fw8 7ELpsM2GJ/BhEhzSpzAb97EifRzRqu5ZgPa4FuoFcxvlpKHH47SGSGEWx uGJooBOLv/kIV2ZsLZNF50awDm/1fZlhfoAgC04mVgH+EaCHg/btXvtB5 M=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-02.qualcomm.com with ESMTP; 16 Jun 2021 09:25:54 -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 Content-Type: text/plain 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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);