From patchwork Thu Jan 21 16:39:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 12037031 Return-Path: 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 4CC12C4332B for ; Thu, 21 Jan 2021 16:43:02 +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 B0A7C23A3C for ; Thu, 21 Jan 2021 16:43:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0A7C23A3C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/4vF4wwcGUoSSnbOR9bypDwgjERzuFqwiDeHWumnfxU=; b=0xFUus2QT6t5r0Mo557we52qH gJW4FH3MGDSBtjl3WVfTjHbAYEWx+e9/wX4OHRdvgsZCV1oEN2Lttrdfo6CgNobBLK51xPj58j39N MGGGcNlv6TlTP2G2yr4Sa7klpgJWG9DN4xZWyz+pt37EvKo0g1Y8fV06ZVq2/gkkrxWJnhB33u1TB sRkv60d88AxD4L6OAgV9o3DxlHbHYmMvyU87K4BtfH9vrXrhP5ohwzSiyhs6v6CvV4REvi3RWQQGD yQ6bKsdfLPUIFa/Zg5o0godoFGwShYqv9QMWcabM8HiJaURFfd8uIEylZAodJ6csquqx3pGKPJT0t pU85hPpMQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2d1A-0003Ow-ED; Thu, 21 Jan 2021 16:41:08 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2d08-00034e-R1 for linux-arm-kernel@lists.infradead.org; Thu, 21 Jan 2021 16:40:07 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F8111596; Thu, 21 Jan 2021 08:40:04 -0800 (PST) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6D3BC3F68F; Thu, 21 Jan 2021 08:40:02 -0800 (PST) From: Vincenzo Frascino To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com Subject: [PATCH v5 6/6] kasan: Forbid kunit tests when async mode is enabled Date: Thu, 21 Jan 2021 16:39:43 +0000 Message-Id: <20210121163943.9889-7-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210121163943.9889-1-vincenzo.frascino@arm.com> References: <20210121163943.9889-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210121_114004_974167_DDA9623F X-CRM114-Status: GOOD ( 13.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marco Elver , Catalin Marinas , Branislav Rankov , Alexander Potapenko , Evgenii Stepanov , Andrey Konovalov , Andrey Ryabinin , Vincenzo Frascino , Will Deacon , Dmitry Vyukov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Architectures supported by KASAN_HW_TAGS can provide a sync or async mode of execution. KASAN KUNIT tests can be executed only when sync mode is enabled. Forbid the execution of the KASAN KUNIT tests when async mode is enabled. Cc: Dmitry Vyukov Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Signed-off-by: Vincenzo Frascino Reported-by: kernel test robot --- lib/test_kasan.c | 5 +++++ mm/kasan/kasan.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 7285dcf9fcc1..1306f707b4fe 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -52,6 +52,11 @@ static int kasan_test_init(struct kunit *test) return -1; } + if (!hw_is_mode_sync()) { + kunit_err(test, "can't run KASAN tests in async mode"); + return -1; + } + multishot = kasan_save_enable_multi_shot(); hw_set_tagging_report_once(false); return 0; diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 3923d9744105..3464113042ab 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -296,6 +296,7 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag) #define hw_enable_tagging_sync() arch_enable_tagging_sync() #define hw_enable_tagging_async() arch_enable_tagging_async() +#define hw_is_mode_sync() arch_is_mode_sync() #define hw_init_tags(max_tag) arch_init_tags(max_tag) #define hw_set_tagging_report_once(state) arch_set_tagging_report_once(state) #define hw_get_random_tag() arch_get_random_tag() @@ -306,6 +307,7 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag) #define hw_enable_tagging_sync() #define hw_enable_tagging_async() +#define hw_is_mode_sync() #define hw_set_tagging_report_once(state) #endif /* CONFIG_KASAN_HW_TAGS */