From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B498C433F5 for ; Tue, 28 Sep 2021 15:46:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB09D60F44 for ; Tue, 28 Sep 2021 15:46:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AB09D60F44 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3CD866B006C; Tue, 28 Sep 2021 11:46:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37DFE900002; Tue, 28 Sep 2021 11:46:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 244E76B0072; Tue, 28 Sep 2021 11:46:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 156056B006C for ; Tue, 28 Sep 2021 11:46:33 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9F86830C86 for ; Tue, 28 Sep 2021 15:46:32 +0000 (UTC) X-FDA: 78637409424.01.B62016E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id EAF3CB0000BC for ; Tue, 28 Sep 2021 15:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=RLhInNF/UixHA5msC5kJ0h7T7fFnfbdQ3PuTDScQ7yQ=; b=PGTlv/HqmrtMPlCrC3ov+Y8nx0 hSuHDsn40aJKzrwUozP0+RkMFXLfgn5Wrxd3zjO5olAqHGRcUigcKLU0a0OJHwRrGfFD46ShRj3r6 8+Tyi4MDA5VAWtsR2ghNRJZgw70GdqimBo2GzRzj9BMx0w3PG+M74k0vHFZya28RBBjO6QGr6+CvK xaNnt3W1xRphZtBLgBDvo9Fj/rlOzJuEqiUWijxj7kXzJwp3DCsk0+bc9tZZfEiYzwNbJYL2Xa1zk PNwuRrTi3zETknPROM+tOJLyLepLnFirLjUjx1XCvkojs9EEENgdA6UrKDInA+yNFspZaczwR/BCx vFsJV2gw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVFGn-00AzHa-0U; Tue, 28 Sep 2021 15:44:32 +0000 Date: Tue, 28 Sep 2021 16:43:48 +0100 From: Matthew Wilcox To: Kefeng Wang Cc: Vlastimil Babka , shakeelb@google.com, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH resend] slub: Add back check for free nonslab objects Message-ID: References: <20210927021538.155991-1-wangkefeng.wang@huawei.com> <566f2009-6acf-4fb9-f7c0-edc1d6ce6561@suse.cz> <73b662cc-ab1f-b3bf-468a-4cd744e92d71@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <73b662cc-ab1f-b3bf-468a-4cd744e92d71@huawei.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EAF3CB0000BC X-Stat-Signature: rkxy1ae1efmsjmewiyghjunbo9adofno Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="PGTlv/Hq"; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1632843991-396827 Content-Transfer-Encoding: quoted-printable 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: On Mon, Sep 27, 2021 at 03:53:47PM +0800, Kefeng Wang wrote: > On 2021/9/27 15:22, Vlastimil Babka wrote: > > On 9/27/21 04:15, Kefeng Wang wrote: > > > After commit ("f227f0faf63b slub: fix unreclaimable slab stat for b= ulk > > > free"), the check for free nonslab page is replaced by VM_BUG_ON_PA= GE, > > > which only check with CONFIG_DEBUG_VM enabled, but this config may > > > impact performance, so it only for debug. > > >=20 > > > Commit ("0937502af7c9 slub: Add check for kfree() of non slab objec= ts.") > > > add the ability, which should be needed in any configs to catch the > > > invalid free, they even could be potential issue, eg, memory corrup= tion, > > > use after free and double-free, so replace VM_BUG_ON_PAGE to WARN_O= N, and > > > add dump_page() to help use to debug the issue. > > There are other situations in SLUB (such as with smaller allocations = that > > don't go directly to page allocator) where use after free and double-= free > > are undetected in non-debug configs, and it's expected that anyone de= bugging > > them will enable slub_debug or even DEBUG_VM. Why should this special= case > > with nonslab pages be different? >=20 > I want the check back in kfree, this one is used=A0 widely in driver, a= nd the > probability >=20 > of problem occurred is bigger in driver, especially in some out of tree > drivers. Why would we want to improve life for out of tree drivers? Drivers shoul= d be in-tree. That's been the Linux Way for thirty years. I remain sceptical that dump_page() is actually useful for debugging drivers anyway. dump_stack(), I could see -- that'll tell you which driver called kfree() on a bogus pointer. But how does dump_page() help?