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 X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72009C43603 for ; Tue, 10 Dec 2019 12:38:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17FE32073B for ; Tue, 10 Dec 2019 12:38:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nPGkkcBh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17FE32073B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9997A6B2C51; Tue, 10 Dec 2019 07:38:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 94A916B2C52; Tue, 10 Dec 2019 07:38:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85FFB6B2C53; Tue, 10 Dec 2019 07:38:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id 6E34B6B2C51 for ; Tue, 10 Dec 2019 07:38:38 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 0F72F8249980 for ; Tue, 10 Dec 2019 12:38:38 +0000 (UTC) X-FDA: 76249185516.26.patch75_4b3e9bf0d0e43 X-HE-Tag: patch75_4b3e9bf0d0e43 X-Filterd-Recvd-Size: 13382 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Dec 2019 12:38:36 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id n9so3022843wmd.3 for ; Tue, 10 Dec 2019 04:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=rcHt2D139ka2ggc7DCMSZD8bhnp1InRv2VuG+CCHyG4=; b=nPGkkcBh23v3dr5pfJrPlDwtjbDgPJ6quOs6ZtqX/KUHyVWGBrivPdf6lvtFtX9SAh KRHVbTqi0dhoIKzFCG0GZ57TTg6TzGJXzR+xwVWj0joa3OglDe2HILt4ASpbHCul3uN0 fQdoEqSok9eJjDzTGnkTkTurEtMYHJto7w2hXUdrIcUpWoWNzod0lB+73dl7BjEcnS2Y y62XJctjqzGC6FOBGojweSkqY56UOsIX2i8dpO6Aep1OzEN8NNNrJqCvv1eELzH0+AW7 IoIg4JHniZbwyGnmEww3uzzD188WqNtEiIalzPAu3Z9a4sDQVrbJWCMemo+AbjZ2fhTO LOVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=rcHt2D139ka2ggc7DCMSZD8bhnp1InRv2VuG+CCHyG4=; b=Xag3E1RUsJv3dC7Ks0QmFJ4JaRNxNzFAi3J6OYjh3jeaJjFgmQJbkC8EA3bk5ayogg qywNoT/pdG8Y+tUVBe658QMzq39Ov0jusOJ2qIsRsIqTWwSuN7mTg7AAKL64ZBE82PTk wiwjmakNfRpKzH6ZpwubawRuFWkPmiIBjdWP6IEw12LyYuQ2TD7rmkxoUtNVGPEP4Qnl NW5FVFkq1omnIoMo8j0zaYY9c2kd+Kbo9IyH1SRXGiyk8sQFW/JOtdDvQ9NZek507mSA 5v6ffgCB7WLv0oyYgs2HMhT0eKa1C3HiBu947yCuJQkJ0G40Ey7UF8ATKBPdmcsVWUqn ffZg== X-Gm-Message-State: APjAAAXLZvycwGeBdhVr4l5Sjv/HOCXSNC9MvPUG9tbnTKNAzb6uCB4L AOSksEF7/hkbejkKhlx0q8WcJJOtW3MEGxyVU7mPPg== X-Google-Smtp-Source: APXvYqy+gI10NRB2DdA/hSVKzrVvO/2in1OCOmmGDOhMWuPDRMjYa2Ga/oofTHTVPemZlx/ULw7AN/P3MevIwN4kz4U= X-Received: by 2002:a7b:cb46:: with SMTP id v6mr4908501wmj.117.1575981515388; Tue, 10 Dec 2019 04:38:35 -0800 (PST) MIME-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> <20191122112621.204798-22-glider@google.com> In-Reply-To: From: Alexander Potapenko Date: Tue, 10 Dec 2019 13:38:24 +0100 Message-ID: Subject: Re: [PATCH RFC v3 21/36] kmsan: disable KMSAN instrumentation for certain kernel parts To: Andrey Konovalov Cc: Ard Biesheuvel , Thomas Gleixner , Vegard Nossum , Dmitry Vyukov , Linux Memory Management List , Alexander Viro , Andreas Dilger , Andrew Morton , Andrey Ryabinin , Andy Lutomirski , Arnd Bergmann , Christoph Hellwig , Christoph Hellwig , "Darrick J. Wong" , "David S. Miller" , Dmitry Torokhov , Eric Biggers , Eric Dumazet , Eric Van Hensbergen , Greg Kroah-Hartman , Harry Wentland , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jason Wang , Jens Axboe , Marek Szyprowski , Marco Elver , Mark Rutland , "Martin K. Petersen" , Martin Schwidefsky , Matthew Wilcox , "Michael S . Tsirkin" , Michal Simek , Petr Mladek , Qian Cai , Randy Dunlap , Robin Murphy , Sergey Senozhatsky , Steven Rostedt , Takashi Iwai , "Theodore Ts'o" , Vasily Gorbik , Wolfram Sang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: Archived-At: List-Archive: List-Post: On Tue, Dec 10, 2019 at 11:35 AM Alexander Potapenko wr= ote: > > On Fri, Nov 29, 2019 at 4:07 PM Andrey Konovalov = wrote: > > > > On Fri, Nov 22, 2019 at 12:27 PM wrote: > > > > > > Instrumenting some files with KMSAN will result in kernel being unabl= e > > > to link, boot or crashing at runtime for various reasons (e.g. infini= te > > > recursion caused by instrumentation hooks calling instrumented code a= gain). > > > > > > Disable KMSAN in the following places: > > > - arch/x86/boot and arch/x86/realmode/rm, as KMSAN doesn't work for = i386; > > > - arch/x86/entry/vdso, which isn't linked with KMSAN runtime; > > > - three files in arch/x86/kernel - boot problems; > > > - arch/x86/mm/cpu_entry_area.c - recursion; > > > - EFI stub - build failures; > > > - kcov, stackdepot - recursion. > > > > It makes sense to unify comments explaining the reasons for > > KMSAN_SANITIZE :=3D n with KCSAN patches: > In principle, yes. > But KCSAN hasn't reached upstream yet, and rebasing on top of it will > increase the number of moving parts to take into account. Ah, I see. Yes, I'll add meaningful comments in v4. > > > https://patchwork.kernel.org/patch/11244145/ > > https://patchwork.kernel.org/patch/11244161/ > > > > > > > > Signed-off-by: Alexander Potapenko > > > To: Alexander Potapenko > > > Cc: Ard Biesheuvel > > > Cc: Thomas Gleixner > > > Cc: Vegard Nossum > > > Cc: Dmitry Vyukov > > > Cc: linux-mm@kvack.org > > > --- > > > > > > Change-Id: I90961eabf2dcb9ae992aed259088953bad5e4d6d > > > --- > > > arch/x86/boot/Makefile | 2 ++ > > > arch/x86/boot/compressed/Makefile | 2 ++ > > > arch/x86/entry/vdso/Makefile | 3 +++ > > > arch/x86/kernel/Makefile | 4 ++++ > > > arch/x86/kernel/cpu/Makefile | 1 + > > > arch/x86/mm/Makefile | 2 ++ > > > arch/x86/realmode/rm/Makefile | 2 ++ > > > drivers/firmware/efi/libstub/Makefile | 1 + > > > kernel/Makefile | 1 + > > > lib/Makefile | 1 + > > > 10 files changed, 19 insertions(+) > > > > > > diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile > > > index e2839b5c246c..c039abd4c81f 100644 > > > --- a/arch/x86/boot/Makefile > > > +++ b/arch/x86/boot/Makefile > > > @@ -10,6 +10,8 @@ > > > # > > > > > > KASAN_SANITIZE :=3D n > > > +# KMSAN doesn't work for i386 > > > +KMSAN_SANITIZE :=3D n > > > OBJECT_FILES_NON_STANDARD :=3D y > > > > > > # Kernel does not boot with kcov instrumentation here. > > > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compre= ssed/Makefile > > > index 6b84afdd7538..9efe2d9fca4c 100644 > > > --- a/arch/x86/boot/compressed/Makefile > > > +++ b/arch/x86/boot/compressed/Makefile > > > @@ -18,6 +18,8 @@ > > > # compressed vmlinux.bin.all + u32 size of vmlinux.bin.all > > > > > > KASAN_SANITIZE :=3D n > > > +# KMSAN doesn't work for i386 > > > +KMSAN_SANITIZE :=3D n > > > OBJECT_FILES_NON_STANDARD :=3D y > > > > > > # Prevents link failures: __sanitizer_cov_trace_pc() is not linked i= n. > > > diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makef= ile > > > index 0f2154106d01..000467a1a4f2 100644 > > > --- a/arch/x86/entry/vdso/Makefile > > > +++ b/arch/x86/entry/vdso/Makefile > > > @@ -11,6 +11,9 @@ include $(srctree)/lib/vdso/Makefile > > > > > > KBUILD_CFLAGS +=3D $(DISABLE_LTO) > > > KASAN_SANITIZE :=3D n > > > +# Undefined references to KMSAN hooks. > > > +KMSAN_SANITIZE_vclock_gettime.o :=3D n > > > +KMSAN_SANITIZE_vgetcpu.o :=3D n > > > UBSAN_SANITIZE :=3D n > > > OBJECT_FILES_NON_STANDARD :=3D y > > > > > > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile > > > index 3578ad248bc9..ce39972a7edf 100644 > > > --- a/arch/x86/kernel/Makefile > > > +++ b/arch/x86/kernel/Makefile > > > @@ -28,6 +28,10 @@ KASAN_SANITIZE_dumpstack_$(BITS).o = :=3D n > > > KASAN_SANITIZE_stacktrace.o :=3D n > > > KASAN_SANITIZE_paravirt.o :=3D n > > > > > > +# Work around reboot loop. > > > +KMSAN_SANITIZE_head$(BITS).o :=3D n > > > +KMSAN_SANITIZE_nmi.o :=3D n > > > + > > > OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o :=3D y > > > OBJECT_FILES_NON_STANDARD_test_nx.o :=3D y > > > OBJECT_FILES_NON_STANDARD_paravirt_patch.o :=3D y > > > diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makef= ile > > > index d7a1e5a9331c..41f4f8f2f2f0 100644 > > > --- a/arch/x86/kernel/cpu/Makefile > > > +++ b/arch/x86/kernel/cpu/Makefile > > > @@ -12,6 +12,7 @@ endif > > > # If these files are instrumented, boot hangs during the first secon= d. > > > KCOV_INSTRUMENT_common.o :=3D n > > > KCOV_INSTRUMENT_perf_event.o :=3D n > > > +KMSAN_SANITIZE_common.o :=3D n > > > > > > # Make sure load_percpu_segment has no stackprotector > > > nostackp :=3D $(call cc-option, -fno-stack-protector) > > > diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile > > > index 84373dc9b341..42cb3a6409b0 100644 > > > --- a/arch/x86/mm/Makefile > > > +++ b/arch/x86/mm/Makefile > > > @@ -7,6 +7,8 @@ KCOV_INSTRUMENT_mem_encrypt_identity.o :=3D n > > > KASAN_SANITIZE_mem_encrypt.o :=3D n > > > KASAN_SANITIZE_mem_encrypt_identity.o :=3D n > > > > > > +KMSAN_SANITIZE_cpu_entry_area.o :=3D n > > > + > > > ifdef CONFIG_FUNCTION_TRACER > > > CFLAGS_REMOVE_mem_encrypt.o =3D -pg > > > CFLAGS_REMOVE_mem_encrypt_identity.o =3D -pg > > > diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Mak= efile > > > index f60501a384f9..27e7bc0bbdde 100644 > > > --- a/arch/x86/realmode/rm/Makefile > > > +++ b/arch/x86/realmode/rm/Makefile > > > @@ -7,6 +7,8 @@ > > > # > > > # > > > KASAN_SANITIZE :=3D n > > > +# KMSAN doesn't work for i386 > > > +KMSAN_SANITIZE :=3D n > > > OBJECT_FILES_NON_STANDARD :=3D y > > > > > > # Prevents link failures: __sanitizer_cov_trace_pc() is not linked i= n. > > > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware= /efi/libstub/Makefile > > > index 0460c7581220..11869c17a64c 100644 > > > --- a/drivers/firmware/efi/libstub/Makefile > > > +++ b/drivers/firmware/efi/libstub/Makefile > > > @@ -32,6 +32,7 @@ KBUILD_CFLAGS :=3D $(cflags-y) -DDI= SABLE_BRANCH_PROFILING \ > > > > > > GCOV_PROFILE :=3D n > > > KASAN_SANITIZE :=3D n > > > +KMSAN_SANITIZE :=3D n > > > UBSAN_SANITIZE :=3D n > > > OBJECT_FILES_NON_STANDARD :=3D y > > > > > > diff --git a/kernel/Makefile b/kernel/Makefile > > > index daad787fb795..5fd6fbca2592 100644 > > > --- a/kernel/Makefile > > > +++ b/kernel/Makefile > > > @@ -30,6 +30,7 @@ KCOV_INSTRUMENT_extable.o :=3D n > > > # Don't self-instrument. > > > KCOV_INSTRUMENT_kcov.o :=3D n > > > KASAN_SANITIZE_kcov.o :=3D n > > > +KMSAN_SANITIZE_kcov.o :=3D n > > > CFLAGS_kcov.o :=3D $(call cc-option, -fno-conserve-stack -fno-stack-= protector) > > > > > > # cond_syscall is currently not LTO compatible > > > diff --git a/lib/Makefile b/lib/Makefile > > > index 08fcb37499a0..ae6e57d857b0 100644 > > > --- a/lib/Makefile > > > +++ b/lib/Makefile > > > @@ -222,6 +222,7 @@ obj-$(CONFIG_IRQ_POLL) +=3D irq_poll.o > > > CFLAGS_stackdepot.o +=3D -fno-builtin > > > obj-$(CONFIG_STACKDEPOT) +=3D stackdepot.o > > > KASAN_SANITIZE_stackdepot.o :=3D n > > > +KMSAN_SANITIZE_stackdepot.o :=3D n > > > KCOV_INSTRUMENT_stackdepot.o :=3D n > > > > > > libfdt_files =3D fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_stre= rror.o \ > > > -- > > > 2.24.0.432.g9d3f5f5b63-goog > > > > > > > -- > Alexander Potapenko > Software Engineer > > Google Germany GmbH > Erika-Mann-Stra=C3=9Fe, 33 > 80636 M=C3=BCnchen > > Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Halimah DeLaine Prado > Registergericht und -nummer: Hamburg, HRB 86891 > Sitz der Gesellschaft: Hamburg --=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, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg