Message ID | 9cd5cf2f633dcbf55cab801cd26845d2b075cec7.1610733117.git.andreyknvl@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=ftTf=GS=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 8DCD2C433DB for <linux-arm-kernel@archiver.kernel.org>; Fri, 15 Jan 2021 17:56:21 +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 3861D23A59 for <linux-arm-kernel@archiver.kernel.org>; Fri, 15 Jan 2021 17:56:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3861D23A59 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=06On7xUKLn7eeEAAOnYFN/Vb8 ku89jRv0bphZJC5VrG0/z7Rz1O17xkrD/inVmn3OAbnSFqJ9DL0IGQawbOdThVN3J8rHmrFq1sW5k Beww8amqAmRUSpou5ouE6vI7YyH0sZguEOZlG9yw3dsUE6YoDH7KqqWwrSYPJ/F6ik0GyJtCcfD/w ysvA5UWw23B07C6JHVDtMwKMx4p9RKIvXalhCXQnbvsC2BWDSp8RsDman3fmu5khLRNbcvYyE/5X1 C2/D9MqHXMFFRSMuFD3k0YxHqzP5XoE4qNolygLeykTQGI16dTOUh9VpOMnlJu3e2jnY6UD6DBZCx sGmsO9wvQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0TJA-0003xb-2P; Fri, 15 Jan 2021 17:54:48 +0000 Received: from mail-qv1-xf4a.google.com ([2607:f8b0:4864:20::f4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0THp-0003Vb-KC for linux-arm-kernel@lists.infradead.org; Fri, 15 Jan 2021 17:53:35 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id m8so8368658qvt.14 for <linux-arm-kernel@lists.infradead.org>; Fri, 15 Jan 2021 09:53:23 -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=oOLTb6iXGw4hR7fdl1kwHC5xGAza1F2tagz3FB0QzJWJZ+QDQztqyFMI5YtXoJnkKe Y8bnNIHQQI6h6YZB8c5JWJITMJwTcCVPccnXBUAH6v53fuzil8/YZQvPlWRIfbIJkX3k QhAZskFpCa+ydA7ejU09Rldhgnq+lomoiasoPI+wLLennUluX7zlgEMOvZlu3aSu/uya REciLVBKZ8HB9mefgBiy1+ygnJg5QEKOGO6TqXqwlYLg9xnZFQb6ydAdwrbnQTcVow6C lv0wjw4582nq09tW4GEKePRBzsLb1hpFJGbAuym5d3D1p8/Qq+uq1wl9ctzgSvCa1YwV Mf6Q== 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=iLd/HWXP4VzLRjPyWCbGfQLskwRSSY9LfRmxx/UTpZni4fiLYaiWI1hal3oTTj3ki9 1ApP+ZTD2w+DuN675UYtqfw093mPSqWqNtUQVjsyz9n2kcl8TGiD4XKeN+1ZKg13SAOz L7Z801vO/cKwOVExbzlaoZqS/jvta85baz60kINIgTtGrUV/9oq//JvWm/CzO/XKCXJD hGB3n500/yOIJl76Dl8iBo7z4P0dy8fKtUAqJXtqOTbQQZ0pT+XUqj6tgFAZPia2lBqz WDylOgjVwWgiuvSIqmBAaHgs716w5vfJupIlUzPM72yw2z8MLQVuREtvIo/WDMrEzPeE 8Q8g== X-Gm-Message-State: AOAM533bNKcyxwgYtUcvLQABVHKIBPPd4iCgFjhs89J7QStD/TetLbSP BiRf2rCC0Cj7XrJ1lWfmLoPvdhFdVJM3SYxg X-Google-Smtp-Source: ABdhPJzKh8C6qw7cdRynOQL3HqGoll2W7wn9Iq+M7R+ck7opki/cSqyWyZcMuFOd2GLp4ocvgj4w963nEuh9ZJCs X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:ad4:5188:: with SMTP id b8mr13230051qvp.55.1610733201718; Fri, 15 Jan 2021 09:53:21 -0800 (PST) Date: Fri, 15 Jan 2021 18:52:46 +0100 In-Reply-To: <cover.1610733117.git.andreyknvl@google.com> Message-Id: <9cd5cf2f633dcbf55cab801cd26845d2b075cec7.1610733117.git.andreyknvl@google.com> Mime-Version: 1.0 References: <cover.1610733117.git.andreyknvl@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH v4 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-20210115_125325_795349_463CB834 X-CRM114-Status: GOOD ( 13.26 ) 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);