Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp455197imn; Wed, 3 Aug 2022 10:56:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR6jMDJSuAn+MDt8tpGjYnYhqv5WAjXcBZhaQk6ApuZt7Dr/4I2Y/yClbDdjm/oxciJEL1gC X-Received: by 2002:aa7:810a:0:b0:52c:e906:e355 with SMTP id b10-20020aa7810a000000b0052ce906e355mr23830461pfi.16.1659549404751; Wed, 03 Aug 2022 10:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659549404; cv=none; d=google.com; s=arc-20160816; b=lutErZXSllz0AT6Qg1DacWVUxmCMAWJgl0w066jtmwGqSpSMDtxHx373AoSy8es8pj QEvwsVF1/Hye3x/vJn8Kr4I5La3H00DTGPLmgG7aJFzwo9bCKMJqfV41X/l0xVsYmpSQ mU7FppKZtZRSgi5ZVqxnA1fP7Xe29erqGxkKENbEFu1hsIsaHJavqfRsdhMqzzC4/USe EKK2PHv7+z+ZPe/LOomB+COcgpJA+WHev+vpZ9WSa5ZMHtO7EY7ikygZ8m0DYTL4ArlU isTdRgyoIH5wcxUDrhlIRe6/IRdfjt/7HG5LyW1wWZM7k/uYRfkqB0Uk7g9rs225XLc2 wyTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kVM/3uyhal6qaeACSB8divgbMh2p6Q9rmvW6JHSngAY=; b=n7lM2vVYb/Lf9kljL594ZgU+3OEdMgGSJV2FwuNqfjCsDuHnkYAqO43ofGTcZZ7Nkl yX97MMXzoF2Lt1HoBvb6DImeS1lnjBxL4foLmjuShTzUcVkrT14S/r3/Im6vYdyjosBA +SofNNqnGqiDJiZ2B1sx1jgRkvUaJbS2xiUuwRqe3KBprdZGw/w6OCX6b/SB73ie7lQf V8k9b9jx8rVWSD/IVVNdix6ZeZERwMWUaNji0j6PAnQIZj9zTvXu74Wsx2clKbBqx/WX PQhpAW+ALLuS/UwmKDA07Ib36sjG22LmBexLQXRH6Hb0Lt02jQmndy4+m5HTLbdf1fJF DxwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ECfvFXHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t1-20020a170902e84100b0016caa701d5bsi2964523plg.487.2022.08.03.10.56.22; Wed, 03 Aug 2022 10:56:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ECfvFXHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237678AbiHCRqf (ORCPT + 99 others); Wed, 3 Aug 2022 13:46:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236263AbiHCRqc (ORCPT ); Wed, 3 Aug 2022 13:46:32 -0400 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C7A65D8 for ; Wed, 3 Aug 2022 10:46:31 -0700 (PDT) Received: by mail-yb1-xb32.google.com with SMTP id y127so29466825yby.8 for ; Wed, 03 Aug 2022 10:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=kVM/3uyhal6qaeACSB8divgbMh2p6Q9rmvW6JHSngAY=; b=ECfvFXHNoWfUFidh9Eguf3fa6Bq7Cr+ZBwO3g+v5R26inMZJ+PprF07thBS/iAUDOv KoHKoNk3p1CD7oA+XYhLMGnLx1UM64+m/oZTxYGBm1ui3mSKNDJXkbXHNHZNWwYMPM25 no6Xk74r5H+HlvFMAu7VhmjjTkqjGEorYK/E1NNrmLycAfwGb5T8CDwMPzi10MsKfcDt CXm/wIg4qaq6nACUNqANSQ4Cc+ljRsHsBpUSMvB1FXN+xTv+VW9BrlbK48uMvV02e1hS ZJi1UEudP/SKw5sBgAoFnA38ohuro2kf26ubLWtfiJ2mUlp6waOtZ04l1TvBymZ8hC+a h9yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=kVM/3uyhal6qaeACSB8divgbMh2p6Q9rmvW6JHSngAY=; b=b9CHpi0OPEug2fIZVVmeH9/AGnebIUQaHbwpFCMd41vE/J6qVZePcQj2PUj5ioIh2Q W+9V+eQVg0gLyAImSUGq/oypNv5Y/EQVOzQJzxMHEtLIpTuXQd79n5zBA7X0fqYTKS9i HwIxMmyF1Avg+SorMs1jbgWB5ryEfzd2X2TbVb3bKoq68eAYTBRNZqz5KW9PZbU6FNnF 2Uvl250Buw7chqsIZGgJkrJ9bkOICWEGSFfkxd6pcE+PWwP1YP5yx5uundrdSL3Tr1r0 Xx5vTX2FqcwD0V7DhRAd6cbxfKynqEay7mwEIG4uxmemaDK3Hdo1QMY7iX25VRS7Ml/t Vinw== X-Gm-Message-State: ACgBeo1gchszXbsZHevZeum3PoWnoGIUW1CfgyvKmylMpJqlYDoQrCiV 3fTbmb9q5vRpClWNXrYQZhZ/4M02gNyGTH2FhUEKzQ== X-Received: by 2002:a25:b9d1:0:b0:671:49f9:4e01 with SMTP id y17-20020a25b9d1000000b0067149f94e01mr22124946ybj.398.1659548790205; Wed, 03 Aug 2022 10:46:30 -0700 (PDT) MIME-Version: 1.0 References: <20220701142310.2188015-1-glider@google.com> <20220701142310.2188015-12-glider@google.com> In-Reply-To: From: Alexander Potapenko Date: Wed, 3 Aug 2022 19:45:53 +0200 Message-ID: Subject: Re: [PATCH v4 11/45] kmsan: add KMSAN runtime core To: Marco Elver 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 , 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 , Linux Memory Management List , Linux-Arch , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 13, 2022 at 12:04 PM Marco Elver wrote: > > On Fri, Jul 01, 2022 at 04:22PM +0200, 'Alexander Potapenko' via kasan-de= v wrote: > [...] > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > > index 2e24db4bff192..59819e6fa5865 100644 > > --- a/lib/Kconfig.debug > > +++ b/lib/Kconfig.debug > > @@ -963,6 +963,7 @@ config DEBUG_STACKOVERFLOW > > > > source "lib/Kconfig.kasan" > > source "lib/Kconfig.kfence" > > +source "lib/Kconfig.kmsan" > > > > endmenu # "Memory Debugging" > > > > diff --git a/lib/Kconfig.kmsan b/lib/Kconfig.kmsan > > new file mode 100644 > > index 0000000000000..8f768d4034e3c > > --- /dev/null > > +++ b/lib/Kconfig.kmsan > > @@ -0,0 +1,50 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > +config HAVE_ARCH_KMSAN > > + bool > > + > > +config HAVE_KMSAN_COMPILER > > + # Clang versions <14.0.0 also support -fsanitize=3Dkernel-memory,= but not > > + # all the features necessary to build the kernel with KMSAN. > > + depends on CC_IS_CLANG && CLANG_VERSION >=3D 140000 > > + def_bool $(cc-option,-fsanitize=3Dkernel-memory -mllvm -msan-disa= ble-checks=3D1) > > + > > +config HAVE_KMSAN_PARAM_RETVAL > > + # Separate check for -fsanitize-memory-param-retval support. > > This comment doesn't add much value, maybe instead say that "Supported > only by Clang >=3D 15." Fixed. > > + depends on CC_IS_CLANG && CLANG_VERSION >=3D 140000 > > Why not just "depends on HAVE_KMSAN_COMPILER"? (All > fsanitize-memory-param-retval supporting compilers must also be KMSAN > compilers.) Good idea, will do. > > + def_bool $(cc-option,-fsanitize=3Dkernel-memory -fsanitize-memory= -param-retval) > > + > > + > > HAVE_KMSAN_PARAM_RETVAL should be moved under "if KMSAN" so that this > isn't unnecessarily evaluated in every kernel build (saving 1 shelling > out to clang in most builds). Ack. > > +config KMSAN > > + bool "KMSAN: detector of uninitialized values use" > > + depends on HAVE_ARCH_KMSAN && HAVE_KMSAN_COMPILER > > + depends on SLUB && DEBUG_KERNEL && !KASAN && !KCSAN > > + select STACKDEPOT > > + select STACKDEPOT_ALWAYS_INIT > > + help > > + KernelMemorySanitizer (KMSAN) is a dynamic detector of uses of > > + uninitialized values in the kernel. It is based on compiler > > + instrumentation provided by Clang and thus requires Clang to bu= ild. > > + > > + An important note is that KMSAN is not intended for production = use, > > + because it drastically increases kernel memory footprint and sl= ows > > + the whole system down. > > + > > + See for more details. > > + > > +if KMSAN > > + > > +config KMSAN_CHECK_PARAM_RETVAL > > + bool "Check for uninitialized values passed to and returned from = functions" > > + default HAVE_KMSAN_PARAM_RETVAL > > This can be enabled even if !HAVE_KMSAN_PARAM_RETVAL. Should this be: > > default y > depends on HAVE_KMSAN_PARAM_RETVAL > > instead? > Ack --=20 Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg