From: Alexander Potapenko <glider@google.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Eric Dumazet <edumazet@google.com>,
Wolfram Sang <wsa@the-dreams.de>,
Vegard Nossum <vegard.nossum@oracle.com>,
Dmitry Vyukov <dvyukov@google.com>,
Linux Memory Management List <linux-mm@kvack.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH RFC v1 19/26] kmsan: call KMSAN hooks where needed
Date: Tue, 29 Oct 2019 14:59:53 +0100 [thread overview]
Message-ID: <CAG_fn=WhOymhOCFRXCvgufB3n6JHpQbXy9n6rYG5gRXvffm27A@mail.gmail.com> (raw)
In-Reply-To: <20191021092551.lf5hadk2kigzwveo@pathway.suse.cz>
On Mon, Oct 21, 2019 at 11:25 AM Petr Mladek <pmladek@suse.com> wrote:
>
> On Fri 2019-10-18 11:42:57, glider@google.com wrote:
> > Insert KMSAN hooks that check for potential memory errors and/or make
> > necessary bookkeeping changes:
> > - allocate/split/deallocate metadata pages in
> > alloc_pages()/split_page()/free_page();
> > - clear page shadow and origins in clear_page(), copy_user_highpage();
> > - copy page metadata in copy_highpage(), wp_page_copy();
> > - handle vmap()/vunmap()/iounmap();
> > - handle task creation and deletion;
> > - handle vprintk();
>
> I looked only at the printk part.
>
> > - call softirq entry/exit hooks in kernel/softirq.c;
> > - check/initialize memory sent to/read from USB, I2C, and network
> >
> > Signed-off-by: Alexander Potapenko <glider@google.com>
> > To: Alexander Potapenko <glider@google.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Eric Dumazet <edumazet@google.com>
> > Cc: Wolfram Sang <wsa@the-dreams.de>
> > Cc: Petr Mladek <pmladek@suse.com>
> > Cc: Vegard Nossum <vegard.nossum@oracle.com>
> > Cc: Dmitry Vyukov <dvyukov@google.com>
> > Cc: linux-mm@kvack.org
>
> Could you please add into CC also the other printk co-maitainers?
Will do in the next version of this patch.
> + Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> + Steven Rostedt <rostedt@goodmis.org>
>
>
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index ca65327a6de8..f77fdcb5f861 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -1914,7 +1914,12 @@ int vprintk_store(int facility, int level,
> > * The printf needs to come first; we need the syslog
> > * prefix which might be passed-in as a parameter.
> > */
> > - text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
> > + /*
> > + * We've checked the printk arguments in vprintk_emit() already.
> > + * Initialize |text_len| to prevent the errors from spreading.
> > + */
> > + text_len = KMSAN_INIT_VALUE(vscnprintf(text, sizeof(textbuf), fmt,
> > + args));
>
> I am a bit confused by the comment.
Fixed in v2.
> What is the exact meaning of KMSAN_INIT_VALUE(), please?
Hope it'll be clear from the "kmsan: add KMSAN runtime" patch.
In fact KMSAN_INIT_VALUE is a wrapper that turns an uninitialized
value into an initialized one:
https://github.com/google/kmsan/blob/3207d604ad68f7e5defdbbd6e63cb97750f380c1/include/linux/kmsan-checks.h#L58
It passes the value into an identity function that always returns
unpoisoned values.
As a result, from now on text_len is considered initialized,
regardless of what vscnprintf() returned.
Without KMSAN_INIT_VALUE the tool will report a huge number of errors
when text_len is used in vprintk_store() and log_output().
> Does it prevent checking fmt again?
> Does make the text_len variable special? In which way?
>
>
> > /* mark and strip a trailing newline */
> > if (text_len && text[text_len-1] == '\n') {
> > @@ -1972,6 +1977,7 @@ asmlinkage int vprintk_emit(int facility, int level,
> > boot_delay_msec(level);
> > printk_delay();
> >
> > + kmsan_handle_vprintk(&fmt, args);
>
> What does this function, please?
> Could I find more details in another patch?
>
> > /* This stops the holder of console_sem just where we want him */
> > logbuf_lock_irqsave(flags);
> > curr_log_seq = log_next_seq;
>
> Best Regards,
> Petr
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
next prev parent reply other threads:[~2019-10-29 14:00 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 9:42 [PATCH RFC v1 00/26] Add KernelMemorySanitizer infrastructure glider
2019-10-18 9:42 ` [PATCH RFC v1 01/26] stackdepot: check depot_index before accessing the stack slab glider
2019-10-18 9:42 ` [PATCH RFC v1 02/26] stackdepot: prevent Clang from optimizing away stackdepot_memcmp() glider
2019-10-18 9:42 ` [PATCH RFC v1 03/26] kasan: stackdepot: move filter_irq_stacks() to stackdepot.c glider
2019-10-18 9:42 ` [PATCH RFC v1 04/26] stackdepot: reserve 5 extra bits in depot_stack_handle_t glider
2019-10-18 9:42 ` [PATCH RFC v1 05/26] printk_safe: externalize printk_context glider
2019-10-21 9:09 ` Petr Mladek
2019-10-23 17:57 ` Alexander Potapenko
2019-10-23 18:00 ` Alexander Potapenko
2019-10-24 12:46 ` Petr Mladek
2019-10-28 13:09 ` Alexander Potapenko
2019-10-29 12:02 ` Petr Mladek
2019-10-29 12:45 ` Alexander Potapenko
2019-10-18 9:42 ` [PATCH RFC v1 06/26] kasan: compiler.h: rename __no_kasan_or_inline into __no_memory_tool_or_inline glider
2019-10-18 9:42 ` [PATCH RFC v1 07/26] kmsan: add ReST documentation glider
2019-10-18 9:42 ` [PATCH RFC v1 08/26] kmsan: gfp: introduce __GFP_NO_KMSAN_SHADOW glider
2019-10-18 9:42 ` [PATCH RFC v1 09/26] kmsan: introduce __no_sanitize_memory and __SANITIZE_MEMORY__ glider
2019-10-18 9:42 ` [PATCH RFC v1 10/26] kmsan: reduce vmalloc space glider
2019-10-18 9:42 ` [PATCH RFC v1 11/26] kmsan: add KMSAN runtime glider
2019-10-18 9:42 ` [PATCH RFC v1 12/26] kmsan: x86: sync metadata pages on page fault glider
2019-10-18 9:42 ` [PATCH RFC v1 13/26] kmsan: add tests for KMSAN glider
2019-10-18 9:42 ` [PATCH RFC v1 14/26] kmsan: make READ_ONCE_TASK_STACK() return initialized values glider
2019-10-18 9:42 ` [PATCH RFC v1 15/26] kmsan: Kconfig changes to disable options incompatible with KMSAN glider
2019-10-21 14:11 ` Harry Wentland
2019-10-18 9:42 ` [PATCH RFC v1 16/26] kmsan: Changing existing files to enable KMSAN builds glider
2019-10-18 9:42 ` [PATCH RFC v1 17/26] kmsan: disable KMSAN instrumentation for certain kernel parts glider
2019-10-18 9:42 ` [PATCH RFC v1 18/26] kmsan: mm: call KMSAN hooks from SLUB code glider
2019-10-18 13:22 ` Qian Cai
2019-10-18 13:33 ` Alexander Potapenko
2019-10-18 13:41 ` Qian Cai
2019-10-18 13:55 ` Alexander Potapenko
2019-10-18 14:42 ` Qian Cai
2019-10-18 14:54 ` Alexander Potapenko
2019-10-18 15:13 ` Qian Cai
2019-10-18 15:30 ` Alexander Potapenko
2019-10-18 16:08 ` Qian Cai
2019-10-18 9:42 ` [PATCH RFC v1 19/26] kmsan: call KMSAN hooks where needed glider
2019-10-18 15:02 ` Qian Cai
2019-10-29 14:09 ` Alexander Potapenko
2019-10-29 14:56 ` Qian Cai
2019-10-21 9:25 ` Petr Mladek
2019-10-29 13:59 ` Alexander Potapenko [this message]
2019-10-18 9:42 ` [PATCH RFC v1 20/26] kmsan: disable instrumentation of certain functions glider
2019-10-18 9:42 ` [PATCH RFC v1 21/26] kmsan: unpoison |tlb| in arch_tlb_gather_mmu() glider
2019-10-18 9:43 ` [PATCH RFC v1 22/26] kmsan: use __msan_memcpy() where possible glider
2019-10-18 9:43 ` [PATCH RFC v1 23/26] kmsan: unpoisoning buffers from devices etc glider
2019-10-18 15:27 ` Christoph Hellwig
2019-10-18 16:22 ` Matthew Wilcox
2019-10-29 14:45 ` Alexander Potapenko
2019-10-30 12:43 ` Alexander Potapenko
2019-10-18 9:43 ` [PATCH RFC v1 24/26] kmsan: hooks for copy_to_user() and friends glider
2019-10-18 9:43 ` [PATCH RFC v1 25/26] kmsan: disable strscpy() optimization under KMSAN glider
2019-10-18 9:43 ` [PATCH RFC v1 26/26] net: kasan: kmsan: support CONFIG_GENERIC_CSUM on x86, enable it for KASAN/KMSAN glider
2019-10-19 3:20 ` Randy Dunlap
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='CAG_fn=WhOymhOCFRXCvgufB3n6JHpQbXy9n6rYG5gRXvffm27A@mail.gmail.com' \
--to=glider@google.com \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-mm@kvack.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=vegard.nossum@oracle.com \
--cc=wsa@the-dreams.de \
/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