lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAG_fn=X6eZ6Cdrv5pivcROHi3D8uymdgh+EbnFasBap2a=0LQQ@mail.gmail.com>
Date:   Tue, 30 Aug 2022 16:23:44 +0200
From:   Alexander Potapenko <glider@...gle.com>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Marco Elver <elver@...gle.com>
Cc:     Alexander Viro <viro@...iv.linux.org.uk>,
        Alexei Starovoitov <ast@...nel.org>,
        Andrey Konovalov <andreyknvl@...gle.com>,
        Andy Lutomirski <luto@...nel.org>,
        Arnd Bergmann <arnd@...db.de>, Borislav Petkov <bp@...en8.de>,
        Christoph Hellwig <hch@....de>,
        Christoph Lameter <cl@...ux.com>,
        David Rientjes <rientjes@...gle.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Eric Dumazet <edumazet@...gle.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        Ilya Leoshkevich <iii@...ux.ibm.com>,
        Ingo Molnar <mingo@...hat.com>, Jens Axboe <axboe@...nel.dk>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Kees Cook <keescook@...omium.org>,
        Mark Rutland <mark.rutland@....com>,
        Matthew Wilcox <willy@...radead.org>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Pekka Enberg <penberg@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Petr Mladek <pmladek@...e.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Vasily Gorbik <gor@...ux.ibm.com>,
        Vegard Nossum <vegard.nossum@...cle.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        kasan-dev <kasan-dev@...glegroups.com>,
        Linux Memory Management List <linux-mm@...ck.org>,
        Linux-Arch <linux-arch@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 04/44] x86: asm: instrument usercopy in get_user() and put_user()

On Mon, Aug 29, 2022 at 9:24 PM Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Mon, 29 Aug 2022 16:57:31 +0200 Alexander Potapenko <glider@...gle.com> wrote:
>
> > On Sat, Aug 27, 2022 at 6:17 AM Andrew Morton <akpm@...ux-foundation.org> wrote:
> > >
> > > On Fri, 26 Aug 2022 17:07:27 +0200 Alexander Potapenko <glider@...gle.com> wrote:
> > >
> > > > Use hooks from instrumented.h to notify bug detection tools about
> > > > usercopy events in variations of get_user() and put_user().
> > >
> > > And this one blows up x86_64 allmodconfig builds.
> >
> > How do I reproduce this?
> > I tried running `make mrproper; make allmodconfig; make -j64` (or
> > allyesconfig, allnoconfig) on both KMSAN tree
> > (https://github.com/google/kmsan/commit/ac3859c02d7f40f59992737d63afcacda0a972ec,
> > which is Linux v6.0-rc2 plus the 44 KMSAN patches) and
> > linux-mm/mm-stable @ec6624452e36158d0813758d837f7a2263a4109d with
> > KMSAN patches applied on top of it.
> > All builds were successful.
> >
> > I then tried to cherry-pick just the first 4 commits to mm-stable and
> > see if allmodconfig works - it resulted in numerous "implicit
> > declaration of function ‘instrument_get_user’" errors (quite silly of
> > me), but nothing looking like the errors you posted.
> > I'll try to build-test every patch in the series after fixing the
> > missing declarations, but so far I don't see other problems.
> >
> > Could you share the mmotm commit id which resulted in the failures?
>
> I just pushed out a tree which exhibits this with gcc-12.1.1 and with
> gcc-11.1.0.  Tag is mm-everything-2022-08-29-19-17.
>
> The problem is introduced by d0d9a44d2210 ("kmsan: add KMSAN runtime core")
>
> make mrproper
> make allmodconfig
> make init/do_mounts.o
>
> In file included from ./include/linux/kernel.h:22,
>                  from ./arch/x86/include/asm/percpu.h:27,
>                  from ./arch/x86/include/asm/nospec-branch.h:14,
>                  from ./arch/x86/include/asm/paravirt_types.h:40,
>                  from ./arch/x86/include/asm/ptrace.h:97,
>                  from ./arch/x86/include/asm/math_emu.h:5,
>                  from ./arch/x86/include/asm/processor.h:13,
>                  from ./arch/x86/include/asm/timex.h:5,
>                  from ./include/linux/timex.h:67,
>                  from ./include/linux/time32.h:13,
>                  from ./include/linux/time.h:60,
>                  from ./include/linux/stat.h:19,
>                  from ./include/linux/module.h:13,
>                  from init/do_mounts.c:2:
> ./include/linux/page-flags.h: In function ‘page_fixed_fake_head’:
> ./include/linux/page-flags.h:226:36: error: invalid use of undefined type ‘const struct page’
>   226 |             test_bit(PG_head, &page->flags)) {
>       |                                    ^~
> ./include/linux/bitops.h:50:44: note: in definition of macro ‘bitop’
>    50 |           __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \
>       |                                            ^~~~
> ./include/linux/page-flags.h:226:13: note: in expansion of macro ‘test_bit’
>   226 |             test_bit(PG_head, &page->flags)) {
>       |             ^~~~~~~~
> ...

Gotcha, this is a circular dependency: mm_types.h -> sched.h ->
kmsan.h -> gfp.h -> mmzone.h -> page-flags.h -> mm_types.h, where the
inclusion of sched.h into mm_types.h was only introduced in "mm:
multi-gen LRU: support page table walks" - that's why the problem was
missing in other trees.

In fact sched.h only needs the definitions of `struct
kmsan_context_state` and `struct kmsan_ctx` from kmsan.h, so I am
splitting them off into kmsan_types.h to break this circle.
Doing so also helped catch a couple of missing/incorrect inclusions of
KMSAN headers in subsystems.

I'll fix those and do more testing.

-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ