Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp908058pxj; Wed, 16 Jun 2021 16:57:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuvKxFZaCKa0AWCMcWdde4TlLQMburRGxeBD9ObRkEdKONKTq5bysfIF5UJQupxzM4KirU X-Received: by 2002:a17:906:5053:: with SMTP id e19mr2049854ejk.251.1623887834191; Wed, 16 Jun 2021 16:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623887834; cv=none; d=google.com; s=arc-20160816; b=OyPivW5jn7wvwa6D1trYEj18gp3C0vvpSXFl85CyhMZtGbtjY8jJXxomn7bAKxqCuE OUn0FmsR3/M2f0TYKjz3T3pY+vt0/mI66fLAfC/KOyDZX//6EkMeiHh/ZFW0SaQEcKxj FpEYU9oJRqQyDUniLV0o1DgMNwRCpnxDMKoWHQFNmi3S9U/HZ0jtsPrJLh1RUYWKvCd/ qaZW4I2wEidxIVso4wm9oUn4dzi6f5DUyokB4Z2ktbG7FeyL7CcCD/XEJ2rLL1n2cSNv f6XYKCZ1+L9fuZlbY1UIA1Jv1knFcar7+6KBPLNmuofFCq7SMrxIS6uNdVbdpKPJSdA7 wUVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=s+fs7aAV8Ixm3MEQCjvdFix1vBA6zB0wLCM+f4oWhXI=; b=W6QPjkZ4Ay8UGB5yPiDmBgRXvB2FC9ZYzkDFk8xqzJIujXHdX7e97cNuU8q7dz0lXJ 8NqDDlDGxYUD2nEa6IUoK4sZJjpMUgbarzYnb+mxkXr/Jim4fpkrvzbvFBUlJDUe90/r xfaMPwHEaqGX+T+Q+UYZneStV+t6UTgSoSD+Md5nDAIadaoSB2Lb1Moh60ClORyhd4Sm wsT54VDYoW0zsaSA7MZYyxsWX9p6UG0hWaxQX5zERNJrhtUYe5JWXeujMWjrtjh4iavL POsfbH4mrSOxumUIduAyay8S6IBs0NQwPiBlbxHe9Ki8xdvyygIh0pOcnArNboAr2gMi I/YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=O7JlAwcU; dkim=neutral (no key) header.i=@suse.cz; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=O7JlAwcU; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la17si3315233ejc.402.2021.06.16.16.56.51; Wed, 16 Jun 2021 16:57:14 -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=pass header.i=@suse.cz header.s=susede2_rsa header.b=O7JlAwcU; dkim=neutral (no key) header.i=@suse.cz; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=O7JlAwcU; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbhFPQgz (ORCPT + 99 others); Wed, 16 Jun 2021 12:36:55 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:43884 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230027AbhFPQgt (ORCPT ); Wed, 16 Jun 2021 12:36:49 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4497A1FD47; Wed, 16 Jun 2021 16:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623861282; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s+fs7aAV8Ixm3MEQCjvdFix1vBA6zB0wLCM+f4oWhXI=; b=O7JlAwcUMHH6qOLLwxzHvHN1KhKJwfvxw+caaPS8d4k/r+mLZP21c5z4chMmrOIsQUbtQ6 Px3vZUkGoE1SR1RRUz51xT8bzADp6Q82OMndyIq/xdATkDXTG5h3h6xlutcMddObu+sWRN xpra4PiBOVOGoa3NRvb+Bu+xp04TmHI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623861282; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s+fs7aAV8Ixm3MEQCjvdFix1vBA6zB0wLCM+f4oWhXI=; b=PmlgTN9QsbUrkCFAZUZBJcIAOGySEfcDPsuGGB3y2cDf4SYOL+lg+ks+a+41eH9UYD2GyX NdwSk+EyCAScRJAw== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 1F8ED118DD; Wed, 16 Jun 2021 16:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623861282; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s+fs7aAV8Ixm3MEQCjvdFix1vBA6zB0wLCM+f4oWhXI=; b=O7JlAwcUMHH6qOLLwxzHvHN1KhKJwfvxw+caaPS8d4k/r+mLZP21c5z4chMmrOIsQUbtQ6 Px3vZUkGoE1SR1RRUz51xT8bzADp6Q82OMndyIq/xdATkDXTG5h3h6xlutcMddObu+sWRN xpra4PiBOVOGoa3NRvb+Bu+xp04TmHI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623861282; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s+fs7aAV8Ixm3MEQCjvdFix1vBA6zB0wLCM+f4oWhXI=; b=PmlgTN9QsbUrkCFAZUZBJcIAOGySEfcDPsuGGB3y2cDf4SYOL+lg+ks+a+41eH9UYD2GyX NdwSk+EyCAScRJAw== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id QvsgByIoymCBIQAALh3uQQ (envelope-from ); Wed, 16 Jun 2021 16:34:42 +0000 Subject: Re: [PATCH] mm/slub: Add taint after the errors are printed To: Georgi Djakov , akpm@linux-foundation.org, iamjoonsoo.kim@lge.com, rientjes@google.com, penberg@kernel.org, cl@linux.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, djakov@kernel.org References: <1623860738-146761-1-git-send-email-quic_c_gdjako@quicinc.com> From: Vlastimil Babka Message-ID: <4b22baf7-582b-f1ae-a525-046a493ec85f@suse.cz> Date: Wed, 16 Jun 2021 18:34:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1623860738-146761-1-git-send-email-quic_c_gdjako@quicinc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/16/21 6:25 PM, Georgi Djakov wrote: > 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 Makes sense. While at it, I wonder if we should use LOCKDEP_STILL_OK instead of LOCKDEP_NOW_UNRELIABLE. Isn't it too pessimistic to assume that some slab's memory corruption hit some lock state? > --- > 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); >