From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 056FEECAAD1 for ; Tue, 30 Aug 2022 14:24:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 60E806B0074; Tue, 30 Aug 2022 10:24:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BDC1940007; Tue, 30 Aug 2022 10:24:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4105E6B0078; Tue, 30 Aug 2022 10:24:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2F57F6B0074 for ; Tue, 30 Aug 2022 10:24:22 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 08320C12DA for ; Tue, 30 Aug 2022 14:24:22 +0000 (UTC) X-FDA: 79856479164.28.68B80C9 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf08.hostedemail.com (Postfix) with ESMTP id AFA7D160054 for ; Tue, 30 Aug 2022 14:24:21 +0000 (UTC) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-32a09b909f6so277905737b3.0 for ; Tue, 30 Aug 2022 07:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=gt/5eV/ZpK3WodQ+XAEGUey1G3s7WAZiZKt3bPC8X9Y=; b=NJkAG1gpVqHfWInlurGJmVG3R+RA9MT+JGCwiveMgAZ2izde0jgt/HGcHXZpxsoM+D VX2DmYxU5+R06Av1HoBK2lfCyrLi0SHU35Xn3Eqg/1pT/OOEJXltQTuKai98zcE4qPc3 IyPVDXb7QXZdAdQs102YteFR2UaXoJog7lMP6N8UOoGxqzL+0EmI/kRV05/P/fNgYP1R u+tfUGRZZmvy2fluAPQYX/tLrSXQtbMStUsiHRhm7CaVhrm7UsEkVAAX9h6nlIKKWaF1 9zcnoe03OdMBz4ny6yBrIehUOgNyXloHhB7PVq+sp0OVonxt1HYY+lLh93wCriBKPj7N Rhmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=gt/5eV/ZpK3WodQ+XAEGUey1G3s7WAZiZKt3bPC8X9Y=; b=O/kViZF/wJJVkPrPes0N1Ea6zyd0pI2VjQ+9u54YPw04jryLgJHPscyd7ECVZnAeZ9 SA7lX2GZK8n3bU30H+pZBrkJR8/QspZKQH1y+5/UuUbj5gwlid+U2Wl1oBj/O0XGuMTj eAk8VsxLExvgl6Nuqk6DahK+axI/OH3vjms5NRFsNJxFR/MgfCx6pvX+zL1MfDYOpvYu gYUiiPFtdwxtA0NomWgWeBQnW36plw+KUly6OCpDu6/+1JMeWsAcB4eTKWxzqDL/SDlM xGtyIDRZDvPXc4o9TBmOwzO6dH0yLkDdLoN6ZCl4jew8t/Bq2ZHpzp7f4Vf2DUxeqvGM beHw== X-Gm-Message-State: ACgBeo1NYQ1l+OjuclQ+Nt6jzt2oIP0huzIRt30z5n+Wiw/SNqLzCMkH MCWrNwKuZSrIVUevRnXsEdsJ16WNGnBzXdLf5JYN+A== X-Google-Smtp-Source: AA6agR7jvVei8SmZabQHeD/SkA+/TrCqpW8qHKuBCJ3rJnHGAOGAH2dSiGFPEKmuWrV3gqrtSOKO3hjd/206yNSfB14= X-Received: by 2002:a05:6902:1106:b0:695:c353:2c32 with SMTP id o6-20020a056902110600b00695c3532c32mr12729722ybu.398.1661869460597; Tue, 30 Aug 2022 07:24:20 -0700 (PDT) MIME-Version: 1.0 References: <20220826150807.723137-1-glider@google.com> <20220826150807.723137-5-glider@google.com> <20220826211729.e65d52e7919fee5c34d22efc@linux-foundation.org> <20220829122452.cce41f2754c4e063f3ae8b75@linux-foundation.org> In-Reply-To: <20220829122452.cce41f2754c4e063f3ae8b75@linux-foundation.org> From: Alexander Potapenko Date: Tue, 30 Aug 2022 16:23:44 +0200 Message-ID: Subject: Re: [PATCH v5 04/44] x86: asm: instrument usercopy in get_user() and put_user() To: Andrew Morton , Marco Elver Cc: Alexander Viro , Alexei Starovoitov , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev , Linux Memory Management List , Linux-Arch , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661869461; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gt/5eV/ZpK3WodQ+XAEGUey1G3s7WAZiZKt3bPC8X9Y=; b=AxlJDhFjm4TWQbqxKglPglnQ+SI/y40lRaHfb0xB6ntVwRh3YKDRfU9xr8I3WcZDUuqf7n 7hu1evwgFX+EHFeD5SYrbs93OaIBYgI72YpsxpcyiCkP2DEBvWzoTWp8KualyA0bLHlKCU gAQpNGaSeIBRfKhlW9fSSYZggZefr9g= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=NJkAG1gp; spf=pass (imf08.hostedemail.com: domain of glider@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=glider@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661869461; a=rsa-sha256; cv=none; b=MvnVXYxdZUdbwvMSLpxktD3OXwLVyZpvpzFWaqKZU91zyQiewZU8uefKbr60QkW9KH6/f8 5gYlesHQwhtcezG6tfDtV0l54He3inoT1XziZuhTU0BVoLsEhvV9fEmfORhpwLFCV1McIv a4uUFuRwe+npwN10Ef77t4DyCylx9Tw= Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=NJkAG1gp; spf=pass (imf08.hostedemail.com: domain of glider@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=glider@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 6azahoc8yzn5a7hhm9tc7ka3xhky5zpp X-Rspamd-Queue-Id: AFA7D160054 X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1661869461-704430 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Aug 29, 2022 at 9:24 PM Andrew Morton w= rote: > > On Mon, 29 Aug 2022 16:57:31 +0200 Alexander Potapenko wrote: > > > On Sat, Aug 27, 2022 at 6:17 AM Andrew Morton wrote: > > > > > > On Fri, 26 Aug 2022 17:07:27 +0200 Alexander Potapenko 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/ac3859c02d7f40f59992737d63afcac= da0a972ec, > > 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 =E2=80=98instrument_get_user=E2=80=99" 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 =E2=80=98page_fixed_fake_head= =E2=80=99: > ./include/linux/page-flags.h:226:36: error: invalid use of undefined type= =E2=80=98const struct page=E2=80=99 > 226 | test_bit(PG_head, &page->flags)) { > | ^~ > ./include/linux/bitops.h:50:44: note: in definition of macro =E2=80=98bit= op=E2=80=99 > 50 | __builtin_constant_p((uintptr_t)(addr) !=3D (uintptr_t)= NULL) && \ > | ^~~~ > ./include/linux/page-flags.h:226:13: note: in expansion of macro =E2=80= =98test_bit=E2=80=99 > 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. --=20 Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg