From: Andrey Konovalov <andreyknvl@gmail.com>
To: Sabyrzhan Tasbolatov <snovitoll@gmail.com>, glider@google.com
Cc: akpm@linux-foundation.org, bp@alien8.de, brauner@kernel.org,
dave.hansen@linux.intel.com, dhowells@redhat.com,
dvyukov@google.com, hpa@zytor.com, kasan-dev@googlegroups.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
mingo@redhat.com, ryabinin.a.a@gmail.com, tglx@linutronix.de,
vincenzo.frascino@arm.com, x86@kernel.org
Subject: Re: [PATCH v4] mm: x86: instrument __get/__put_kernel_nofault
Date: Sun, 22 Sep 2024 14:06:34 +0200 [thread overview]
Message-ID: <CA+fCnZfXp3-NOq-LB13q8V6tv=H976AeNQXU8p-VGK-m9Qdh1g@mail.gmail.com> (raw)
In-Reply-To: <20240921071005.909660-1-snovitoll@gmail.com>
On Sat, Sep 21, 2024 at 9:09 AM Sabyrzhan Tasbolatov
<snovitoll@gmail.com> wrote:
>
> Instrument copy_from_kernel_nofault(), copy_to_kernel_nofault(),
> strncpy_from_kernel_nofault() where __put_kernel_nofault,
> __get_kernel_nofault macros are used.
>
> __get_kernel_nofault needs instrument_memcpy_before() which handles
> KASAN, KCSAN checks for src, dst address, whereas for __put_kernel_nofault
> macro, instrument_write() check should be enough as it's validated via
> kmsan_copy_to_user() in instrument_put_user().
>
> __get_user_size was appended with instrument_get_user() for KMSAN check in
> commit 888f84a6da4d("x86: asm: instrument usercopy in get_user() and
> put_user()") but only for CONFIG_CC_HAS_ASM_GOTO_OUTPUT.
>
> copy_from_to_kernel_nofault_oob() kunit test triggers 4 KASAN OOB
> bug reports as expected, one for each copy_from/to_kernel_nofault call.
>
> Reported-by: Andrey Konovalov <andreyknvl@gmail.com>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=210505
> Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
> ---
> v3: changed kunit test from UAF to OOB case and git commit message.
> v4: updated a grammar in git commit message.
> ---
> arch/x86/include/asm/uaccess.h | 4 ++++
> mm/kasan/kasan_test.c | 21 +++++++++++++++++++++
> 2 files changed, 25 insertions(+)
>
> diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
> index 3a7755c1a441..87fb59071e8c 100644
> --- a/arch/x86/include/asm/uaccess.h
> +++ b/arch/x86/include/asm/uaccess.h
> @@ -353,6 +353,7 @@ do { \
> default: \
> (x) = __get_user_bad(); \
> } \
> + instrument_get_user(x); \
> } while (0)
instrument_get_user is KMSAN-related, so I don't think this change
belongs as a part of this patch.
Perhaps Alexander can comment on whether we need to add
instrument_get_user here for KMSAN.
prev parent reply other threads:[~2024-09-22 12:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 20:18 [PATCH] " Sabyrzhan Tasbolatov
2024-09-17 22:51 ` Andrey Konovalov
2024-09-18 10:56 ` [PATCH v2] " Sabyrzhan Tasbolatov
2024-09-18 15:15 ` Andrey Konovalov
2024-09-19 10:57 ` [PATCH v3] " Sabyrzhan Tasbolatov
2024-09-20 22:26 ` Andrey Konovalov
2024-09-21 7:10 ` [PATCH v4] " Sabyrzhan Tasbolatov
2024-09-21 20:49 ` Andrey Konovalov
2024-09-22 9:26 ` Sabyrzhan Tasbolatov
2024-09-22 12:04 ` Andrey Konovalov
2024-09-22 14:57 ` [PATCH v5] " Sabyrzhan Tasbolatov
2024-09-23 6:09 ` Sabyrzhan Tasbolatov
2024-09-27 15:18 ` Sabyrzhan Tasbolatov
2024-09-22 12:06 ` Andrey Konovalov [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='CA+fCnZfXp3-NOq-LB13q8V6tv=H976AeNQXU8p-VGK-m9Qdh1g@mail.gmail.com' \
--to=andreyknvl@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=brauner@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=dhowells@redhat.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=hpa@zytor.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=ryabinin.a.a@gmail.com \
--cc=snovitoll@gmail.com \
--cc=tglx@linutronix.de \
--cc=vincenzo.frascino@arm.com \
--cc=x86@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