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 C3B65C433FE for ; Wed, 29 Sep 2021 16:39:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 64D1261425 for ; Wed, 29 Sep 2021 16:39:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 64D1261425 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 99FF0940042; Wed, 29 Sep 2021 12:39:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9503894003A; Wed, 29 Sep 2021 12:39:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F042940042; Wed, 29 Sep 2021 12:39:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id 71A2394003A for ; Wed, 29 Sep 2021 12:39:16 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2B11E2D24A for ; Wed, 29 Sep 2021 16:39:16 +0000 (UTC) X-FDA: 78641171112.34.8902522 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf23.hostedemail.com (Postfix) with ESMTP id BFC7790000BB for ; Wed, 29 Sep 2021 16:39:15 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4FC0E20399; Wed, 29 Sep 2021 16:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1632933554; 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=Yesk9jGDaVQ68unRpfsU8Z5P6/4xg2xRiWVlJMEJT0Q=; b=EoIMT0byTfOkwfKDk06GWdcgGVJUNzzqOuD576os0qYpYFPYaEbExh68Qht+jRDacI/V+R ILmOHpw8Sc7Y+vGK1Qyj7tT1PtXJbpVnEHpPXRdl9iUJvTcCOoPig/eWnMzwJ56pDzHLwU tIEgI2AEug6pQbkzROTgeKAcc32/tUg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1632933554; 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=Yesk9jGDaVQ68unRpfsU8Z5P6/4xg2xRiWVlJMEJT0Q=; b=j4klpNIBQnKQD6WH2k+0tpVqUfJqoktudrK9gVQxQpk0alj9rFukGkVhhUbtZP0PMF3gnZ XV0ZM8TQehqjPmAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 14CB513FE7; Wed, 29 Sep 2021 16:39:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id M7ovBLKWVGGuPAAAMHmgww (envelope-from ); Wed, 29 Sep 2021 16:39:14 +0000 Message-ID: <9ddb1f1e-c81a-ac34-1c6a-4ececa6dbc94@suse.cz> Date: Wed, 29 Sep 2021 18:39:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Content-Language: en-US To: Matthew Wilcox , Kefeng Wang Cc: shakeelb@google.com, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Greg Kroah-Hartman References: <20210927021538.155991-1-wangkefeng.wang@huawei.com> <566f2009-6acf-4fb9-f7c0-edc1d6ce6561@suse.cz> <73b662cc-ab1f-b3bf-468a-4cd744e92d71@huawei.com> From: Vlastimil Babka Subject: Re: [PATCH resend] slub: Add back check for free nonslab objects In-Reply-To: Content-Type: text/plain; charset=UTF-8 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BFC7790000BB X-Stat-Signature: a76mmty68swfdu7ydqghmtxdeunxhc1c Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=EoIMT0by; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=j4klpNIB; spf=pass (imf23.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-HE-Tag: 1632933555-388192 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 9/28/21 17:43, Matthew Wilcox wrote: > 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 = bulk >> > > free"), the check for free nonslab page is replaced by VM_BUG_ON_P= AGE, >> > > 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 obje= cts.") >> > > add the ability, which should be needed in any configs to catch th= e >> > > invalid free, they even could be potential issue, eg, memory corru= ption, >> > > use after free and double-free, so replace VM_BUG_ON_PAGE to WARN_= ON, 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 d= ebugging >> > them will enable slub_debug or even DEBUG_VM. Why should this specia= l case >> > with nonslab pages be different? >>=20 >> I want the check back in kfree, this one is used=C2=A0 widely in drive= r, and the >> probability >>=20 >> of problem occurred is bigger in driver, especially in some out of tre= e >> drivers. >=20 > Why would we want to improve life for out of tree drivers? Drivers sho= uld > be in-tree. That's been the Linux Way for thirty years. Yes, there's a reason we distinguish VM_BUG_ON/VM_WARN_ON and plain BUG_ON/WARN_ON. Picking arbitrarily one VM_ variant check and making it always-enabled makes little sense to me, and doing it because of out of t= ree drivers is certainly not a convincing argument. Commit f227f0faf63b was correct in making it VM_BUG_ON. > 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() hel= p? >=20