diff options
| author | Alexander Potapenko <[email protected]> | 2025-05-07 16:00:11 +0000 |
|---|---|---|
| committer | Andrew Morton <[email protected]> | 2025-05-21 16:55:16 +0000 |
| commit | e17c1f15b0ccfa4802cedbd464d00ece50a10cf1 (patch) | |
| tree | 350fa7a9c93670309b881cd191a50a4f17b19b03 | |
| parent | kmsan: drop the declaration of kmsan_save_stack() (diff) | |
| download | kernel-e17c1f15b0ccfa4802cedbd464d00ece50a10cf1.tar.gz kernel-e17c1f15b0ccfa4802cedbd464d00ece50a10cf1.zip | |
kmsan: enter the runtime around kmsan_internal_memmove_metadata() call
kmsan_internal_memmove_metadata() transitively calls stack_depot_save()
(via kmsan_internal_chain_origin() and kmsan_save_stack_with_flags()),
which may allocate memory. Guard it with kmsan_enter_runtime() and
kmsan_leave_runtime() to avoid recursion.
This bug was spotted by CONFIG_WARN_CAPABILITY_ANALYSIS=y
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Alexander Potapenko <[email protected]>
Acked-by: Marco Elver <[email protected]>
Cc: Bart Van Assche <[email protected]>
Cc: Kent Overstreet <[email protected]>
Cc: Dmitriy Vyukov <[email protected]>
Cc: Ilya Leoshkevich <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
| -rw-r--r-- | mm/kmsan/hooks.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c index 05f2faa54054..97de3d6194f0 100644 --- a/mm/kmsan/hooks.c +++ b/mm/kmsan/hooks.c @@ -275,8 +275,10 @@ void kmsan_copy_to_user(void __user *to, const void *from, size_t to_copy, * Don't check anything, just copy the shadow of the copied * bytes. */ + kmsan_enter_runtime(); kmsan_internal_memmove_metadata((void *)to, (void *)from, to_copy - left); + kmsan_leave_runtime(); } user_access_restore(ua_flags); } |
