From patchwork Tue Feb 22 18:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 12755807 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 4910AC433F5 for ; Tue, 22 Feb 2022 18:26:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 995178D0002; Tue, 22 Feb 2022 13:26:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91B238D0001; Tue, 22 Feb 2022 13:26:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BB928D0002; Tue, 22 Feb 2022 13:26:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 675148D0001 for ; Tue, 22 Feb 2022 13:26:36 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 22E0D9AC89 for ; Tue, 22 Feb 2022 18:26:36 +0000 (UTC) X-FDA: 79171246392.13.0271929 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf06.hostedemail.com (Postfix) with ESMTP id 55021180002 for ; Tue, 22 Feb 2022 18:26:35 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1645554393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Lb/QQb5DmP2LHrXtHDNMk4U8p312LQBN/82u4kQO66g=; b=l7Bx2GUkm3Dq5StqRmciyqB+5cGjfC3M+543snV01fvLP9JXoAN2fRqX4tMOUJ6OxvkRec tZ8EDfLFptIHP30shsd5HMLexP/s1MF7F3/neYZyZsZ4OuyQ3K/1o6qF9Sv3BeH8czNEcZ 9niRTJULEML6baoeydk560SQ4PRbwLU= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov , kernel test robot Subject: [PATCH mm v2] another fix for "kasan: improve vmalloc tests" Date: Tue, 22 Feb 2022 19:26:28 +0100 Message-Id: <019ac41602e0c4a7dfe96dc8158a95097c2b2ebd.1645554036.git.andreyknvl@google.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 55021180002 X-Stat-Signature: 1ca7fxfgeyjybsodj6qmob8cbwaz657t Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=l7Bx2GUk; spf=pass (imf06.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-HE-Tag: 1645554395-241586 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: From: Andrey Konovalov set_memory_rw/ro() are not exported to be used in modules and thus cannot be used in KUnit-compatible KASAN tests. Do the checks that rely on these functions only when the tests are built-in. Reported-by: kernel test robot Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- Changes v1->v2: - Hide checks under #if instead of dropping. --- lib/test_kasan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index ef99d81fe8b3..c4b7eb2bad77 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -1083,11 +1083,13 @@ static void vmalloc_helpers_tags(struct kunit *test) KUNIT_ASSERT_TRUE(test, is_vmalloc_addr(ptr)); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vmalloc_to_page(ptr)); +#if !IS_MODULE(CONFIG_KASAN_KUNIT_TEST) /* Make sure vmalloc'ed memory permissions can be changed. */ rv = set_memory_ro((unsigned long)ptr, 1); KUNIT_ASSERT_GE(test, rv, 0); rv = set_memory_rw((unsigned long)ptr, 1); KUNIT_ASSERT_GE(test, rv, 0); +#endif vfree(ptr); }