Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp62561rdb; Mon, 4 Dec 2023 20:48:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOks1fKhoQdCjBdZomEGg+eNYlSAnKMSFOTlBVtK7HW9+O/LyS3IrC48Kc3Pl+GngSo2uB X-Received: by 2002:a17:90b:2b4e:b0:286:b45c:f972 with SMTP id rr14-20020a17090b2b4e00b00286b45cf972mr752846pjb.44.1701751735235; Mon, 04 Dec 2023 20:48:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701751735; cv=none; d=google.com; s=arc-20160816; b=lwD8VrxNv2l3eREf+2AhZsZo6lhU23uiQrjCxbtK1BeBxYcdjmnKwTQFBJiQpClo5J EZsyFRfUPs25o9WIGKLRC2qQn3b/ib4Bz1Zc6ZOwxsxU5NVqMIVMGbyfYpBBqnmmb9rw S4yRKZBn9D+Vzgz9FVNa1zOJ5MDNF1bdadf21js5H7RxPz5jr/NQ6x5KFUaTmo08EtT3 Iw+XbQJ30be0WZdAHBeJuvogyTe0rHGC89NIEk+9t66TajdHA9ZGocAlYdQD3Gf+Guum T1/PwHqxsxdRlsrw2QRKaO2p7O/xWouNQ3TeHcBfgYfmlRCzkku9NuVmGPg5xqWfXZBr QTZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=l6U7HYB+MMDXs4im/MnwOh3wT6+xRnbqGtkbQLiIJbE=; fh=ezGgTJoHdqijbJ6IWHiSjHZUYI0p+VPBCX/sPRmQd+E=; b=PAr9rZ4ygUGU1gQM9Ca7gfOxnD1VYW5WGj7+KK/Qh/dooIDAuZTA3eH6Xm8Cgi/BjM ks1a4vO93HDCCnQq8FVcNeTBK7xcCoGMLaZ7m3aYW+TSSZdBSTEH0A2BD+LsyxDpb6sr 0VwqI9HB7wbm0BzdHi0k5jeH9We/AkIdtKZqKZiWgweMCDsN+4ZQGMnOa5njQ/cb8qSA LzTxBN+izQmDrGRdUwCWyLnDZeLENQXbPg6CCJhtbijiOQCoG6cWe053ezkq/zilF/Ni iX7uq0cR4oUZCnAF7yAMF9so+25oAZisCI1BKO3dwKGlBUtt9SROQmdmMnD9VP2YC5nN Elkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="NkCp/7ns"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id y1-20020a17090a16c100b00286530bddecsi7213940pje.105.2023.12.04.20.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 20:48:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="NkCp/7ns"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 433218057D95; Mon, 4 Dec 2023 20:48:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344090AbjLEEsP (ORCPT + 99 others); Mon, 4 Dec 2023 23:48:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjLEEsN (ORCPT ); Mon, 4 Dec 2023 23:48:13 -0500 Received: from mail-ua1-x92c.google.com (mail-ua1-x92c.google.com [IPv6:2607:f8b0:4864:20::92c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EDA6C3; Mon, 4 Dec 2023 20:48:19 -0800 (PST) Received: by mail-ua1-x92c.google.com with SMTP id a1e0cc1a2514c-7c59ac49f12so1640355241.1; Mon, 04 Dec 2023 20:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701751698; x=1702356498; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=l6U7HYB+MMDXs4im/MnwOh3wT6+xRnbqGtkbQLiIJbE=; b=NkCp/7ns32k2qkHc2tAWEEGEk4EYBXlUlVXG5Y5LTzzGG8dgXuy0LxjAhhyhPkuynO A8/M1EA4NP+VACv5tTXUM2pUJ6DL9fzkEExHhnaOHJnLFgJHjc8Yz8QbtTrfr7xlqLS7 7xmzYNvqyk4li1rmX5agcGXzVdW1Af/YcsuFX0tEypuXFl85RCLAd0YO0Xhmmuneb6g0 MP6tmGXMn9QIv1HbZXx4wojrks20qnxkSMMUGJTr7VpCHY3pChzJ9ALltQ2/BfQkIU6h BelxxYy06rNx3rl9Ec6Cpdrcj3EzZEtpvB/b6Xg/vwhlYuW8F8NICE8Gn/+imwagksRz w6Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701751698; x=1702356498; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l6U7HYB+MMDXs4im/MnwOh3wT6+xRnbqGtkbQLiIJbE=; b=hpMN6rK0O2R2/vtGGQrqVWYOpy9yYlJHARslctbWR3zdwkUWbrdFsnE2C+2foizLm3 IB/vehAzh+uTv6B0kAeQIMVAJvda35ibtO6G3OS1jLyOtDzp+kQh2oY+acQPRiFjo1a5 FgMiJ9XCdE2TuKA8N4p5jS9liOCSkDMMGd/hvNVppvOUYtoOQa+XjXNu73/mshfYE0al Nf1ux0lQkA1lz+rQk7M5gpPBUB7oVXL+zB0QyTXondaRIKdIBqzu1oB+9XfGM/rnHfCt 4T+PY/AMosJ8KfaWerlTSJSmuvkTslnnrpd72vaXsPJfwjw06N7PpUh6jcG8C6AU3e4I RCQA== X-Gm-Message-State: AOJu0YzSoeRYidf27rgOeYMNUplsgSChFdz10dLWBQdmTKmiHKzQ5TTg ReEIuQ+98y86RddGDyJnj0lUEHHAft+/SbUboHM= X-Received: by 2002:a05:6102:2dc:b0:464:77f1:f34e with SMTP id h28-20020a05610202dc00b0046477f1f34emr651042vsh.28.1701751698506; Mon, 04 Dec 2023 20:48:18 -0800 (PST) MIME-Version: 1.0 References: <20231120-slab-remove-slab-v2-0-9c9c70177183@suse.cz> <20231120-slab-remove-slab-v2-3-9c9c70177183@suse.cz> In-Reply-To: From: Hyeonggon Yoo <42.hyeyoo@gmail.com> Date: Tue, 5 Dec 2023 13:48:07 +0900 Message-ID: Subject: Re: [PATCH v2 03/21] KASAN: remove code paths guarded by CONFIG_SLAB 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,MAILING_LIST_MULTI, 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 04 Dec 2023 20:48:52 -0800 (PST) On Tue, Dec 5, 2023 at 1:27=E2=80=AFPM 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 u= p > > 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 b= e > > * accessed after being freed. We preassign tags for objects in the= se > > * caches as well. > > - * 3. For SLAB allocator we can't preassign tags randomly since the fr= eelist > > - * is stored as an array of indexes instead of a linked list. Assig= n 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 *ca= che, > > 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 *)obje= ct); > > -#else > > /* > > - * For SLUB assign a random tag during slab creation, otherwise r= euse > > + * 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, s= truct kmem_cache *cache) > > { > > void *object =3D qlink_to_object(qlink, cache); > > struct kasan_free_meta *meta =3D kasan_get_free_meta(cache, objec= t); > > - 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, st= ruct kmem_cache *cache) > > *(u8 *)kasan_mem_to_shadow(object) =3D 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 *ca= che) > > Looks good to me, > Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> 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 > > > > > -- > > 2.42.1 > > > >