Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp282780pxj; Wed, 16 Jun 2021 02:11:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys+u1GGPAk41VD0pGIdM6A7j1a1NLUx2tvkZR9l4QIIUrtH4TnfOdO9Cm0nFUWYFVFAZ72 X-Received: by 2002:a17:906:b2cb:: with SMTP id cf11mr1631098ejb.448.1623834709437; Wed, 16 Jun 2021 02:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623834709; cv=none; d=google.com; s=arc-20160816; b=UVH7YvTBaVTxjqHDeUNXpQSzk+lBzYr39K9gK9rcZNGULIgtAJ8QO2LNqXQRg2/OVh F0u7ZwnE8LU+ZhfXWmbNIhIn/BFAkhCZAGYIuPMwQyNmb6YlJI3PYg3IIXtoExpa8Lcz tVHbbTA4ektsl2I0c0iIDwV+Zcs4N9rddNMK6tg0QgUxFdSgRLmnWWOzXmIzym7BMwCy ZZrW1f/i3Zn8GdyShfQI8WypWyuwBWANXbzLh1nNsAdbQaZbcl0LZ/Pypdp4+5U9sIRx XzAqm6twFEpwNTqrJjSAMThWZ/r6jtmRzof98fUBh9lSddhFrupNnBgw36SmHbiSMQK0 paNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=N0yUvQwf56uXT+DeZe9wCbbuUfkwdrAhTZdP0qYYdjo=; b=SY4o74lONzf7qT6FfD9IA/V4bWs8T/l88TlaCTvYKgzi7796XlL1K8RihjWo0eWEXu 0r1MO5osQP064941WjSJblRRTqyVrKyfStojFdQGeet3/HZNr3lVnnFlpk4RVI4aOeTG 7xbFbIuXkKVem2kpxNviGZiLwjfsfoIIa/jDZf8T8RPhfyCNbfyjhmoNS7xS8LtYBp8J nXVYtmqOGxQGf1XkdRu8xqJHkFJitiLrXYpd47+j1Ye4Cy8BHCg1Kc1IjVP6U1tOAje0 HdS785toBWKE5QkeL+qKlUyzF81Ex/qQbPrqNgPWb7Zu498vSwTsk6Sor6Ct9u0EFIse wbbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qXg9QAKz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 30si1623647ejh.725.2021.06.16.02.11.26; Wed, 16 Jun 2021 02:11:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qXg9QAKz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232093AbhFPJMQ (ORCPT + 99 others); Wed, 16 Jun 2021 05:12:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbhFPJMQ (ORCPT ); Wed, 16 Jun 2021 05:12:16 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71EAEC06175F for ; Wed, 16 Jun 2021 02:10:10 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id 7-20020a9d0d070000b0290439abcef697so1835454oti.2 for ; Wed, 16 Jun 2021 02:10:10 -0700 (PDT) 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; bh=N0yUvQwf56uXT+DeZe9wCbbuUfkwdrAhTZdP0qYYdjo=; b=qXg9QAKzdXfthLDxP6zeemP2casijCB6XU3FXrtn/t+04x7cIVKbqlwYXO/NW83y5N FYeOBm0U+vOR+S7vlL8vPEZS92ikMZai1afR/J68OkxxbK60emPCifUaoZRWR670JtV1 i4RKNRk8bvwV3XC2sEDdy3AREtzi3oAkh5npEUNKEMvf/XXsQiUWIHioCfJ2JvhzVWx3 +FVwpFNpV7NAUxq8aYV9V+myvwS+QfWj4fHQHarGOIUQQuYX0csczWusfl3gIUdHe9G0 MfmhYwJ/pyvOYerwoV70BhYPYVJs2K05Ax3GUAuSmT11jM9gjgJWbwDFkCcHvaLdHqE4 rzxg== 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; bh=N0yUvQwf56uXT+DeZe9wCbbuUfkwdrAhTZdP0qYYdjo=; b=fHHLs5/DNFTuZOHzCPzfTsFBHP1eW33I32Fq5efiC8X56OoFrheIIuxvBiNcrpfO/G EQ4dR28EatJYUKUWjIuR+u5cZVsSqR09ojQRxfH4Ye5tdFPdue1nVbeOVNQVw1dgfjiP axoHhCPSLR/J/Obu/7HdKi4wUQcymUIaQ7VxbT4Zlo4QIDSyKLGhcHgkUCX3v/3Gf6Yv 6Z2zNo1xnotzIX6Vbp3TsmqLnAB5nFmGfF+jw0qxw5+mbN4xbgmv0Lq96eZ2adHstlc2 oEgJcPTVgb1e8vQeDV/Ygs2LWFEm8MMSurAKQvRNgRS2fYlya5egvO+z16CuWJcusbmz ikRw== X-Gm-Message-State: AOAM5314v7G+E6zFBpKLWCq/132qJGeq+FpZKoxOPDDnsXVpQpqeJAPg CrLu2suWxdbVd8iUvJdDd781G9o+3Kw+i4EhYFmIug== X-Received: by 2002:a05:6830:1591:: with SMTP id i17mr517649otr.233.1623834609650; Wed, 16 Jun 2021 02:10:09 -0700 (PDT) MIME-Version: 1.0 References: <20210616080244.51236-1-dja@axtens.net> <20210616080244.51236-2-dja@axtens.net> In-Reply-To: <20210616080244.51236-2-dja@axtens.net> From: Marco Elver Date: Wed, 16 Jun 2021 11:09:57 +0200 Message-ID: Subject: Re: [PATCH v13 1/3] kasan: allow an architecture to disable inline instrumentation To: Daniel Axtens Cc: LKML , Linux Memory Management List , kasan-dev , Andrew Morton , Andrey Konovalov , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , aneesh.kumar@linux.ibm.com, Balbir Singh Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 16 Jun 2021 at 10:02, Daniel Axtens wrote: > > 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. > > * on ppc64 atm, the shadow lives in virtual memory and isn't accessible in > real mode. However, before we turn on virtual memory, we parse the device > tree to determine which platform and MMU we're running under. That calls > generic DT code, which is instrumented. Inline instrumentation in DT would > unconditionally attempt to touch the shadow region, which we won't have > set up yet, and would crash. We can make outline mode wait for the arch to > be ready, but we can't change what the compiler inserts for inline mode. > > Signed-off-by: Daniel Axtens Reviewed-by: Marco Elver Thank you. > --- > lib/Kconfig.kasan | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan > index cffc2ebbf185..cb5e02d09e11 100644 > --- a/lib/Kconfig.kasan > +++ b/lib/Kconfig.kasan > @@ -12,6 +12,15 @@ config HAVE_ARCH_KASAN_HW_TAGS > config HAVE_ARCH_KASAN_VMALLOC > bool > > +config ARCH_DISABLE_KASAN_INLINE > + bool > + help > + Sometimes an architecture might not be able to support inline > + instrumentation but might be able to support outline instrumentation. > + This option allows an architecture to prevent inline and stack > + instrumentation from being enabled. > + > + > config CC_HAS_KASAN_GENERIC > def_bool $(cc-option, -fsanitize=kernel-address) > > @@ -130,6 +139,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 > @@ -141,6 +151,7 @@ endchoice > config KASAN_STACK > bool "Enable stack instrumentation (unsafe)" if CC_IS_CLANG && !COMPILE_TEST > depends on KASAN_GENERIC || KASAN_SW_TAGS > + depends on !ARCH_DISABLE_KASAN_INLINE > default y if CC_IS_GCC > help > The LLVM stack address sanitizer has a know problem that > @@ -154,6 +165,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" > -- > 2.30.2 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20210616080244.51236-2-dja%40axtens.net.