From patchwork Fri Mar 19 14:40:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 12151197 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 58C9AC433DB for ; Fri, 19 Mar 2021 14:41:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E6D9164F18 for ; Fri, 19 Mar 2021 14:41:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6D9164F18 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 839D76B0070; Fri, 19 Mar 2021 10:41:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E9176B0072; Fri, 19 Mar 2021 10:41:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 63AF26B0075; Fri, 19 Mar 2021 10:41:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id 469F46B0070 for ; Fri, 19 Mar 2021 10:41:23 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 03FFD5837 for ; Fri, 19 Mar 2021 14:41:23 +0000 (UTC) X-FDA: 77936886804.07.A1E0FCD Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 80DAC4000F75 for ; Fri, 19 Mar 2021 14:41:10 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id x184so6034810pfd.6 for ; Fri, 19 Mar 2021 07:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ydwegfj06jUtcG1bKMw1Rb3csKPSe8+eJN43gEYqDtE=; b=CWsyw4mBVYYeByo2NmAV258BnfafVcVIoZvhJvhi6CNHCf+F9cnaxudDwiLQtI/tdx 7QZM8TZBam/tGkDvyQEtIFfXOt24Z5+pMalET8WYuKJ5MIN7UC9Ehz9bJTHW5/v8sRoY xHUySAj/MPui5Z8chx1OrAVZIrdBn1g5vsACk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ydwegfj06jUtcG1bKMw1Rb3csKPSe8+eJN43gEYqDtE=; b=sR7H6p/cAVXQzkGJdfqdNS70J4RSYEMdD55eDtPons8BHcx2zgFyIcef7ByKfAJJ4+ U0MNDdrVSALbzkWmnIUG2LT8YRhTuXKRd939BcZ4DG9RgxZsCIKSu7A9yv8P+ozr10pd MqTJvt0iZ6Z/NeOAMjrbQt5su/AcAIh3z93Gf0H2yR8rOYXHm+DpruRV9i09uLcj7xk8 gZFoIgeVw3z5nkbu2Vdkv6ypT3+Zo8cUCmJWrk8uRobEc3eKdCPqGayhWGv3po7LGnbW k62HoQiHglTT34uf2y2iuvjGuLRwPz/3X4bmn2i3VtpVoMCwf8qLDkYdXX31vS+WhPYF mM7g== X-Gm-Message-State: AOAM533vV5IWkK+MkAvrhcgxBsjbT8QEMJIrjBCtiU5/oGiefwAxAZdO ug/D1IyHo41VlDNFaNZGtaKCXg== X-Google-Smtp-Source: ABdhPJx8jC6sFzPVzCCBeAE55Npits4PhLlsXPXK2kY5DhbeqW460kQQ2vJrsrniRqiY86+J6PWQiw== X-Received: by 2002:a63:181c:: with SMTP id y28mr11211891pgl.175.1616164868280; Fri, 19 Mar 2021 07:41:08 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-674e-5c6f-efc9-136d.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:674e:5c6f:efc9:136d]) by smtp.gmail.com with ESMTPSA id v13sm5242767pfu.54.2021.03.19.07.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 07:41:08 -0700 (PDT) From: Daniel Axtens To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, kasan-dev@googlegroups.com, christophe.leroy@csgroup.eu, aneesh.kumar@linux.ibm.com, bsingharora@gmail.com Cc: Daniel Axtens Subject: [PATCH v11 1/6] kasan: allow an architecture to disable inline instrumentation Date: Sat, 20 Mar 2021 01:40:53 +1100 Message-Id: <20210319144058.772525-2-dja@axtens.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210319144058.772525-1-dja@axtens.net> References: <20210319144058.772525-1-dja@axtens.net> MIME-Version: 1.0 X-Stat-Signature: ci1tim8zb387cycnachsttu33ai6tp1y X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 80DAC4000F75 Received-SPF: none (axtens.net>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=mail-pf1-f172.google.com; client-ip=209.85.210.172 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616164870-244376 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: For annoying architectural reasons, it's very difficult to support inline instrumentation on powerpc64. Add a Kconfig flag to allow an arch to disable inline. (It's a bit annoying to be 'backwards', but I'm not aware of any way to have an arch force a symbol to be 'n', rather than 'y'.) We also disable stack instrumentation in this case as it does things that are functionally equivalent to inline instrumentation, namely adding code that touches the shadow directly without going through a C helper. Signed-off-by: Daniel Axtens --- lib/Kconfig.kasan | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index cffc2ebbf185..7e237dbb6df3 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -12,6 +12,9 @@ config HAVE_ARCH_KASAN_HW_TAGS config HAVE_ARCH_KASAN_VMALLOC bool +config ARCH_DISABLE_KASAN_INLINE + def_bool n + config CC_HAS_KASAN_GENERIC def_bool $(cc-option, -fsanitize=kernel-address) @@ -130,6 +133,7 @@ config KASAN_OUTLINE config KASAN_INLINE bool "Inline instrumentation" + depends on !ARCH_DISABLE_KASAN_INLINE help Compiler directly inserts code checking shadow memory before memory accesses. This is faster than outline (in some workloads @@ -142,6 +146,7 @@ config KASAN_STACK bool "Enable stack instrumentation (unsafe)" if CC_IS_CLANG && !COMPILE_TEST depends on KASAN_GENERIC || KASAN_SW_TAGS default y if CC_IS_GCC + depends on !ARCH_DISABLE_KASAN_INLINE help The LLVM stack address sanitizer has a know problem that causes excessive stack usage in a lot of functions, see @@ -154,6 +159,9 @@ config KASAN_STACK but clang users can still enable it for builds without CONFIG_COMPILE_TEST. On gcc it is assumed to always be safe to use and enabled by default. + If the architecture disables inline instrumentation, this is + also disabled as it adds inline-style instrumentation that + is run unconditionally. config KASAN_SW_TAGS_IDENTIFY bool "Enable memory corruption identification"