Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp55560rdb; Mon, 4 Dec 2023 20:27:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhVZz+lcjleqhk8/eMfNQiSjRsaxsFn558RuXJSixRpeRl6iRN3aAWE+c2De8pnWwdjsLo X-Received: by 2002:a17:902:f544:b0:1d0:6ffd:9e1a with SMTP id h4-20020a170902f54400b001d06ffd9e1amr6329650plf.108.1701750445177; Mon, 04 Dec 2023 20:27:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701750445; cv=none; d=google.com; s=arc-20160816; b=vssf71Lv3Pgfr7S0WhMEeAKXkfC/BbCdE38/KlpUG0KH+LkaMMOAthbRZ16Ciea2OR JqZ7Hvcu/B5kiaBRCxoT0t8GieBmQiFJn1IBXHUEyvnJV7rYYtUUMjE/uCusjkcaFhlM IZSmcXFqJ4rIBynezhgvxiBEYgFeeMEqFPLndwydwPZcxLRyM6kT+ESSPpdAk8IzVh+C HY40Fp0rbWmVws0mlR/QOfug67sm1m8MDmk4Lqr/jQqcqmaKrVMhXSlsObbBGAMkrRCD UOq34qmfWaucN5KRSlbF1zpWaSC5eTwNP9c7OToJT0ghENIzXpNvevfECbVLhP6s3AOH D+hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ECB8bTrkothGumH+K2V0Img+vaTChlA6bV4xhaiY7v4=; fh=ezGgTJoHdqijbJ6IWHiSjHZUYI0p+VPBCX/sPRmQd+E=; b=ROgcfgfY4qXYaPTXahvQLuJ1foQJT7mcYTrTUSK/YxxXkkhlcZSrmfk1AWfSc55TEw H0giYjnDWFLNnGQbRYS7IFNzbw7k/My6zJEYxp5SovhFscrqYLmqEuOIXONFPj7N6ExS wg0O1N+uZOFTK9wdLN86KnzPqUaRLCz0u8vmqHv/DGQ9BGjj2ortbmrI/JzHOILOs2V5 7QQbX4FZB4jCU8hitOmnlOGeMpAjPrhaRees75hj+rAS8lmuyCuxPjHihK+yZkp05R6N VzTGaQuCAsWRCAPusoyBUMzeoX0MMlaC1rSGrfw31fh7QVygdW8/70j3bKjktyts/qBX r8Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D8OlvDFi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m8-20020a170902768800b0019c354055d0si8700757pll.304.2023.12.04.20.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 20:27:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D8OlvDFi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 714A5806B57C; Mon, 4 Dec 2023 20:27:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbjLEE1M (ORCPT + 99 others); Mon, 4 Dec 2023 23:27:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbjLEE1L (ORCPT ); Mon, 4 Dec 2023 23:27:11 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F73138; Mon, 4 Dec 2023 20:27:17 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d048c171d6so34531685ad.1; Mon, 04 Dec 2023 20:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701750436; x=1702355236; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ECB8bTrkothGumH+K2V0Img+vaTChlA6bV4xhaiY7v4=; b=D8OlvDFigxgHKtTeGZZqjyOjVmYZC0mzXRDm/ZDOtsYBcjw6ncFwgvBzaVSuXXi/Pn Vy1lpCUwvnkAGi1CT/VJaMJwo/o9mCUgmLjI0Hmy52G70tEekbosqPc5j81tmo6XcJdg XbKKc8uguVGaIqw5D94zHht7XCedxsWnhhCGFKa8s2/e3i86iforxK9JQgzeeVPU6bD5 q/kotz5/npc75Trrz8nhp9Yd+AJzJRymSkL8Y9pN6MK42XXW8g0seLXlcZiT2l7mGQ4s ZGM2hkw4pcuvaH0BvOgB5WmEp0GGvoxM5fGfl13l8X/54msIGULVfJCvEkZajl4yWF4d Ho3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701750436; x=1702355236; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ECB8bTrkothGumH+K2V0Img+vaTChlA6bV4xhaiY7v4=; b=CEvryTyuCFEkKgpWPGyyRZoRkigXtLXROJpuMKts7AzNn0z2fNpBSeMrFctvweWOn9 0mhyJhRvIihISWQklV0DZqxhf3ri/eQK/Y+vtov8E64Xpq2r7kW9fiq8KaUQPUi43ZwZ Nj3kXpiMb7zguJzFEpUDxI31DBgXvkccWJiGC3AeUhUmuZ09WtqmcM7PztdaAVlxO3Bi yKHiqRtaLXRL8eIrS4kVycA769mfRc1aVC9MlzA0ezdH/tz2ppp+rPLxyi1ZKo4yadKQ q1le9cFpWeAcrboQcIrIeKa/t7fnE194gk907u/BJ9CSLmi1nXp/cOrgoNb/Fyin7FEm iE2w== X-Gm-Message-State: AOJu0YyonNuuHRIG9vYcJ7rOxsuDmbedVB8+0/xEaTyMEd0171yJ/4kI Ko6hfJCM4ZcPCemaV+qvQ3Q= X-Received: by 2002:a17:903:1109:b0:1d0:6ffd:9e10 with SMTP id n9-20020a170903110900b001d06ffd9e10mr5482369plh.98.1701750436129; Mon, 04 Dec 2023 20:27:16 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id u9-20020a17090341c900b001d087d2c42fsm3831273ple.24.2023.12.04.20.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 20:27:15 -0800 (PST) Date: Tue, 5 Dec 2023 13:26:52 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka 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 Subject: Re: [PATCH v2 03/21] KASAN: remove code paths guarded by CONFIG_SLAB Message-ID: References: <20231120-slab-remove-slab-v2-0-9c9c70177183@suse.cz> <20231120-slab-remove-slab-v2-3-9c9c70177183@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231120-slab-remove-slab-v2-3-9c9c70177183@suse.cz> X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 20:27:23 -0800 (PST) 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> > > -- > 2.42.1 > >