Re: [PATCH v5 32/38] kmsan: disable strscpy() optimization under KMSAN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 8, 2020 at 6:01 PM Andrey Konovalov <andreyknvl@xxxxxxxxxx> wrote:
>
> On Wed, Mar 25, 2020 at 5:14 PM <glider@xxxxxxxxxx> wrote:
> >
> > Disable the efficient 8-byte reading under KMSAN to avoid false positives.
>
> Another user of read_word_at_a_time() is dentry_string_cmp() in
> dcache.c, should we disable it there as well?
>

I think we'd better disable DCACHE_WORD_ACCESS if KMSAN is enabled.
Will do that in v6.

> >
> > Signed-off-by: Alexander Potapenko <glider@xxxxxxxxxx>
> > To: Alexander Potapenko <glider@xxxxxxxxxx>
> > Cc: Vegard Nossum <vegard.nossum@xxxxxxxxxx>
> > Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
> > Cc: Marco Elver <elver@xxxxxxxxxx>
> > Cc: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
> > Cc: linux-mm@xxxxxxxxx
> >
> > ---
> >
> > v4:
> >  - actually disable the optimization under KMSAN via max=0
> >  - use IS_ENABLED as requested by Marco Elver
> >
> > Change-Id: I25d1acf5c3df6eff85894cd94f5ddbe93308271c
> > ---
> >  lib/string.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/lib/string.c b/lib/string.c
> > index 6012c385fb314..fec929e70f1a5 100644
> > --- a/lib/string.c
> > +++ b/lib/string.c
> > @@ -202,6 +202,14 @@ ssize_t strscpy(char *dest, const char *src, size_t count)
> >                 max = 0;
> >  #endif
> >
> > +       /*
> > +        * read_word_at_a_time() below may read uninitialized bytes after the
> > +        * trailing zero and use them in comparisons. Disable this optimization
> > +        * under KMSAN to prevent false positive reports.
> > +        */
> > +       if (IS_ENABLED(CONFIG_KMSAN))
> > +               max = 0;
> > +
> >         while (max >= sizeof(unsigned long)) {
> >                 unsigned long c, data;
> >
> > --
> > 2.25.1.696.g5e7596f4ac-goog
> >



-- 
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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux