From: Vincenzo Frascino <vincenzo.frascino@arm.com>
To: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Linux ARM <linux-arm-kernel@lists.infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
kasan-dev <kasan-dev@googlegroups.com>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>
Subject: Re: [PATCH] kasan: Fix hw tags enablement when KUNIT tests are disabled
Date: Fri, 8 Apr 2022 13:32:28 +0100 [thread overview]
Message-ID: <08e480cf-90d4-8225-1af9-fe187fc622be@arm.com> (raw)
In-Reply-To: <CA+fCnZcoFWXyhjfKSxPh2djiTWjYCh2xmirPehyJS94DaoJC9w@mail.gmail.com>
Hi Andrey,
On 4/8/22 1:26 PM, Andrey Konovalov wrote:
> On Fri, Apr 8, 2022 at 12:04 PM Vincenzo Frascino
> <vincenzo.frascino@arm.com> wrote:
>>
>> Kasan enables hw tags via kasan_enable_tagging() which based on the mode
>> passed via kernel command line selects the correct hw backend.
>> kasan_enable_tagging() is meant to be invoked indirectly via the cpu features
>> framework of the architectures that support these backends.
>> Currently the invocation of this function is guarded by CONFIG_KASAN_KUNIT_TEST
>> which allows the enablement of the correct backend only when KUNIT tests are
>> enabled in the kernel.
>
>> ... and prevents to enable MTE on arm64 when KUNIT tests for kasan hw_tags are
>> disabled.
>
> Oh, indeed. Thanks for finding this!
>
>> This inconsistency was introduced in commit:
>>
>> f05842cfb9ae2 ("kasan, arm64: allow using KUnit tests with HW_TAGS mode")
>
> No, that commit is fine. The issue was introduced recently in
> ed6d74446cbf ("kasan: test: support async (again) and asymm modes for
> HW_TAGS"), where I changed kasan_init_hw_tags_cpu() to call
> kasan_enable_tagging() instead of hw_enable_tagging_*().
>
Thanks for pointing this out, the commit message above is referring to when the
guard was introduced but I agree it is more correct to refer to when the logical
issue was introduced. I will update it in v2.
>> Fix the issue making sure that the CONFIG_KASAN_KUNIT_TEST guard does not
>> prevent the correct invocation of kasan_enable_tagging().
>>
>> Fixes: f05842cfb9ae2 ("kasan, arm64: allow using KUnit tests with HW_TAGS mode")
>> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
>> Cc: Alexander Potapenko <glider@google.com>
>> Cc: Andrey Konovalov <andreyknvl@gmail.com>
>> Cc: Dmitry Vyukov <dvyukov@google.com>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>> mm/kasan/hw_tags.c | 4 ++--
>> mm/kasan/kasan.h | 10 ++++++----
>> 2 files changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
>> index 07a76c46daa5..e2677501c36e 100644
>> --- a/mm/kasan/hw_tags.c
>> +++ b/mm/kasan/hw_tags.c
>> @@ -336,8 +336,6 @@ void __kasan_poison_vmalloc(const void *start, unsigned long size)
>>
>> #endif
>>
>> -#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
>> -
>> void kasan_enable_tagging(void)
>> {
>> if (kasan_arg_mode == KASAN_ARG_MODE_ASYNC)
>> @@ -349,6 +347,8 @@ void kasan_enable_tagging(void)
>> }
>> EXPORT_SYMBOL_GPL(kasan_enable_tagging);
>
> Please keep this EXPORT_SYMBOL_GPL under CONFIG_KASAN_KUNIT_TEST.
>
Will do. Thanks!
>>
>> +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
>> +
>> void kasan_force_async_fault(void)
>> {
>> hw_force_async_tag_fault();
>> diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
>> index d79b83d673b1..b01b4bbe0409 100644
>> --- a/mm/kasan/kasan.h
>> +++ b/mm/kasan/kasan.h
>> @@ -355,25 +355,27 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
>> #define hw_set_mem_tag_range(addr, size, tag, init) \
>> arch_set_mem_tag_range((addr), (size), (tag), (init))
>>
>> +void kasan_enable_tagging(void);
>> +
>> #else /* CONFIG_KASAN_HW_TAGS */
>>
>> #define hw_enable_tagging_sync()
>> #define hw_enable_tagging_async()
>> #define hw_enable_tagging_asymm()
>>
>> +static inline void kasan_enable_tagging(void) { }
>> +
>> #endif /* CONFIG_KASAN_HW_TAGS */
>>
>> #if defined(CONFIG_KASAN_HW_TAGS) && IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
>>
>> -void kasan_enable_tagging(void);
>> void kasan_force_async_fault(void);
>>
>> -#else /* CONFIG_KASAN_HW_TAGS || CONFIG_KASAN_KUNIT_TEST */
>> +#else /* CONFIG_KASAN_HW_TAGS && CONFIG_KASAN_KUNIT_TEST */
>>
>> -static inline void kasan_enable_tagging(void) { }
>> static inline void kasan_force_async_fault(void) { }
>>
>> -#endif /* CONFIG_KASAN_HW_TAGS || CONFIG_KASAN_KUNIT_TEST */
>> +#endif /* CONFIG_KASAN_HW_TAGS && CONFIG_KASAN_KUNIT_TEST */
>>
>> #ifdef CONFIG_KASAN_SW_TAGS
>> u8 kasan_random_tag(void);
>> --
>> 2.35.1
>>
>
> Thank you, Vincenzo!
--
Regards,
Vincenzo
prev parent reply other threads:[~2022-04-08 12:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 10:03 Vincenzo Frascino
2022-04-08 12:26 ` Andrey Konovalov
2022-04-08 12:32 ` Vincenzo Frascino [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08e480cf-90d4-8225-1af9-fe187fc622be@arm.com \
--to=vincenzo.frascino@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®