Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp180245rdb; Tue, 5 Dec 2023 02:17:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQk/AFf8Ikv/kZW5YSxD9WdvwbnGUPIBAMsCxGhYAuP9eg1mOnYrF3D5Pq/F3daOIhhhnL X-Received: by 2002:a17:90b:360f:b0:286:6cc1:867a with SMTP id ml15-20020a17090b360f00b002866cc1867amr784475pjb.95.1701771454052; Tue, 05 Dec 2023 02:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701771454; cv=none; d=google.com; s=arc-20160816; b=jckjs3QOj6Fe0aUQBzwiWlgaqoD7zlqcDNJ9nyJ0eLLtFsYu8QK5JZu6qjDs0sNNKX RfSm0RSI3QWLalhNcvZd2sFuiQhB83u/wJsvtFmrDg5HEQwnqVpi/DvEqgeY0qF0TqU6 VcyLMw8y0XD2X9CjBPoFEE/Fy/1FaGP23TaT/FNKOSxdAXWh+kOh0K7ACiShMMqIWroy gH6p7ifDOEPDTn/E3PtHnLqAMoTj9L6PkAgSXwbFpg/WcMSatWra5dZQ9ANYr3DhPk07 eXDYM0zZ/a9rnFYp1b27Ew0ixLnvAJPkLOqEajiiwrDZF10ObLp2l1oa7eXtUiHZAj6z J5qw== 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; bh=L8u0GTc7MD6XLgY8Qms86a3Tg/qLA5sTEiRQbdzvIt0=; fh=06sOGDy6+X3nN0awOxb/HH+z4VuvuKLqmFUbQx9UqP4=; b=JOAy2kET4JFlSWuEPWRDAjIwQTqRpQURPC2lU8vo4kp55qhrHVMBE4+DurUgyz0g5r 0atdBMoPXGfxx5qe/EX9FKbmGfb3x1z9L0k6ZUC9z9DBjv48VHLZWGjVYOz/obP7r9U0 oT1VmhXG6tMosuaX0og42v0eQtwWyAzn7kFrEekgrpTljDMdfVT+KwXA2biJhaBQ5f6+ 8HJrs4U7fbRCA3fpjKwGinDiAQ/Asc6mV91ZhOb+IwpD5P+SPkxE8mZNr4pclOg7hirY w4fgm2YByeslM/q4pwJTHpvrKlLGxe7C5VM4w8SQhP5HlWGmXTr4fVj0PJI8C8Utqvj8 BRkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id e12-20020a170902b78c00b001c60d334996si4416737pls.622.2023.12.05.02.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:17:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 447A2807F4AB; Tue, 5 Dec 2023 02:17:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235028AbjLEKRP (ORCPT + 99 others); Tue, 5 Dec 2023 05:17:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235119AbjLEKRC (ORCPT ); Tue, 5 Dec 2023 05:17:02 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5293E181; Tue, 5 Dec 2023 02:16:58 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9D0EA2207E; Tue, 5 Dec 2023 10:16:56 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6C908136CF; Tue, 5 Dec 2023 10:16:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 3fBhGZj4bmV8aAAAD6G6ig (envelope-from ); Tue, 05 Dec 2023 10:16:56 +0000 Message-ID: <432494ef-b47f-16fa-41a0-f68613f94fc4@suse.cz> Date: Tue, 5 Dec 2023 11:16:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2 03/21] KASAN: remove code paths guarded by CONFIG_SLAB Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: David Rientjes , Christoph Lameter , Pekka Enberg , Joonsoo Kim , Andrew Morton , Roman Gushchin , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Marco Elver , Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org, linux-hardening@vger.kernel.org References: <20231120-slab-remove-slab-v2-0-9c9c70177183@suse.cz> <20231120-slab-remove-slab-v2-3-9c9c70177183@suse.cz> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Bar: ++++++++++++ X-Spam-Score: 12.84 X-Rspamd-Server: rspamd1 Authentication-Results: smtp-out1.suse.de; dkim=none; spf=softfail (smtp-out1.suse.de: 2a07:de40:b281:104:10:150:64:97 is neither permitted nor denied by domain of vbabka@suse.cz) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Queue-Id: 9D0EA2207E X-Spamd-Result: default: False [12.84 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; R_SPF_SOFTFAIL(4.60)[~all]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.cz]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; NEURAL_SPAM_SHORT(2.95)[0.983]; NEURAL_SPAM_LONG(3.50)[1.000]; RCPT_COUNT_TWELVE(0.00)[23]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[google.com,linux.com,kernel.org,lge.com,linux-foundation.org,linux.dev,gmail.com,arm.com,cmpxchg.org,chromium.org,kvack.org,vger.kernel.org,googlegroups.com]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Status: No, score=-4.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 05 Dec 2023 02:17:31 -0800 (PST) On 12/5/23 05:48, Hyeonggon Yoo wrote: > On Tue, Dec 5, 2023 at 1:27 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: >> >> On Mon, Nov 20, 2023 at 07:34:14PM +0100, Vlastimil Babka wrote: >> > With SLAB removed and SLUB the only remaining allocator, we can clean up >> > some code that was depending on the choice. >> > >> > Reviewed-by: Kees Cook >> > Reviewed-by: Marco Elver >> > Signed-off-by: Vlastimil Babka >> > --- >> > mm/kasan/common.c | 13 ++----------- >> > mm/kasan/kasan.h | 3 +-- >> > mm/kasan/quarantine.c | 7 ------- >> > 3 files changed, 3 insertions(+), 20 deletions(-) >> > >> > diff --git a/mm/kasan/common.c b/mm/kasan/common.c >> > index 256930da578a..5d95219e69d7 100644 >> > --- a/mm/kasan/common.c >> > +++ b/mm/kasan/common.c >> > @@ -153,10 +153,6 @@ void __kasan_poison_object_data(struct kmem_cache *cache, void *object) >> > * 2. A cache might be SLAB_TYPESAFE_BY_RCU, which means objects can be >> > * accessed after being freed. We preassign tags for objects in these >> > * caches as well. >> > - * 3. For SLAB allocator we can't preassign tags randomly since the freelist >> > - * is stored as an array of indexes instead of a linked list. Assign tags >> > - * based on objects indexes, so that objects that are next to each other >> > - * get different tags. >> > */ >> > static inline u8 assign_tag(struct kmem_cache *cache, >> > const void *object, bool init) >> > @@ -171,17 +167,12 @@ static inline u8 assign_tag(struct kmem_cache *cache, >> > if (!cache->ctor && !(cache->flags & SLAB_TYPESAFE_BY_RCU)) >> > return init ? KASAN_TAG_KERNEL : kasan_random_tag(); >> > >> > - /* For caches that either have a constructor or SLAB_TYPESAFE_BY_RCU: */ >> > -#ifdef CONFIG_SLAB >> > - /* For SLAB assign tags based on the object index in the freelist. */ >> > - return (u8)obj_to_index(cache, virt_to_slab(object), (void *)object); >> > -#else >> > /* >> > - * For SLUB assign a random tag during slab creation, otherwise reuse >> > + * For caches that either have a constructor or SLAB_TYPESAFE_BY_RCU, >> > + * assign a random tag during slab creation, otherwise reuse >> > * the already assigned tag. >> > */ >> > return init ? kasan_random_tag() : get_tag(object); >> > -#endif >> > } >> > >> > void * __must_check __kasan_init_slab_obj(struct kmem_cache *cache, >> > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h >> > index 8b06bab5c406..eef50233640a 100644 >> > --- a/mm/kasan/kasan.h >> > +++ b/mm/kasan/kasan.h >> > @@ -373,8 +373,7 @@ void kasan_set_track(struct kasan_track *track, gfp_t flags); >> > void kasan_save_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags); >> > void kasan_save_free_info(struct kmem_cache *cache, void *object); >> > >> > -#if defined(CONFIG_KASAN_GENERIC) && \ >> > - (defined(CONFIG_SLAB) || defined(CONFIG_SLUB)) >> > +#ifdef CONFIG_KASAN_GENERIC >> > bool kasan_quarantine_put(struct kmem_cache *cache, void *object); >> > void kasan_quarantine_reduce(void); >> > void kasan_quarantine_remove_cache(struct kmem_cache *cache); >> > diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c >> > index ca4529156735..138c57b836f2 100644 >> > --- a/mm/kasan/quarantine.c >> > +++ b/mm/kasan/quarantine.c >> > @@ -144,10 +144,6 @@ static void qlink_free(struct qlist_node *qlink, struct kmem_cache *cache) >> > { >> > void *object = qlink_to_object(qlink, cache); >> > struct kasan_free_meta *meta = kasan_get_free_meta(cache, object); >> > - unsigned long flags; >> > - >> > - if (IS_ENABLED(CONFIG_SLAB)) >> > - local_irq_save(flags); >> > >> > /* >> > * If init_on_free is enabled and KASAN's free metadata is stored in >> > @@ -166,9 +162,6 @@ static void qlink_free(struct qlist_node *qlink, struct kmem_cache *cache) >> > *(u8 *)kasan_mem_to_shadow(object) = KASAN_SLAB_FREE; >> > >> > ___cache_free(cache, object, _THIS_IP_); >> > - >> > - if (IS_ENABLED(CONFIG_SLAB)) >> > - local_irq_restore(flags); >> > } >> > >> > static void qlist_free_all(struct qlist_head *q, struct kmem_cache *cache) >> >> Looks good to me, >> Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Thanks! > nit: Some KASAN tests depends on SLUB, but as now it's the only allocator > KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); in > mm/kasan/kasan_test.c can be removed Hmm I see, but will rather also leave it for later cleanup at this point, thanks! >> >> > >> > -- >> > 2.42.1 >> > >> >