From patchwork Fri Nov 1 18:40:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13859677 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 A151CE6F07D for ; Fri, 1 Nov 2024 18:40:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3706C6B008A; Fri, 1 Nov 2024 14:40:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 320426B008C; Fri, 1 Nov 2024 14:40:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C0E36B0093; Fri, 1 Nov 2024 14:40:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F11796B008A for ; Fri, 1 Nov 2024 14:40:24 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 78F0BACE3B for ; Fri, 1 Nov 2024 18:40:24 +0000 (UTC) X-FDA: 82738390728.24.DD9861F Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf05.hostedemail.com (Postfix) with ESMTP id 8FF6110000B for ; Fri, 1 Nov 2024 18:39:28 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JVeugnK2; spf=pass (imf05.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=snovitoll@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730486340; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=325HZLula7jSoNoGXlC+vhYpf/xwBEOPgui+U1ZAOR4=; b=djIkVxEgXRpMhqZ6jvvkC0GtMQM223CZfaO4G39PrYpyvAnTj33Q3l+I/uug0+7HOp2gI1 Izlvf2cDKII65RBWZp1iKvS5MY+yfVWhTCk5Zf5XHp2wFE+l9kOSzW/ubxJtEFKbKSxGXb 6lIFa7LA+3/RJ6FG2F4Oh2Ji4CElkWI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730486340; a=rsa-sha256; cv=none; b=voW0PtArkDe50h+5XQmj9UuvuJhnvjquJLMUQ1GZqJvnBpGEEiKBHpYlc9aGhdCL9uR9Rj 9rpspVtGmqKM8M09gWKyZDVGphsYI/qRJyqlfDo1XXzN3ERJ2woPzCHcVuA9Pn2S6zVX6O 5vhded3CihsRWoAzVJ/grTal6E4X9Bc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JVeugnK2; spf=pass (imf05.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=snovitoll@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-539f2b95775so2730335e87.1 for ; Fri, 01 Nov 2024 11:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730486421; x=1731091221; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=325HZLula7jSoNoGXlC+vhYpf/xwBEOPgui+U1ZAOR4=; b=JVeugnK2LsBuW5OKGqclXXQ5qLR/C39PFRCpmM9OwfJQTrA0ofauOXInLLdJ/Y4cXq 60xI5eXHz/WL2vKg17EHk9GUL7eUJ/E34HU1rEB91IGHgAUpaEgjGyOlo5mOl7KNND31 DZNQK4pgO/GHBUMt147cQeXKvot60PWJ2Cg0Rx3JHQqf+/PnRvSCpG3eMlJ7a8CB9oap KxwFSsGd4T9iuJsZX+Dxchr7fS09AmhivqnUPjRbVXCflNy6BetojLWRY15R4UxLIVyQ XW1EGDeNdqzWKdMXC1QW39BepatKajgbn5i+k+lALeYaRT/pN1XFMtAcRfsjpmIEO6TM V4Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730486421; x=1731091221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=325HZLula7jSoNoGXlC+vhYpf/xwBEOPgui+U1ZAOR4=; b=B0Rh5IaSTwiXUvJ4L99MMOySKIaHIsrHRHg/KS3FRacE4qdLUaxeoYxgLTYwyA9a9J 7+ZLOwecVnO3IU8LI0K/MHT8Dr0sxAGTtThk46owSEmn03wGByUUiioPucDzzbmZn3QH NHdYtp8g0EaXPXlY33Rb80DB1Dd5YZ73lhiIiS7o9h4RcWrz52TV2nEJDo4CGFzKl+JI YzonTmQ45gtzmEBTrURsAqNCPzNm9VIMPwadMYB5ciXLUce1pl+Ez5uwNo6tcnVVSxaO C4Q7unkluFi5aBireJc/pXZa2Wr6Fgc2imdpYRfEeYikLXElry7fbxKOqdyM/PZSDz+u N6KA== X-Forwarded-Encrypted: i=1; AJvYcCXGOP1LQKw5CAcPbLRvyxcUq69TY3F26J/RSHUPFK5L1/NnyV85HFqLwuuvv0iRVpplnibiaHwakg==@kvack.org X-Gm-Message-State: AOJu0YwrRicTNa6edS4+XViL8Ep9RnaaCSKfsjJONubQTWVDqCOvzxuZ ldpQRqhAiQQwfy/PS5lihXOPMocbnvY5VZLYhN1kz+MEO3veGJC/ X-Google-Smtp-Source: AGHT+IFJs6WKOoZ+dQPXZdy5J0yt3B7+wP/Od81xCXCJNl3ABlWzNAHthdTYNFEexLKPL7ABxshCLw== X-Received: by 2002:a05:6512:3a8b:b0:539:89a8:600f with SMTP id 2adb3069b0e04-53d65de5298mr4080862e87.23.1730486420555; Fri, 01 Nov 2024 11:40:20 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53c7bc957cbsm646821e87.60.2024.11.01.11.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 11:40:19 -0700 (PDT) From: Sabyrzhan Tasbolatov To: ryabinin.a.a@gmail.com, andreyknvl@gmail.com, elver@google.com Cc: arnd@kernel.org, glider@google.com, dvyukov@google.com, vincenzo.frascino@arm.com, akpm@linux-foundation.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, snovitoll@gmail.com Subject: [PATCH 1/2] kasan: use EXPORT_SYMBOL_IF_KUNIT to export symbols Date: Fri, 1 Nov 2024 23:40:10 +0500 Message-Id: <20241101184011.3369247-2-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241101184011.3369247-1-snovitoll@gmail.com> References: <20241101184011.3369247-1-snovitoll@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: 48nmnz3ueksnm6qs3qj4faane69rrzhu X-Rspamd-Queue-Id: 8FF6110000B X-Rspam-User: X-HE-Tag: 1730486368-761720 X-HE-Meta: U2FsdGVkX18IJZlc488zaByNqmdx1Q3sx9zuF7ivQ2K83TlcUGREuBxTPJlSK+LKvXJfmqAzERrlLrF7KWTUAzFLmD5s/YWVE9KlGtL/Boatnguag5bM85bHnv6N4WHaRunzQ9/PMmNQOLCnRbmzMT6qxO7LBxv2dtJNlblCikG7LRV+dr/6g689BC9KrWO6ibDpMyBlt13gmGhvHy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53Fy9X5xKpWGifBV3DxRgVnYHkiTr6UV98q6zkkfAVtpRzmJl91NUFp10EUuubeCTqmRezjO5xcjCr/ehHwlRxzXRPNJjq27Oz2Z1EgRNHqUSkYoOMsvuDzuzH6hUBZBCkblDCqA5LJX3ku0uk9Z835pbodnAwba9oYN2NVNJAXcfDetFxcyjnZ+e3v1zfkA5oHN8Eq4tOwBafNhRQvndalMeKiMezsSzFP/I= 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: List-Subscribe: List-Unsubscribe: Replace EXPORT_SYMBOL_GPL with EXPORT_SYMBOL_IF_KUNIT to mark the symbols as visible only if CONFIG_KUNIT is enabled. KASAN Kunit test should import the namespace EXPORTED_FOR_KUNIT_TESTING to use these marked symbols. Reported-by: Andrey Konovalov Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov Reviewed-by: Andrey Konovalov --- mm/kasan/hw_tags.c | 7 ++++--- mm/kasan/kasan_test_c.c | 2 ++ mm/kasan/report.c | 17 +++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c index 9958ebc15d38..ccd66c7a4081 100644 --- a/mm/kasan/hw_tags.c +++ b/mm/kasan/hw_tags.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "kasan: " fmt +#include #include #include #include @@ -394,12 +395,12 @@ void kasan_enable_hw_tags(void) #if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) -EXPORT_SYMBOL_GPL(kasan_enable_hw_tags); +EXPORT_SYMBOL_IF_KUNIT(kasan_enable_hw_tags); -void kasan_force_async_fault(void) +VISIBLE_IF_KUNIT void kasan_force_async_fault(void) { hw_force_async_tag_fault(); } -EXPORT_SYMBOL_GPL(kasan_force_async_fault); +EXPORT_SYMBOL_IF_KUNIT(kasan_force_async_fault); #endif diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c index a181e4780d9d..3e495c09342e 100644 --- a/mm/kasan/kasan_test_c.c +++ b/mm/kasan/kasan_test_c.c @@ -33,6 +33,8 @@ #define OOB_TAG_OFF (IS_ENABLED(CONFIG_KASAN_GENERIC) ? 0 : KASAN_GRANULE_SIZE) +MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING); + static bool multishot; /* Fields set based on lines observed in the console. */ diff --git a/mm/kasan/report.c b/mm/kasan/report.c index b48c768acc84..e5bc4e3ee198 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -134,18 +135,18 @@ static bool report_enabled(void) #if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) || IS_ENABLED(CONFIG_KASAN_MODULE_TEST) -bool kasan_save_enable_multi_shot(void) +VISIBLE_IF_KUNIT bool kasan_save_enable_multi_shot(void) { return test_and_set_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); } -EXPORT_SYMBOL_GPL(kasan_save_enable_multi_shot); +EXPORT_SYMBOL_IF_KUNIT(kasan_save_enable_multi_shot); -void kasan_restore_multi_shot(bool enabled) +VISIBLE_IF_KUNIT void kasan_restore_multi_shot(bool enabled) { if (!enabled) clear_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); } -EXPORT_SYMBOL_GPL(kasan_restore_multi_shot); +EXPORT_SYMBOL_IF_KUNIT(kasan_restore_multi_shot); #endif @@ -157,17 +158,17 @@ EXPORT_SYMBOL_GPL(kasan_restore_multi_shot); */ static bool kasan_kunit_executing; -void kasan_kunit_test_suite_start(void) +VISIBLE_IF_KUNIT void kasan_kunit_test_suite_start(void) { WRITE_ONCE(kasan_kunit_executing, true); } -EXPORT_SYMBOL_GPL(kasan_kunit_test_suite_start); +EXPORT_SYMBOL_IF_KUNIT(kasan_kunit_test_suite_start); -void kasan_kunit_test_suite_end(void) +VISIBLE_IF_KUNIT void kasan_kunit_test_suite_end(void) { WRITE_ONCE(kasan_kunit_executing, false); } -EXPORT_SYMBOL_GPL(kasan_kunit_test_suite_end); +EXPORT_SYMBOL_IF_KUNIT(kasan_kunit_test_suite_end); static bool kasan_kunit_test_suite_executing(void) {