From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Alexander Potapenko <glider@google.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Heiko Carstens <hca@linux.ibm.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Marco Elver <elver@google.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Pekka Enberg <penberg@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Vasily Gorbik <gor@linux.ibm.com>,
Vlastimil Babka <vbabka@suse.cz>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Dmitry Vyukov <dvyukov@google.com>,
Hyeonggon Yoo <42.hyeyoo@gmail.com>,
kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, linux-s390@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Sven Schnelle <svens@linux.ibm.com>
Subject: Re: [PATCH v2 12/33] kmsan: Allow disabling KMSAN checks for the current task
Date: Wed, 13 Dec 2023 16:01:45 +0100 [thread overview]
Message-ID: <0bd0f6f9d0c6ff454739f38d6661fdda662afcca.camel@linux.ibm.com> (raw)
In-Reply-To: <CAG_fn=VaJtMogdmehJoYmZRNrs5AXYs+ZwBTu3TQQVaSkFNzcw@mail.gmail.com>
On Mon, 2023-12-11 at 12:50 +0100, Alexander Potapenko wrote:
> On Tue, Nov 21, 2023 at 11:06 PM Ilya Leoshkevich <iii@linux.ibm.com>
> wrote:
> >
> > Like for KASAN, it's useful to temporarily disable KMSAN checks
> > around,
> > e.g., redzone accesses. Introduce kmsan_disable_current() and
> > kmsan_enable_current(), which are similar to their KASAN
> > counterparts.
>
> Initially we used to have this disablement counter in KMSAN, but
> adding it uncontrollably can result in KMSAN not functioning
> properly.
> E.g. forgetting to call kmsan_disable_current() or underflowing the
> counter will break reporting.
> We'd better put this API in include/linux/kmsan.h to indicate it
> should be discouraged.
>
> > Even though it's not strictly necessary, make them reentrant, in
> > order
> > to match the KASAN behavior.
>
> Until this becomes strictly necessary, I think we'd better
> KMSAN_WARN_ON if the counter is re-entered.
I encountered a case when we are freeing memory from an interrupt
handler:
[ 149.840553] ------------[ cut here ]------------
[ 149.840649] WARNING: CPU: 1 PID: 181 at mm/kmsan/hooks.c:447
kmsan_disable_current+0x2e/0x40
[ 149.840790] Modules linked in:
[ 149.840894] CPU: 1 PID: 181 Comm: (direxec) Tainted: G B W
N 6.7.0-rc5-gd34a4b46f382 #13
[ 149.841003] Hardware name: IBM 3931 A01 704 (KVM/Linux)
[ 149.841094] Krnl PSW : 0404c00180000000 000000000197dbc2
(kmsan_disable_current+0x32/0x40)
[ 149.841276] R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:0
PM:0 RI:0 EA:3
[ 149.841420] Krnl GPRS: 0000000000000040 0000000096914100
0000000000001000 0000000000000001
[ 149.841518] 0000036d827daee0 0000000007c97008
0000000080096500 0000000092f4f000
[ 149.841617] 0000036d00000000 0000000000000000
0000000000000040 0000000000000000
[ 149.841712] 0000000092f4efc0 00000001ff710f60
000000000193acba 0000037f0008f710
[ 149.841893] Krnl Code: 000000000197dbb6: eb0018640352 mviy
14436(%r1),0
[ 149.841893] 000000000197dbbc: 07fe bcr
15,%r14
[ 149.841893] #000000000197dbbe: af000000 mc
0,0
[ 149.841893] >000000000197dbc2: a7f4fffa brc
15,000000000197dbb6
[ 149.841893] 000000000197dbc6: 0700 bcr
0,%r0
[ 149.841893] 000000000197dbc8: 0700 bcr
0,%r0
[ 149.841893] 000000000197dbca: 0700 bcr
0,%r0
[ 149.841893] 000000000197dbcc: 0700 bcr
0,%r0
[ 149.842438] Call Trace:
15:37:25 [90/1838]
[ 149.842510] [<000000000197dbc2>] kmsan_disable_current+0x32/0x40
[ 149.842631] ([<000000000193ac14>] slab_pad_check+0x1d4/0xac0)
[ 149.842738] [<0000000001949222>] free_to_partial_list+0x1d72/0x3b80
[ 149.842850] [<0000000001947066>] __slab_free+0xd86/0x11d0
[ 149.842956] [<00000000019111e8>] kmem_cache_free+0x15d8/0x25d0
[ 149.843062] [<0000000000229e3a>] __tlb_remove_table+0x20a/0xa50
[ 149.843174] [<00000000016c7f98>] tlb_remove_table_rcu+0x98/0x120
[ 149.843291] [<000000000083e1c6>] rcu_core+0x15b6/0x54b0
[ 149.843406] [<00000000069c3c0e>] __do_softirq+0xa1e/0x2178
[ 149.843514] [<00000000003467b4>] irq_exit_rcu+0x2c4/0x630
[ 149.843623] [<0000000006949f6e>] do_ext_irq+0x9e/0x120
[ 149.843736] [<00000000069c18d4>] ext_int_handler+0xc4/0xf0
[ 149.843841] [<000000000197e428>] kmsan_get_metadata+0x68/0x280
[ 149.843950] [<000000000197e344>]
kmsan_get_shadow_origin_ptr+0x74/0xf0
[ 149.844071] [<000000000197ba3a>]
__msan_metadata_ptr_for_load_8+0x2a/0x40
[ 149.844192] [<0000000000184e4a>]
unwind_get_return_address+0xda/0x150
[ 149.844313] [<000000000018fd12>] arch_stack_walk+0x172/0x2f0
[ 149.844417] [<00000000008f1af0>] stack_trace_save+0x100/0x160
[ 149.844529] [<000000000197af22>]
kmsan_internal_chain_origin+0x62/0xe0
[ 149.844647] [<000000000197c1f0>] __msan_chain_origin+0xd0/0x160
[ 149.844763] [<00000000068b3ba4>] memchr_inv+0x5b4/0xb20
[ 149.844877] [<000000000193e730>] check_bytes_and_report+0xa0/0xd30
[ 149.844986] [<000000000193b920>] check_object+0x420/0x17d0
[ 149.845092] [<000000000194aa8a>] free_to_partial_list+0x35da/0x3b80
[ 149.845202] [<0000000001947066>] __slab_free+0xd86/0x11d0
[ 149.845308] [<00000000019111e8>] kmem_cache_free+0x15d8/0x25d0
[ 149.845414] [<00000000016bc2fe>] exit_mmap+0x87e/0x1200
[ 149.845524] [<00000000002f315c>] mmput+0x13c/0x5b0
[ 149.845632] [<0000000001b9d634>] exec_mmap+0xc34/0x1230
[ 149.845744] [<0000000001b996c2>] begin_new_exec+0xcf2/0x2520
[ 149.845857] [<0000000001f6a084>] load_elf_binary+0x2364/0x67d0
[ 149.845971] [<0000000001ba5ba4>] bprm_execve+0x25b4/0x4010
[ 149.846083] [<0000000001baa7e6>] do_execveat_common+0x2436/0x2600
[ 149.846200] [<0000000001ba78f8>] __s390x_sys_execve+0x108/0x140
[ 149.846314] [<000000000011b192>] do_syscall+0x4c2/0x690
[ 149.846424] [<0000000006949d78>] __do_syscall+0x98/0xe0
[ 149.846536] [<00000000069c1640>] system_call+0x70/0xa0
[ 149.846638] INFO: lockdep is turned off.
[ 149.846846] Last Breaking-Event-Address:
[ 149.846916] [<000000000197dbb2>] kmsan_disable_current+0x22/0x40
[ 149.847057] irq event stamp: 0
[ 149.847128] hardirqs last enabled at (0): [<0000000000000000>] 0x0
[ 149.847227] hardirqs last disabled at (0): [<00000000002f8f46>]
copy_process+0x21f6/0x8b20
[ 149.847344] softirqs last enabled at (0): [<00000000002f8f80>]
copy_process+0x2230/0x8b20
[ 149.847461] softirqs last disabled at (0): [<0000000000000000>] 0x0
[ 149.847559] ---[ end trace 0000000000000000 ]---
[ 149.865485] =====================================================
Using a counter resolves this issue, but, of course, at the expense of
not reporting valid issues in the interrupt handler.
Unfortunately I don't see another easy way to solve this problem. The
possibilities that come to mind are providing uninstrumented
memchr_inv() or disablement flags for each context, but I'm not sure if
we want to go there, especially since KASAN already has this
limitation.
next prev parent reply other threads:[~2023-12-13 15:02 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 22:00 [PATCH v2 00/33] kmsan: Enable on s390 Ilya Leoshkevich
2023-11-21 22:00 ` [PATCH v2 01/33] ftrace: Unpoison ftrace_regs in ftrace_ops_list_func() Ilya Leoshkevich
2023-11-22 23:32 ` Steven Rostedt
2023-12-08 14:16 ` Alexander Potapenko
2023-12-08 14:31 ` Steven Rostedt
2023-12-12 2:05 ` Ilya Leoshkevich
2023-11-21 22:00 ` [PATCH v2 02/33] kmsan: Make the tests compatible with kmsan.panic=1 Ilya Leoshkevich
2023-11-21 22:00 ` [PATCH v2 03/33] kmsan: Disable KMSAN when DEFERRED_STRUCT_PAGE_INIT is enabled Ilya Leoshkevich
2023-11-21 22:00 ` [PATCH v2 04/33] kmsan: Increase the maximum store size to 4096 Ilya Leoshkevich
2023-12-08 16:31 ` Alexander Potapenko
2023-11-21 22:00 ` [PATCH v2 05/33] kmsan: Fix is_bad_asm_addr() on arches with overlapping address spaces Ilya Leoshkevich
2023-12-11 9:52 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 06/33] kmsan: Fix kmsan_copy_to_user() " Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 07/33] kmsan: Remove a useless assignment from kmsan_vmap_pages_range_noflush() Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 08/33] kmsan: Remove an x86-specific #include from kmsan.h Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 09/33] kmsan: Introduce kmsan_memmove_metadata() Ilya Leoshkevich
2023-12-08 16:51 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 10/33] kmsan: Expose kmsan_get_metadata() Ilya Leoshkevich
2023-12-11 10:07 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 11/33] kmsan: Export panic_on_kmsan Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 12/33] kmsan: Allow disabling KMSAN checks for the current task Ilya Leoshkevich
2023-12-11 11:50 ` Alexander Potapenko
2023-12-13 15:01 ` Ilya Leoshkevich [this message]
2023-11-21 22:01 ` [PATCH v2 13/33] kmsan: Introduce memset_no_sanitize_memory() Ilya Leoshkevich
2023-12-08 13:48 ` Alexander Potapenko
2023-12-08 14:07 ` Ilya Leoshkevich
2023-12-08 15:25 ` Alexander Potapenko
2023-12-13 1:31 ` Ilya Leoshkevich
2023-12-13 11:32 ` Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 14/33] kmsan: Support SLAB_POISON Ilya Leoshkevich
2023-12-08 13:51 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 15/33] kmsan: Use ALIGN_DOWN() in kmsan_get_metadata() Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 16/33] mm: slub: Let KMSAN access metadata Ilya Leoshkevich
2023-11-30 15:26 ` Vlastimil Babka
2023-11-21 22:01 ` [PATCH v2 17/33] mm: kfence: Disable KMSAN when checking the canary Ilya Leoshkevich
2023-12-08 12:53 ` Alexander Potapenko
2023-12-08 13:55 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 18/33] lib/string: Add KMSAN support to strlcpy() and strlcat() Ilya Leoshkevich
2023-12-08 16:50 ` Alexander Potapenko
2023-12-13 0:53 ` Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 19/33] lib/zlib: Unpoison DFLTCC output buffers Ilya Leoshkevich
2023-12-08 13:32 ` Alexander Potapenko
2023-12-08 14:14 ` Ilya Leoshkevich
2023-12-08 14:25 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 20/33] kmsan: Accept ranges starting with 0 on s390 Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 21/33] s390: Turn off KMSAN for boot, vdso and purgatory Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 22/33] s390: Use a larger stack for KMSAN Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 23/33] s390/boot: Add the KMSAN runtime stub Ilya Leoshkevich
2023-12-08 16:56 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 24/33] s390/checksum: Add a KMSAN check Ilya Leoshkevich
2023-12-08 13:38 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 25/33] s390/cpacf: Unpoison the results of cpacf_trng() Ilya Leoshkevich
2023-12-11 10:36 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 26/33] s390/ftrace: Unpoison ftrace_regs in kprobe_ftrace_handler() Ilya Leoshkevich
2023-12-08 14:18 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 27/33] s390/mm: Define KMSAN metadata for vmalloc and modules Ilya Leoshkevich
2023-12-11 10:13 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 28/33] s390/string: Add KMSAN support Ilya Leoshkevich
2023-12-11 10:49 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 29/33] s390/traps: Unpoison the kernel_stack_overflow()'s pt_regs Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 30/33] s390/uaccess: Add KMSAN support to put_user() and get_user() Ilya Leoshkevich
2023-12-11 10:46 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 31/33] s390/unwind: Disable KMSAN checks Ilya Leoshkevich
2023-11-21 22:01 ` [PATCH v2 32/33] s390: Implement the architecture-specific kmsan functions Ilya Leoshkevich
2023-12-11 10:26 ` Alexander Potapenko
2023-12-11 10:39 ` Ilya Leoshkevich
2023-12-11 10:45 ` Alexander Potapenko
2023-11-21 22:01 ` [PATCH v2 33/33] kmsan: Enable on s390 Ilya Leoshkevich
2023-11-29 9:19 ` Alexander Potapenko
2023-11-29 9:58 ` Ilya Leoshkevich
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=0bd0f6f9d0c6ff454739f38d6661fdda662afcca.camel@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=42.hyeyoo@gmail.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=borntraeger@linux.ibm.com \
--cc=cl@linux.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=svens@linux.ibm.com \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).