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 CDA79C433EF for ; Wed, 29 Sep 2021 02:06:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2EA55613E6 for ; Wed, 29 Sep 2021 02:06:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2EA55613E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id CD87F940008; Tue, 28 Sep 2021 22:06:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C88A36B0073; Tue, 28 Sep 2021 22:06:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B772A940008; Tue, 28 Sep 2021 22:06:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id A86506B0072 for ; Tue, 28 Sep 2021 22:06:20 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5F9F6180295AE for ; Wed, 29 Sep 2021 02:06:20 +0000 (UTC) X-FDA: 78638971320.06.2A50905 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id D3568F0000A8 for ; Wed, 29 Sep 2021 02:06:19 +0000 (UTC) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HK03l35Zlz8yxP; Wed, 29 Sep 2021 10:01:39 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 29 Sep 2021 10:06:16 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Wed, 29 Sep 2021 10:06:16 +0800 Message-ID: <638e3abe-4180-3ed2-e591-dc96e228e19e@huawei.com> Date: Wed, 29 Sep 2021 10:06:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [PATCH resend] slub: Add back check for free nonslab objects Content-Language: en-US To: Matthew Wilcox CC: Vlastimil Babka , , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , , References: <20210927021538.155991-1-wangkefeng.wang@huawei.com> <566f2009-6acf-4fb9-f7c0-edc1d6ce6561@suse.cz> <73b662cc-ab1f-b3bf-468a-4cd744e92d71@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggeme713-chm.china.huawei.com (10.1.199.109) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D3568F0000A8 X-Stat-Signature: xtfi3pwxc79us9bfaaty3b1srii136q4 Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-HE-Tag: 1632881179-692233 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 2021/9/28 23: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_PAGE, >>>> which only check with CONFIG_DEBUG_VM enabled, but this config may >>>> impact performance, so it only for debug. >>>> >>>> Commit ("0937502af7c9 slub: Add check for kfree() of non slab objects.") >>>> add the ability, which should be needed in any configs to catch the >>>> invalid free, they even could be potential issue, eg, memory corruption, >>>> 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 debugging >>> them will enable slub_debug or even DEBUG_VM. Why should this special case >>> with nonslab pages be different? >> >> I want the check back in kfree, this one is used  widely in driver, and the >> probability >> >> 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 should > 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? Add dump_page here because it could help us debug for memory corruption, if we think it is redundant, I could drop it in the next version. > . >