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 A1DCFC433F5 for ; Mon, 27 Sep 2021 07:22:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2C88260F48 for ; Mon, 27 Sep 2021 07:22:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2C88260F48 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 7C9126B0071; Mon, 27 Sep 2021 03:22:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7789A6B0072; Mon, 27 Sep 2021 03:22:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 640FE6B0073; Mon, 27 Sep 2021 03:22:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 564D86B0071 for ; Mon, 27 Sep 2021 03:22:25 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1C5958249980 for ; Mon, 27 Sep 2021 07:22:25 +0000 (UTC) X-FDA: 78632510250.35.B92AB5F Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf01.hostedemail.com (Postfix) with ESMTP id 9AFC45065647 for ; Mon, 27 Sep 2021 07:22:24 +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 24CDC20090; Mon, 27 Sep 2021 07:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1632727343; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=twi7tr3G0mRox0fdt3s9a0k/zFUh4epYUQC3P5pAYHo=; b=w7Vb50P3NzNYxA5AXNudFCAi8XCg/8hwLk8Utkxy6wLKocK8lS0oXYMn6UxXe4tVsJ+wrX 4yPbhB6oylqoER4uZGuCJQL1WCzNIzlkhz4z0IDo5OQNiiFXjL5fD65Jz2D5ctXclL4yXw VtYEEMSwHstaa6xVhu1uFFhpbK0TRDI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1632727343; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=twi7tr3G0mRox0fdt3s9a0k/zFUh4epYUQC3P5pAYHo=; b=4WtWXvGEp8V8Rm5+8ZT0cdHvLk4IA4m7vroQRytxijJqGwY3WvxUMNKCEaAxFL5Gupj5dJ 26560LowpYPmneCg== 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 EA28013A1E; Mon, 27 Sep 2021 07:22:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oyFvOC5xUWEOLAAAMHmgww (envelope-from ); Mon, 27 Sep 2021 07:22:22 +0000 Message-ID: <566f2009-6acf-4fb9-f7c0-edc1d6ce6561@suse.cz> Date: Mon, 27 Sep 2021 09:22:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; 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: Kefeng Wang , shakeelb@google.com, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210927021538.155991-1-wangkefeng.wang@huawei.com> From: Vlastimil Babka In-Reply-To: <20210927021538.155991-1-wangkefeng.wang@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 9AFC45065647 X-Stat-Signature: wgqxb7yqi1x1xc3dgq7yhua6pe64wtt4 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=w7Vb50P3; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4WtWXvGE; spf=pass (imf01.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam06 X-HE-Tag: 1632727344-110516 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/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? > Signed-off-by: Kefeng Wang > --- > mm/slub.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 3095b889fab4..555c2e6ccfca 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3522,7 +3522,8 @@ static inline void free_nonslab_page(struct page *page, void *object) > { > unsigned int order = compound_order(page); > > - VM_BUG_ON_PAGE(!PageCompound(page), page); > + if (WARN_ON(!PageCompound(page))) > + dump_page(page, "invalid free nonslab page"); > kfree_hook(object); > mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, -(PAGE_SIZE << order)); > __free_pages(page, order); >