Message ID | 62a4d6dba701ad4747d836fb08c20fdfffc701f8.1610652890.git.andreyknvl@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=gHlk=GR=lists.infradead.org=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84616C433DB for <linux-arm-kernel@archiver.kernel.org>; Thu, 14 Jan 2021 19:40:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE9E52343B for <linux-arm-kernel@archiver.kernel.org>; Thu, 14 Jan 2021 19:40:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE9E52343B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LS5+RLbsIrKZIBNqllF9xlGDN7+QiEhlrFZa48vuwW4=; b=j5h/bXlMvffiorC5beHQPqjEu WClXf+XQl75msVGYqwkNnxaIXiSAP4wvkwz5ST2BChQ03p4HLkx2W9jxl6c5AvRy5Au5HGu8kUX8E ywaQJ6J0b7ZPXAqFsFZ/AtTVP00Yrk2skrzCDWEdUPetgQ2TpVsLrlAqjG/oYrEd4ZiHRlQM7yAOK tLyQOaqvpY85bqHfl8IrjZlKZkJshg6oOOeQaKLgKQLascVJ+JYlD7LyeBWe2UUA7PsurpRJYgCQ9 1ewQnWpwd4ziEfQV3xjQd4/VKSh4sbdx03UGhwjhtuLmDoLsN7nqhO6DJoFCR7X6hhCIE7mZwUobR RCD00YZJw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l08Rw-0004qg-2f; Thu, 14 Jan 2021 19:38:28 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l08QU-0004Ft-Ue for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2021 19:37:07 +0000 Received: by mail-wr1-x44a.google.com with SMTP id q18so3052195wrc.20 for <linux-arm-kernel@lists.infradead.org>; Thu, 14 Jan 2021 11:36:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=BYOOBCCudRU7Lchp5NpxZrw19s2hqbj4Q5eYKa3nns4=; b=rTUv5m0zNhD34FCcwlpq09FOQVY979bNJORsUf6OmzgaoTAOFMWsj6uKVvVPryAncc Y6OhafJM04uWVc9pjJQKH5NCt3DkQiMm85OpEihWPA8JcD25gC3aeR9kvA9Y7WWCW9ie EmLUYPTYMJpoVS5omyVpvjA8KTO6StvqomYrsX+za0mQvc8oQwUxEjeGb11XkDrHA5Ee Szowzviwu7DMZ/YWR074GrBN8wKOLaOqezsuVaixBa1pbB8unyc+XyrVbX7S7Hr4U0Jt MYp20quJAyjR5U7eAr6/jrLyH1zjC5WXJT5NxhYC5GL61NwjGH+LqPS61lk6rSQ+HQeG bkqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=BYOOBCCudRU7Lchp5NpxZrw19s2hqbj4Q5eYKa3nns4=; b=d5PDVEREFI/bDXrN2hcpMD9wjYYhZ3icjalnAUpJTFcPblxu7PbAzXmQMMZvIo+jci mtsH8lN+gY2SGtTQjhPxJDpMoSalcfudL0e2TSmUgmQqXgT54zgBcjNd899K+Dx+L3xK c8FCj4LDVg4XF+00mVlvVPz2qh+9U1/j6jHfZaQomyLgR4hL78TLFo4HVFJU+5XBC+wO MeBFGiA5cvNeRamvYZeG/hmqVTfJUybboK5eJxFrK9fQorwWf7NcAfKrVcs6QlWUgWgE R4K6L20spbYUyuccK2ZXrfMuBxWuL7uzXImM08qCgA1V98NMfTFssCEMFH+yGY08vW2a L3OA== X-Gm-Message-State: AOAM530ild39rvWg/8gtMlmTidYEk+TprnwZUk5c9kAbjrF/IlVolLIE pl5rbAIntvkQvphSQ1MHh1IKRd0h76pSfxfU X-Google-Smtp-Source: ABdhPJyYO2MlxfR/Y4/edLSR5eTxNluzpB8ZY4biV8IiJKVDxm5JrKLOUsXrzNZQUnUIvM0PtVPM014fSmcVbUqw X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a05:600c:2905:: with SMTP id i5mr5291713wmd.28.1610653015397; Thu, 14 Jan 2021 11:36:55 -0800 (PST) Date: Thu, 14 Jan 2021 20:36:25 +0100 In-Reply-To: <cover.1610652890.git.andreyknvl@google.com> Message-Id: <62a4d6dba701ad4747d836fb08c20fdfffc701f8.1610652890.git.andreyknvl@google.com> Mime-Version: 1.0 References: <cover.1610652890.git.andreyknvl@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH v3 09/15] kasan: adapt kmalloc_uaf2 test to HW_TAGS mode From: Andrey Konovalov <andreyknvl@google.com> To: Andrew Morton <akpm@linux-foundation.org>, Catalin Marinas <catalin.marinas@arm.com>, Vincenzo Frascino <vincenzo.frascino@arm.com>, Dmitry Vyukov <dvyukov@google.com>, Alexander Potapenko <glider@google.com>, Marco Elver <elver@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210114_143659_103094_9D639DD0 X-CRM114-Status: GOOD ( 13.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Cc: Branislav Rankov <Branislav.Rankov@arm.com>, Andrey Konovalov <andreyknvl@google.com>, Kevin Brodsky <kevin.brodsky@arm.com>, Will Deacon <will.deacon@arm.com>, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Ryabinin <aryabinin@virtuozzo.com>, Peter Collingbourne <pcc@google.com>, Evgenii Stepanov <eugenis@google.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
kasan: HW_TAGS tests support and fixes
|
expand
|
diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 2419e36e117b..0cda4a1ff394 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -382,7 +382,9 @@ static void kmalloc_uaf2(struct kunit *test) { char *ptr1, *ptr2; size_t size = 43; + int counter = 0; +again: ptr1 = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr1); @@ -391,6 +393,15 @@ static void kmalloc_uaf2(struct kunit *test) ptr2 = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr2); + /* + * For tag-based KASAN ptr1 and ptr2 tags might happen to be the same. + * Allow up to 16 attempts at generating different tags. + */ + if (!IS_ENABLED(CONFIG_KASAN_GENERIC) && ptr1 == ptr2 && counter++ < 16) { + kfree(ptr2); + goto again; + } + KUNIT_EXPECT_KASAN_FAIL(test, ptr1[40] = 'x'); KUNIT_EXPECT_PTR_NE(test, ptr1, ptr2);