From patchwork Thu Sep 15 15:03:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12977529 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 24DA3C6FA8A for ; Thu, 15 Sep 2022 15:05:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EDB18000E; Thu, 15 Sep 2022 11:05:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69B0E8000C; Thu, 15 Sep 2022 11:05:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C6888000E; Thu, 15 Sep 2022 11:05:13 -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 3DD2C8000C for ; Thu, 15 Sep 2022 11:05:13 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1A7221206CE for ; Thu, 15 Sep 2022 15:05:13 +0000 (UTC) X-FDA: 79914642906.28.93FCA59 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) by imf10.hostedemail.com (Postfix) with ESMTP id 99164C0097 for ; Thu, 15 Sep 2022 15:05:12 +0000 (UTC) Received: by mail-ej1-f73.google.com with SMTP id xj11-20020a170906db0b00b0077b6ecb23fcso5863417ejb.5 for ; Thu, 15 Sep 2022 08:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=7DSx6RI0rEPDhrbVIpPikNsWTzcR9RC7kojIoDN82TE=; b=Ei0ZOo1tqmI3niKdg+NjyFrYcuWag/zfWQm1yP23l3BnyrmeeyX9JElhu/ainPdOo+ W/dywvadr04aecsU+ebZxNPOW9ICDqXTNUBOfu9kwz4f+GBrzmn4+l42PxeNQZxqW7qX Lc6kk/7HGejkAghJS9IEbkisG2lBRJSt45/r7bb7cF8xd11QNz4bx8M34JSwDTW4yhwt tJ78o05A6unsLVwF1wekgeIG4C2cUR1DKnuMtF3G53ElLkeVtM+TiQxtNlZWsycB4QVI EGJwbLtLFKkrnXnXXmVON0VvjQn5HAXmX0ge2JfPIbRLtNJmQD9OXFejAYW9ubOcI1mg OwYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=7DSx6RI0rEPDhrbVIpPikNsWTzcR9RC7kojIoDN82TE=; b=4xvHj1AN63izsJ8DwYuzXpSByFfpHjO2lMIHeACeWgHs+MQvWu5P1YUk+7ev69ZfuH 8VQEmJuTelg7U5aGLSENyFlFfw65MJw3XIbJNAEO8vKFRzCnMxdiraUDOnc5bH20kWqP 5Fk5foK2VxBcb0irg5ZYo40F6YyA2TP1xf3R+Yq0x7yQy6lCHV+r2IgHnfIj5sePCab5 EIcRoarCY+X+fXLv3DBUYlHi0i6AGIGa9gdGNXXf4uKN+w3YAfaLePi1ZbBYVdbPJeaJ /DwqcQ2t8QiwySJF3K8P76qKBphWXt3iamTsVbw0FUj/QaSdV1UfnYeRm1f+V7dJf8iM bIyw== X-Gm-Message-State: ACrzQf1sWTbFr7HUkh9z7OFVUAr8O/wUMTjAeMWahIcf49p+YxHUT5dI azjhM85EYNIM3w8Dgt7X8Sk68D5RJGw= X-Google-Smtp-Source: AMsMyM5UGtRZWEfRuSf8jc2keSvCdwG95jpOF1wSMEeWA1a/s2P04BTVQXHj5Bx/TIBtK5vybFlxr4pFIjQ= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:686d:27b5:495:85b7]) (user=glider job=sendgmr) by 2002:aa7:c74c:0:b0:44e:a7b9:d5c9 with SMTP id c12-20020aa7c74c000000b0044ea7b9d5c9mr264063eds.19.1663254311281; Thu, 15 Sep 2022 08:05:11 -0700 (PDT) Date: Thu, 15 Sep 2022 17:03:46 +0200 In-Reply-To: <20220915150417.722975-1-glider@google.com> Mime-Version: 1.0 References: <20220915150417.722975-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220915150417.722975-13-glider@google.com> Subject: [PATCH v7 12/43] 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 Biggers , 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 , Stephen Rothwell , 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663254312; a=rsa-sha256; cv=none; b=WJMvqGPER+ujECXR+GCe3Plk8JFo1rUZKbzh5ElM8PaO19spFIzcNTcwPuiapyrujar9cd EQxjIpoNFr7Fp1gNIsoF8CXpuXQFB7w1W7Im2bRKiNDPnTLBGA1w29m/z4rtz56DaCZlpP +JpM8lC9YR3l1EWFq9+58HQkcn42IYo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Ei0ZOo1t; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3Jz8jYwYKCFI052xyB08805y.w86527EH-664Fuw4.8B0@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3Jz8jYwYKCFI052xyB08805y.w86527EH-664Fuw4.8B0@flex--glider.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663254312; 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=7DSx6RI0rEPDhrbVIpPikNsWTzcR9RC7kojIoDN82TE=; b=VdKs6IzXeONen/RB5/zbpKhzCZXFlkTHQTuX88bPosIUKijX7oNqwE+PE+viPClUWvIGPU XtxG9RUVzjSAYtSqw6u0aMlKHEsEU91uZllpbwUAGqyAK9TWUz6tRiLPnFv2FtR8dghY+M Z5vDf60aAGUfSlgpwXbegwa6qcXTq4A= X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Ei0ZOo1t; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3Jz8jYwYKCFI052xyB08805y.w86527EH-664Fuw4.8B0@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3Jz8jYwYKCFI052xyB08805y.w86527EH-664Fuw4.8B0@flex--glider.bounces.google.com X-Stat-Signature: rpooxyzip7hx1umhn31cdgh93icsyyr8 X-Rspamd-Queue-Id: 99164C0097 X-Rspamd-Server: rspam09 X-HE-Tag: 1663254312-483935 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. Signed-off-by: Alexander Potapenko Reviewed-by: Marco Elver --- v4: -- This patch was previously part of "kmsan: disable KMSAN instrumentation for certain kernel parts", but was split away per Mark Rutland's request. v5: -- remove unnecessary comment belonging to another patch Link: https://linux-review.googlesource.com/id/I41ae706bd3474f074f6a870bfc3f0f90e9c720f7 --- drivers/firmware/efi/libstub/Makefile | 1 + kernel/Makefile | 1 + kernel/locking/Makefile | 3 ++- lib/Makefile | 3 +++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index 2c67f71f23753..2c1eb1fb0f226 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -53,6 +53,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 318789c728d32..d754e0be1176d 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 ffabc30a27d4e..fcebece0f5b6f 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -275,6 +275,9 @@ obj-$(CONFIG_POLYNOMIAL) += polynomial.o CFLAGS_stackdepot.o += -fno-builtin obj-$(CONFIG_STACKDEPOT) += stackdepot.o KASAN_SANITIZE_stackdepot.o := n +# In particular, instrumenting stackdepot.c with KMSAN will result in infinite +# recursion. +KMSAN_SANITIZE_stackdepot.o := n KCOV_INSTRUMENT_stackdepot.o := n obj-$(CONFIG_REF_TRACKER) += ref_tracker.o