From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.3 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL 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 9F61AC432C0 for ; Thu, 28 Nov 2019 13:13:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 436E121774 for ; Thu, 28 Nov 2019 13:13:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sNHMSmy0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 436E121774 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A39236B0529; Thu, 28 Nov 2019 08:13:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E9E56B052A; Thu, 28 Nov 2019 08:13:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FF9D6B052B; Thu, 28 Nov 2019 08:13:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 782776B0529 for ; Thu, 28 Nov 2019 08:13:13 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 080BE181AEF23 for ; Thu, 28 Nov 2019 13:13:13 +0000 (UTC) X-FDA: 76205727066.11.lead15_73567d7387141 X-HE-Tag: lead15_73567d7387141 X-Filterd-Recvd-Size: 6230 Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Nov 2019 13:13:12 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id l136so7662744oig.1 for ; Thu, 28 Nov 2019 05:13:12 -0800 (PST) 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=/rllkm+RoIWcgxAcEGF3oTa/MWi2gHPXdrrUldnqWXQ=; b=sNHMSmy0fOrx2uf/Efqq5i8+vui2R2w9gzP0Yly+f3d2rnECuTfNW6bJw9TSivfhld jFXLa0CCgzTczBMwpV/3WeC7JHMwxjvgTiDPeTHf1lys/UkrjLaJAKYt9YRRN4PtkX7n XFqv8nR9viT4xa5u37S7uIK/GaPGhV+PhbX7UolReWIqSnLVqMgncDZwzO9azAT13bji 96/muqgJUO33H83v/7NmkTEM0jm9z75RkIQPWEFG84G0ZTNTmkvwpMBlb4oT5Y3zHxPr /D1KY7kPSnCyjwVnNQA6cweuwDWF27vJtJlvuwfgPjY1F0oVpxaP3o21zz6pH+mGty2g 35qg== 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=/rllkm+RoIWcgxAcEGF3oTa/MWi2gHPXdrrUldnqWXQ=; b=NHTmacolvHjCmpliy2uDqnlLM33HHYQSzOzNMQGPiJz2WF/i03y/RzMX1OWlXQbHbk UedO2cNH9HJv7hgdfOLQ2Oy4iqGvDHqtIzMyCFfa1BsrAtQucA6bLuWcZM5iAmJNcPhp jsFMiM7IeA8KFhqiIgjbm6Y60qMn/g362wEtAyEReykXnJMQqJ5S/mKWfhFTq8IukYJw Li8gkftF+zX4/jvkz6prsMIFDZ5TCHH7f1SCDrfhU1j96DisqJX5tuAFyBb+t/Oevmwa NGAtf0Kc1EiBuOOZuu4tXpGFjEyAr9wyyMK4cSM1DcFsd+IvMEb29fb4Gz6BKQq0KHek oa6A== X-Gm-Message-State: APjAAAU3pNw06pBJnloW2q5ZDHDWfblTf6DKIUu7KTmrSAiEJ+j0ltJZ 5Ms6QUXzXB9p3OrKMWBupFa+SHPRQET7D87hPAcjOw== X-Google-Smtp-Source: APXvYqxcbLEwZsk13HElW9S2lQWqnJJZClpMxDDIPPvW0YOJv9rzPv0sI6vCgs8QaukRjYqoiW0lgq5w5mRZe8M8ACE= X-Received: by 2002:aca:d80b:: with SMTP id p11mr8684154oig.83.1574946791151; Thu, 28 Nov 2019 05:13:11 -0800 (PST) MIME-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> <20191122112621.204798-8-glider@google.com> In-Reply-To: <20191122112621.204798-8-glider@google.com> From: Marco Elver Date: Thu, 28 Nov 2019 14:13:00 +0100 Message-ID: Subject: Re: [PATCH RFC v3 07/36] kmsan: introduce __no_sanitize_memory and __SANITIZE_MEMORY__ To: Alexander Potapenko Cc: Vegard Nossum , Dmitry Vyukov , Linux Memory Management List , Al Viro , adilger.kernel@dilger.ca, Andrew Morton , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , hch@infradead.org, hch@lst.de, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, Eric Biggers , Eric Dumazet , ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, jasowang@redhat.com, axboe@kernel.dk, m.szyprowski@samsung.com, Mark Rutland , martin.petersen@oracle.com, schwidefsky@de.ibm.com, Matthew Wilcox , mst@redhat.com, Michal Simek , pmladek@suse.com, Qian Cai , Randy Dunlap , robin.murphy@arm.com, Sergey Senozhatsky , Steven Rostedt , tiwai@suse.com, tytso@mit.edu, Thomas Gleixner , gor@linux.ibm.com, wsa@the-dreams.de Content-Type: text/plain; charset="UTF-8" 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: Archived-At: List-Archive: List-Post: On Fri, 22 Nov 2019 at 12:26, wrote: > > __no_sanitize_memory is a function attribute that makes KMSAN > ignore the uninitialized values coming from the function's > inputs, and initialize the function's outputs. > > Functions marked with this attribute can't be inlined into functions > not marked with it, and vice versa. > > __SANITIZE_MEMORY__ is a macro that's defined iff the file is > instrumented with KMSAN. This is not the same as CONFIG_KMSAN, which is > defined for every file. > > Signed-off-by: Alexander Potapenko > To: Alexander Potapenko > Cc: Vegard Nossum > Cc: Dmitry Vyukov > Cc: linux-mm@kvack.org Acked-by: Marco Elver > --- > > Change-Id: I1f1672652c8392f15f7ca8ac26cd4e71f9cc1e4b > --- > include/linux/compiler-clang.h | 8 ++++++++ > include/linux/compiler-gcc.h | 5 +++++ > 2 files changed, 13 insertions(+) > > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h > index 333a6695a918..edba13a069a6 100644 > --- a/include/linux/compiler-clang.h > +++ b/include/linux/compiler-clang.h > @@ -24,6 +24,14 @@ > #define __no_sanitize_address > #endif > > +/* KMSAN is a Clang-only tool, thus putting the defines here */ The comment is a bit confusing, because compiler-gcc.h also has a define. I assume that if GCC ever supports KMSAN, the definition here wouldn't change? > +#if __has_feature(memory_sanitizer) > +# define __SANITIZE_MEMORY__ > +# define __no_sanitize_memory __attribute__((no_sanitize("kernel-memory"))) > +#else > +# define __no_sanitize_memory > +#endif > + > /* > * Not all versions of clang implement the the type-generic versions > * of the builtin overflow checkers. Fortunately, clang implements > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h > index d7ee4c6bad48..e5ebc788dde4 100644 > --- a/include/linux/compiler-gcc.h > +++ b/include/linux/compiler-gcc.h > @@ -145,6 +145,11 @@ > #define __no_sanitize_address > #endif > > +/* > + * GCC doesn't support KMSAN. > + */ > +#define __no_sanitize_memory > + > #if GCC_VERSION >= 50100 > #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 > #endif > -- > 2.24.0.432.g9d3f5f5b63-goog >