Re: [PATCH v5 04/44] x86: asm: instrument usercopy in get_user() and put_user()

From: Alexander Potapenko
Date: Mon Aug 29 2022 - 10:58:15 EST


On Sat, Aug 27, 2022 at 6:17 AM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, 26 Aug 2022 17:07:27 +0200 Alexander Potapenko <glider@xxxxxxxxxx> 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?


> > --- a/arch/x86/include/asm/uaccess.h
> > +++ b/arch/x86/include/asm/uaccess.h
> > @@ -5,6 +5,7 @@
> > * User space memory access functions
> > */
> > #include <linux/compiler.h>
> > +#include <linux/instrumented.h>
> > #include <linux/kasan-checks.h>
> > #include <linux/string.h>
> > #include <asm/asm.h>
>
> instrumented.h looks like a higher-level thing than uaccess.h, so this
> inclusion is an inappropriate layering. Or maybe not.
>
> 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)) {
> | ^~
>
> [25000 lines snipped]
>
>
> And kmsan-add-kmsan-runtime-core.patch introduces additional build
> errors with x86_64 allmodconfig.
>
> This is all with CONFIG_KMSAN=n
>
> I'll disable the patch series. Please do much more compilation testing
> - multiple architectures, allnoconfig, allmodconfig, allyesconfig,
> defconfig, randconfig, etc. Good luck, it looks ugly :(
>


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