Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1599334rwb; Fri, 12 Aug 2022 03:55:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR5SfYkHdYXYWU+sPrHXM3XVWnYoASxtYMPqm3bsT496x8AvIuxKY+YjNBSgF/F/+0ETkNLQ X-Received: by 2002:aa7:cac7:0:b0:43a:c5ba:24a6 with SMTP id l7-20020aa7cac7000000b0043ac5ba24a6mr3060772edt.84.1660301713466; Fri, 12 Aug 2022 03:55:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660301713; cv=none; d=google.com; s=arc-20160816; b=uzDKz62iirkaIpLyqaSBAPDGGmkxJt2TMiSgW23+wQRAaaz421tSxhEYAQDJ9MoepH js8adzh646TRY1SdqSeoUmaBauyGz7FuyVFYp2EAhuC0q6uzi3JuZ7ZQSLCIDd+Vrph4 VUpUiMuHWgA07+Tv8ctEy/iJl46W4nErYCZDoKmsMmb5YyW6vqgRus6M3aWYL27Wv1OM jXPiLT5TEWLIjT+XmISBlGsFi3GD33cLA5askpnPTgjtKQPK2u090M5UEm/HtpaV1ZUL 2VPLDR/2VQZwZtlRh7ru1i9rajKy3RqFa6Wgxe0rc07w0ysQxrJHNnlMfmDZUX/y9g1s Kghg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=3nvTqnT7K3LiWJYUMML5+6yBkFhanW5C2y33qNN7G5I=; b=deQr3SlZh3lYoEP49B1m9R3BmfLGz36V+l33qu0t2dR2swXFCCcTqj+GGkwOG+ZI/Y ccNT+3rurtJxsSl/LD6N4DNDLRt0DNKruXmXkqgF4uX4qT104TOIj+t4Ekqcv87CPzDY FhXzPOuC59tnzQC8pPCsPrh7UYatRTP2evIYHSKSscoOitt3mnP3jmSNs3RFErg1gqHk wLKWU2iOnvi+yfVI3NgkYrHpSw24vfDjs9jyCudQAzjlucGlwNR5tAuGOBZ8NPtKGaQP YADH7uvnDUeljMMagTkhXb0z2d0fWiNna96Lb2ErUdN4Ts/nlY/T23qq4XcWYKEye43F TNlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qQC2SZ2K; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a50d644000000b0043c93c51cdcsi2019476edj.185.2022.08.12.03.54.48; Fri, 12 Aug 2022 03:55:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qQC2SZ2K; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237402AbiHLK25 (ORCPT + 99 others); Fri, 12 Aug 2022 06:28:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232433AbiHLK24 (ORCPT ); Fri, 12 Aug 2022 06:28:56 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B75EA6C01 for ; Fri, 12 Aug 2022 03:28:55 -0700 (PDT) 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-out1.suse.de (Postfix) with ESMTPS id 119EF3EDB7; Fri, 12 Aug 2022 10:28:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1660300134; 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=3nvTqnT7K3LiWJYUMML5+6yBkFhanW5C2y33qNN7G5I=; b=qQC2SZ2K+zGPknb6DeUDqSJz17ArNIRGdVcEv+WZwU5xf5hxmd70rNOx/MUPDzN2MmnLxV trmTK9pXjgyujQQ9y4wK285M8HSFHDAMoB1DUy61UC4zBaePAbKinFDhjsQONUfvHLDuR6 LqiQDYEsXgndazKsJDXPOZKYMwo90s0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1660300134; 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=3nvTqnT7K3LiWJYUMML5+6yBkFhanW5C2y33qNN7G5I=; b=9KLKbLUpXuZRnPN19AEZRNln6YGKTmYaqE8PYLcpSQiTd8x2UvfmyXNVqT5f5G6j2dGUSQ 5An8cGVmD11tWzCQ== 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 CFE9B13305; Fri, 12 Aug 2022 10:28:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iK31MWUr9mK2WwAAMHmgww (envelope-from ); Fri, 12 Aug 2022 10:28:53 +0000 Message-ID: Date: Fri, 12 Aug 2022 12:28:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: Re: [PATCH v2] Introduce sysfs interface to disable kfence for selected slabs. Content-Language: en-US To: Imran Khan , glider@google.com, elver@google.com, dvyukov@google.com, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org References: <20220811085938.2506536-1-imran.f.khan@oracle.com> From: Vlastimil Babka In-Reply-To: <20220811085938.2506536-1-imran.f.khan@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/11/22 10:59, Imran Khan wrote: > By default kfence allocation can happen for any slab object, whose size > is up to PAGE_SIZE, as long as that allocation is the first allocation > after expiration of kfence sample interval. But in certain debugging > scenarios we may be interested in debugging corruptions involving > some specific slub objects like dentry or ext4_* etc. In such cases > limiting kfence for allocations involving only specific slub objects > will increase the probablity of catching the issue since kfence pool > will not be consumed by other slab objects. > > This patch introduces a sysfs interface '/sys/kernel/slab//skip_kfence' > to disable kfence for specific slabs. Having the interface work in this > way does not impact current/default behavior of kfence and allows us to > use kfence for specific slabs (when needed) as well. The decision to > skip/use kfence is taken depending on whether kmem_cache.flags has > (newly introduced) SLAB_SKIP_KFENCE flag set or not. > > Signed-off-by: Imran Khan Reviewed-by: Vlastimil Babka Nit below: > --- > > Changes since v1: > - Remove RFC tag > > include/linux/slab.h | 6 ++++++ > mm/kfence/core.c | 7 +++++++ > mm/slub.c | 27 +++++++++++++++++++++++++++ > 3 files changed, 40 insertions(+) > > diff --git a/include/linux/slab.h b/include/linux/slab.h > index 0fefdf528e0d..947d912fd08c 100644 > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -119,6 +119,12 @@ > */ > #define SLAB_NO_USER_FLAGS ((slab_flags_t __force)0x10000000U) > > +#ifdef CONFIG_KFENCE > +#define SLAB_SKIP_KFENCE ((slab_flags_t __force)0x20000000U) > +#else > +#define SLAB_SKIP_KFENCE 0 > +#endif The whitespace here (spaces) differs from other flags above (tabs).