From patchwork Fri Jul 1 14:22:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12903369 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 D3BD8C433EF for ; Fri, 1 Jul 2022 14:23:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 695E86B0083; Fri, 1 Jul 2022 10:23:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6458F6B0085; Fri, 1 Jul 2022 10:23:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 537346B0087; Fri, 1 Jul 2022 10:23:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3BCF96B0083 for ; Fri, 1 Jul 2022 10:23:51 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 18B538085F for ; Fri, 1 Jul 2022 14:23:51 +0000 (UTC) X-FDA: 79638749862.02.AA30AD1 Received: from mail-lj1-f202.google.com (mail-lj1-f202.google.com [209.85.208.202]) by imf03.hostedemail.com (Postfix) with ESMTP id A3AC320039 for ; Fri, 1 Jul 2022 14:23:50 +0000 (UTC) Received: by mail-lj1-f202.google.com with SMTP id d24-20020a2eb058000000b0025a7f5ccae6so501666ljl.14 for ; Fri, 01 Jul 2022 07:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=prMZkaWSelYFGUo1Yp0oSlk2FGuv/jH48kix0SjfSqo=; b=hUrPjZ5xQAK1rq1Z9VjevL+FrrINSG0tRRhgiAbMolgJVMWGIx4r5RfIMIwzpxc6ms gUg7hKctDb4wQE3VOaCHWIV2LGy5Ucp2ZAB7kF9GJdFo1NEyX0t952wecwLOOKno1+2E 1rgmYSk4NtJQfzw9K/W+3BAffRewOQGfttd7giwJGo9MV8LuZwy/QsokSAd/dtQcFE3M z+L8uHLCgsAlvhMmnJc8Wq3E2JUFEG6y6kF7zDOvDO2SeAdTgKBtF3nkCOG4j2QwCqre z530iem10UaCweSv2liUUURMK8s4nPk+0u5brQ3OdzHhBaeQjctMcqzwscixL/Fwjs+v C1qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=prMZkaWSelYFGUo1Yp0oSlk2FGuv/jH48kix0SjfSqo=; b=xPOYAst7ciLQZ2ws6ojxSeesYY1AU4HzUOPHa9GXK4QHkYQYdxNj5yalb/q7aJALZw Wccz4xnWpHZTk+W5EzScB6ouO+F2/BZCKfOMM6hn7VByHY4zmbH6nuVOPOCagdE15JYT /NEowTk3f1bNbFQTcXjyybsJ1oDGLJOsMXL+704FPrVq6zB5jYfYUDgJ2UIHwVRP3Txi gcEdld0uY3rAc2shsUVMqx7ybueRXxWFbtN2HMeIVvZcFbzt0kT8CArfnUCJYMIFbuhd tQxUFUUlbgcp2ATHsuHyvJzncBiIAazxetqMs1HlhyocTa221VClQucVJBDuV46VYW1+ 64tQ== X-Gm-Message-State: AJIora9QBO/5k0cFlUd6fBXD9pDaBrr5LSO/1QVYNFzrCXm1fNvYBRPw RWwlfqmNiUnhzc/THo6Kvb3rdLskaSw= X-Google-Smtp-Source: AGRyM1tkPv2qxZS7ch8ZP9uL8wXLQqYDrfQpsgzEv2crKp3uD9M2y3fPjLDqyCgehGEb/p3HkajEMnoQMWA= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:a6f5:f713:759c:abb6]) (user=glider job=sendgmr) by 2002:a05:6512:2622:b0:481:5b17:58e7 with SMTP id bt34-20020a056512262200b004815b1758e7mr2552760lfb.600.1656685428893; Fri, 01 Jul 2022 07:23:48 -0700 (PDT) Date: Fri, 1 Jul 2022 16:22:37 +0200 In-Reply-To: <20220701142310.2188015-1-glider@google.com> Message-Id: <20220701142310.2188015-13-glider@google.com> Mime-Version: 1.0 References: <20220701142310.2188015-1-glider@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v4 12/45] kmsan: disable instrumentation of unsupported common kernel code From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , 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 , Marco Elver , 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@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hUrPjZ5x; spf=pass (imf03.hostedemail.com: domain of 3dAO_YgYKCJM38501E3BB381.zB985AHK-997Ixz7.BE3@flex--glider.bounces.google.com designates 209.85.208.202 as permitted sender) smtp.mailfrom=3dAO_YgYKCJM38501E3BB381.zB985AHK-997Ixz7.BE3@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656685430; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=prMZkaWSelYFGUo1Yp0oSlk2FGuv/jH48kix0SjfSqo=; b=HT0h78QzUPsWUUmegNdnnpBRgkwnoh3fQurrf5SNOmbBO+/ZhAmAPPBSIVGLGGauiScj8/ aWKMBPCfIiR7Z3EJ5/wYznVxdW9XF9ovJJyDImHc7LofaS5N1hh7PGDmtV+vTePAkJBtOZ ibgLDmALffAekZ2qHu2BZUqQ8s3oz5I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656685430; a=rsa-sha256; cv=none; b=xx0afgJJgIfIT20dpepcYhl4+TQqZQVuIz25RvQ2h4RONCp1LhoQxNBOUpMRNscdEKY9L7 BXgtADM3bwknQnlgJJf597/DyM2y7EqJ7B8EOaUh8umrspBhIE/bwEEkYEy+7QL5rGak/O Qg7bYH9WPQwPpPLnEACAYro2CvWziOU= X-Stat-Signature: 49t4xg8hzgfhbdfaart6fu7nt45u8eba X-Rspamd-Queue-Id: A3AC320039 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hUrPjZ5x; spf=pass (imf03.hostedemail.com: domain of 3dAO_YgYKCJM38501E3BB381.zB985AHK-997Ixz7.BE3@flex--glider.bounces.google.com designates 209.85.208.202 as permitted sender) smtp.mailfrom=3dAO_YgYKCJM38501E3BB381.zB985AHK-997Ixz7.BE3@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1656685430-993189 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: EFI stub cannot be linked with KMSAN runtime, so we disable instrumentation for it. Instrumenting kcov, stackdepot or lockdep leads to infinite recursion caused by instrumentation hooks calling instrumented code again. This patch was previously part of "kmsan: disable KMSAN instrumentation for certain kernel parts", but was split away per Mark Rutland's request. Signed-off-by: Alexander Potapenko Reviewed-by: Marco Elver --- Link: https://linux-review.googlesource.com/id/I41ae706bd3474f074f6a870bfc3f0f90e9c720f7 --- drivers/firmware/efi/libstub/Makefile | 1 + kernel/Makefile | 1 + kernel/locking/Makefile | 3 ++- lib/Makefile | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index d0537573501e9..81432d0c904b1 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -46,6 +46,7 @@ GCOV_PROFILE := n # Sanitizer runtimes are unavailable and cannot be linked here. KASAN_SANITIZE := n KCSAN_SANITIZE := n +KMSAN_SANITIZE := n UBSAN_SANITIZE := n OBJECT_FILES_NON_STANDARD := y diff --git a/kernel/Makefile b/kernel/Makefile index a7e1f49ab2b3b..e47f0526c987f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -38,6 +38,7 @@ KCOV_INSTRUMENT_kcov.o := n KASAN_SANITIZE_kcov.o := n KCSAN_SANITIZE_kcov.o := n UBSAN_SANITIZE_kcov.o := n +KMSAN_SANITIZE_kcov.o := n CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack) -fno-stack-protector # Don't instrument error handlers diff --git a/kernel/locking/Makefile b/kernel/locking/Makefile index d51cabf28f382..ea925731fa40f 100644 --- a/kernel/locking/Makefile +++ b/kernel/locking/Makefile @@ -5,8 +5,9 @@ KCOV_INSTRUMENT := n obj-y += mutex.o semaphore.o rwsem.o percpu-rwsem.o -# Avoid recursion lockdep -> KCSAN -> ... -> lockdep. +# Avoid recursion lockdep -> sanitizer -> ... -> lockdep. KCSAN_SANITIZE_lockdep.o := n +KMSAN_SANITIZE_lockdep.o := n ifdef CONFIG_FUNCTION_TRACER CFLAGS_REMOVE_lockdep.o = $(CC_FLAGS_FTRACE) diff --git a/lib/Makefile b/lib/Makefile index f99bf61f8bbc6..5056769d00bb6 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -272,6 +272,7 @@ obj-$(CONFIG_POLYNOMIAL) += polynomial.o CFLAGS_stackdepot.o += -fno-builtin obj-$(CONFIG_STACKDEPOT) += stackdepot.o KASAN_SANITIZE_stackdepot.o := n +KMSAN_SANITIZE_stackdepot.o := n KCOV_INSTRUMENT_stackdepot.o := n obj-$(CONFIG_REF_TRACKER) += ref_tracker.o