From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D20BC433FE for ; Tue, 8 Feb 2022 18:42:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D453E6B007E; Tue, 8 Feb 2022 13:42:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CF5056B0080; Tue, 8 Feb 2022 13:42:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6E706B0081; Tue, 8 Feb 2022 13:42:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id A69C86B007E for ; Tue, 8 Feb 2022 13:42:45 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 60B3E9528D for ; Tue, 8 Feb 2022 18:42:45 +0000 (UTC) X-FDA: 79120483890.29.7C11D62 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) by imf12.hostedemail.com (Postfix) with ESMTP id 2221540004 for ; Tue, 8 Feb 2022 18:42:44 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id p19so5991190ybc.6 for ; Tue, 08 Feb 2022 10:42:44 -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=6qZ+pPhDDYjN2BJEUJ3iB4rTAi+CMeaHgTG54/t5621TPLjRSrSlhf41OjpAqgVI4g de24CuEE66o947AVx3U43yk7ce0r1ce4Q1yqqOHQTecnHId3xm1PM+CwKFJvUYnwkbZ1 2qGiehCfVU3lSrCV7DWzrikTJijvN+zNK3r0EoyfRtykvCgO//mBD1tNpRi3M1Uk+W6i vQfxxb6nCVY7M93+uGzYlmJSHAuvGlpppBh1iOJFsVGgtH73UWDXPqy2J48gq51RVADU F2Gvnok6MNwL/HCS8n5RDYIVpAkSmHldbSwArGo8+EficWkfj8hzQM7Kij8iIL/o02ah PScg== X-Gm-Message-State: AOAM533paHpNq8j9V3P8KJpdc11rGb7HT74dCt17WWvT8VRdo/+dRvbU k79LEwWe/DyMhkWp4nomonPA4m9E2HSeENQsv1HXnQ== X-Google-Smtp-Source: ABdhPJzzgBhFqMGwnMviH8m/k+/Na9ar8Vld1U133z3sPwDidgZQciC0WOhjzLFQ41uD+RWtK2DX4qnr+RjAJkV+OoU= 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" Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=gaYYFlmO; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of elver@google.com designates 209.85.219.175 as permitted sender) smtp.mailfrom=elver@google.com X-Rspamd-Server: rspam03 X-Rspam-User: X-Stat-Signature: ktmsg7d6hreioj5koaz8zcbch3bwagcc X-Rspamd-Queue-Id: 2221540004 X-HE-Tag: 1644345764-284812 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 >