Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1649999pxb; Wed, 9 Feb 2022 01:11:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpoD7coB6AeCXb7dVyub82oIPrgR9rG+2CpXa2v2mpXWnr1Lh2GcjSnhg4axLy+/MqxMEO X-Received: by 2002:a17:90a:7f8d:: with SMTP id m13mr1507896pjl.70.1644397863104; Wed, 09 Feb 2022 01:11:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644397863; cv=none; d=google.com; s=arc-20160816; b=JvYRPvZmkIHUqrxSUm1UbynN05KFP3WxlnIo5nbGJWDIGXJZj8m0cIok+MoGs3h4ZO D6PHwBrXLa44BGYp9VvLVXKTGhljUKZkWJiXljXFPISRE2GlKHyxiEMtqv5/RZJl99f/ uqEfHj4UY3z9fZd/RvitbQz58LNnLxY1fZXZaw5UOxRdCp7okV8DGo+z/uUt3bXSZ/MT My4Pt6OIEQmr/e7/sED3fYnZnPFNwGxA1W1Td/ERYGpxL+rAQIUjfzFYsTm+XCiLnVgx N6v3MC9DBcAJtZpyEN1H028eV2JUdNHRjCLPsV4gSuZ3WaGxvtk1UcRIOy4JtfjVywpX xgBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/wpZic7Pvz+TsDyuU6lHPsRfMMkUmLxvHW1ooX7tgs4=; b=X03NoOJ9kfMIAqOIdhuVeFzA9W+WnoWAS6rxRGY/dCFCY8S/8vxVTqdLp+4AS38Aqa 4MYgBK4umT3l+n4OEUlP3Odh+bHr+CgeFOAehyCf0Dx9xyUf5tZb3FPvoJ3VroO2x9OF OSc1ccSpUccCUEjUzK+S5JQcNZl4iWRgi3rrI5RwoBHOw5WCjNJ6snToWAiLIqbK0l6C cpco/CMFwFpmxaalUm8tp2ws6mXjp6kxI9ppyh7kYD4nJTTknwuHv9G0gugl0Fo/Var9 H/Kf6qSiKxlfUrgI4CnspnzvagYB/S0eX3DYMUz5GQT32nhfznJZyqSxTa/GhRLxk0c8 zfcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gaYYFlmO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l22si3323186pgh.543.2022.02.09.01.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 01:11:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gaYYFlmO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27401E01CE67; Wed, 9 Feb 2022 00:52:46 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385337AbiBHSna (ORCPT + 99 others); Tue, 8 Feb 2022 13:43:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385243AbiBHSmr (ORCPT ); Tue, 8 Feb 2022 13:42:47 -0500 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37966C0611DB for ; Tue, 8 Feb 2022 10:42:45 -0800 (PST) Received: by mail-yb1-xb29.google.com with SMTP id c6so52545629ybk.3 for ; Tue, 08 Feb 2022 10:42:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/wpZic7Pvz+TsDyuU6lHPsRfMMkUmLxvHW1ooX7tgs4=; b=gaYYFlmOdYHJMDrmJcxW5Vwb6rcpbXxvMdj+tvzvZIFO5haSmHbfkt7qcyyLwRH0qN jvXhDdYfMLVRHEz0YO1xiH2AafDHKpeGLOw+4zKTruz5KZOotfFkDOe5UY5ph2s8xE4n JYGPNgWjkAMarxQNA4WKxyoQCx2MRnkIt5zcb2BtCw/TOw7IzfCvQ91pHG/9ARaBM7ph haMw5YjwR8V8MIJkQOcMDB4Ah7NBJQ5COnEpzo80c/SWOrukQwfwliTM1jEL64Fv/iAm xSIDmqFV+wJpTrV2WcOjCxXdW10DQWOd6OUlhSeYqqElibpVxTlhOk5MhJW3DJ265jOy l3xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/wpZic7Pvz+TsDyuU6lHPsRfMMkUmLxvHW1ooX7tgs4=; b=DouQWH87uOu8QFcUjzUIw2TGUX8VpvPQHuJ975esjNc+OGVk2vU1xEn5894BdhtbsA n81ZB2K8Ug4OL61xIqZBy3H2oRqJOHh7WWz7XHdoF+AkZdjrZxQNnGW/MaeWOXMoaHMF q3NDnWgVnLgOQkZiKT5LRlnElfiHCDMehcuvELRWbRY4iQ3cVPQEBCvhOognvbEP6lfn MPirMxJEUJdWNAdKzK2+ZHsoAObLR9rNXfTlE0SSoi7he8B50gnOQhe/4qBNnDTziOKv tP0h5gSBGuEO24pY1bfaUor9gcyaO7iQX3Rl5j0gS6OYdcWeAh4UP/s4EV+Uk4Dsfxm+ BlYg== X-Gm-Message-State: AOAM533Dy37shQPKGTjx25q2KcUcLAbrpdytAsv+THxewOmg97IGbTI/ asDqlNaE3hPoDF/fssPVKrt3FQrQlus8GuUxHhLFyQ== X-Received: by 2002:a81:4741:: with SMTP id u62mr6495415ywa.512.1644345764183; Tue, 08 Feb 2022 10:42:44 -0800 (PST) MIME-Version: 1.0 References: <748bd5e0bad5266a4cac52ff25232bbc314b24f5.1644345308.git.andreyknvl@google.com> In-Reply-To: <748bd5e0bad5266a4cac52ff25232bbc314b24f5.1644345308.git.andreyknvl@google.com> From: Marco Elver Date: Tue, 8 Feb 2022 19:42:31 +0100 Message-ID: Subject: Re: [PATCH] kasan: test: prevent cache merging in kmem_cache_double_destroy To: andrey.konovalov@linux.dev Cc: Andrew Morton , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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 On Tue, 8 Feb 2022 at 19:37, wrote: > > From: Andrey Konovalov > > With HW_TAGS KASAN and kasan.stacktrace=off, the cache created in the > kmem_cache_double_destroy() test might get merged with an existing one. > Thus, the first kmem_cache_destroy() call won't actually destroy it > but will only descrease the refcount. This causes the test to fail. s/descrease/decrease/ > Provide an empty contructor for the created cache to prevent the cache s/contructor/constructor/ > from getting merged. > > Fixes: f98f966cd750 ("kasan: test: add test case for double-kmem_cache_destroy()") > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > lib/test_kasan.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c > index 26a5c9007653..3b413f8c8a71 100644 > --- a/lib/test_kasan.c > +++ b/lib/test_kasan.c > @@ -869,11 +869,14 @@ static void kmem_cache_invalid_free(struct kunit *test) > kmem_cache_destroy(cache); > } > > +static void empty_cache_ctor(void *object) { } > + > static void kmem_cache_double_destroy(struct kunit *test) > { > struct kmem_cache *cache; > > - cache = kmem_cache_create("test_cache", 200, 0, 0, NULL); > + /* Provide a constructor to prevent cache merging. */ > + cache = kmem_cache_create("test_cache", 200, 0, 0, empty_cache_ctor); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, cache); > kmem_cache_destroy(cache); > KUNIT_EXPECT_KASAN_FAIL(test, kmem_cache_destroy(cache)); > -- > 2.25.1 >