From patchwork Fri Aug 26 15:07:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12956185 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 32AACECAAD5 for ; Fri, 26 Aug 2022 15:08:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5790940013; Fri, 26 Aug 2022 11:08:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B19A1940007; Fri, 26 Aug 2022 11:08:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F658940013; Fri, 26 Aug 2022 11:08:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7CC3B940007 for ; Fri, 26 Aug 2022 11:08:47 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5709C120F4C for ; Fri, 26 Aug 2022 15:08:47 +0000 (UTC) X-FDA: 79842075894.19.2201319 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf12.hostedemail.com (Postfix) with ESMTP id EBCE640026 for ; Fri, 26 Aug 2022 15:08:46 +0000 (UTC) Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-33da75a471cso29359517b3.20 for ; Fri, 26 Aug 2022 08:08:46 -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; bh=mLlFYFB/rgc9qqJnOoWYqSqEWYlWfzhxjk78c+cLuAA=; b=XiFqi+HvFYWVKfCkxZSEvaLp4dj6PJCrtRX+y89NfMTPZ6+goUHOrJlaygaqkuIGBr cdc5TBzN75bo5l86pnTnW79iKtt96Ou0SDdJM2YIL9g3uoi3Job0DZK7q/nIm6l/tWpV UNDqvTKx+/6Oadm/ZjmMPEuU3raZ5GAff/rF0sMmJtdeCbxKEsKayU6Bd3s50LCPKUcZ oMZ+RIGrr0zlDQke70b2ZaiBxuU5QGWCP+5v5NfPFB1kpt3JEHHNKAiGV5LkFVztHN6G +Uh7pGeyKXy0VtS5AtzRj9P6HtYc37b8quRD9x2XVb1xZapp20z/LcMX0wNNYJelokgN IPMA== 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; bh=mLlFYFB/rgc9qqJnOoWYqSqEWYlWfzhxjk78c+cLuAA=; b=O56yYwd9nlK398AtVUJtdx0FY4ypb9JvAk2NXk60rvq/p9OTd3/BAL1H+7EX6+B778 S8oQMQLuL7jP8ose7mhZWUi2Ynm+3XO1FY1giRbhntWtLa/PEmaz3APNl62LRmY50TO5 BauTId0o8JRxtg1Rcr/Te9vCHFc/Ngm12cMMv1Mrw3CFBWdMpLz3XHhMJi3vw/AQz7P9 vU00NoGnJgZAJlJo59kygU39oCmsvVfkcFWOYI+H079MYyA8vGimRXwqtfd8jfuZUbQM ZjVL40v1Le/bodlOiUxtmRlVocD52tpv9dUnRYPeVYD8QwfpUTK4vlyCb/b1h178BtUc w+xg== X-Gm-Message-State: ACgBeo0wS//Obs9z5lMt0e6bIpHw8tdU+DgVGHVN1cjoEZVi94x3636x Stf1dTwlTCIKg+fHSIY//Bd+nMLsqbs= X-Google-Smtp-Source: AA6agR57RONmOxoyPLmSyjKKyC9XY3IjUGI1gX8npn/cM8EWP8iDs6QDrjkGDieykAPqCJaWURQiX5dgMQY= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:5207:ac36:fdd3:502d]) (user=glider job=sendgmr) by 2002:a0d:f144:0:b0:33d:a554:b9b6 with SMTP id a65-20020a0df144000000b0033da554b9b6mr135036ywf.172.1661526526267; Fri, 26 Aug 2022 08:08:46 -0700 (PDT) Date: Fri, 26 Aug 2022 17:07:35 +0200 In-Reply-To: <20220826150807.723137-1-glider@google.com> Mime-Version: 1.0 References: <20220826150807.723137-1-glider@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220826150807.723137-13-glider@google.com> Subject: [PATCH v5 12/44] 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; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=XiFqi+Hv; spf=pass (imf12.hostedemail.com: domain of 3_uEIYwYKCAUlqnijwlttlqj.htrqnsz2-rrp0fhp.twl@flex--glider.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3_uEIYwYKCAUlqnijwlttlqj.htrqnsz2-rrp0fhp.twl@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661526527; a=rsa-sha256; cv=none; b=P66/48AWYq2psk1oR1tzmdtjEg96t2BxgqPxUoosljXFEzdxdWaQrou+vLoi0jq4DoZRDs q2jD9J4XBTsS8k4J9pJM/tqAbJjCGik9odARgAUBiDcXfK42iVt+OxzQ+haGW6OynBVQP9 YKJNFtEr/jJaFduDobyutlVeOvfU5S4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661526527; 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=mLlFYFB/rgc9qqJnOoWYqSqEWYlWfzhxjk78c+cLuAA=; b=z74aKcS72RweFJPmnYl0Y3e+LHArywynujL80Y2iKl3GgEi4X6Q078sl0mBKkua5BXhDtl UGvd+k5PO11HWHIDdiZe8Pqk+1+IqsYNFERjVGwRH7DMis57JH1lWjrr10utmVOO628ANJ 5iFDZLK7+lcMHrNIfxtxZeEUFgaPtKY= X-Rspam-User: X-Stat-Signature: qcmeftdz1iybughpo9cdbjj8qmso1isp X-Rspamd-Queue-Id: EBCE640026 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=XiFqi+Hv; spf=pass (imf12.hostedemail.com: domain of 3_uEIYwYKCAUlqnijwlttlqj.htrqnsz2-rrp0fhp.twl@flex--glider.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3_uEIYwYKCAUlqnijwlttlqj.htrqnsz2-rrp0fhp.twl@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam09 X-HE-Tag: 1661526526-878528 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 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 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 5927d7fa08063..22c064b61b3be 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