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.4 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,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 337EAC432C0 for ; Fri, 29 Nov 2019 16:09:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB4F32176D for ; Fri, 29 Nov 2019 16:09:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mgjkP+5R" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB4F32176D 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 8B2D36B05B2; Fri, 29 Nov 2019 11:09:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 888AB6B05B3; Fri, 29 Nov 2019 11:09:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C51A6B05B4; Fri, 29 Nov 2019 11:09:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id 67F0C6B05B2 for ; Fri, 29 Nov 2019 11:09:48 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 09E9787E5 for ; Fri, 29 Nov 2019 16:09:47 +0000 (UTC) X-FDA: 76209800772.01.order79_72760b191925a X-HE-Tag: order79_72760b191925a X-Filterd-Recvd-Size: 6369 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 Nov 2019 16:09:46 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id y21so13432894pjn.9 for ; Fri, 29 Nov 2019 08:09:46 -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=R0ZCuHAUPaaL1BdyKJjtYEEXjAt9aGJ+EeLic/3B+KI=; b=mgjkP+5RasxsOL8q5b1bTx7BSLc3gAcr62TFbKxfda+v6WSFoaQC3iw8Dlq6g1mXin 2ewynafGupJSryZH+y0Ht8t0KVX03QrVeePGdxpLM44CeuHnT6hvTIxZEbt7fX2FJ5at RlIh4bgENWWFCqiiJi6EYhI6aLMQ4mNGvz48lMx3Lmlc3cufShtjWkbFLoWjY9blmOa4 P1vs/6zFGZ0gFghcODw/DrvIsDeeggwQZUAhFJw2Y9YEARn0Kc2qTVLd8fatJ5QnR7w3 7D65ZV2AEowupuJyyce0ygWkIe/5VIvq5qyd2mOJVWjF02KEzolJQ+8x/v6hbrmFn4wr yrjQ== 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=R0ZCuHAUPaaL1BdyKJjtYEEXjAt9aGJ+EeLic/3B+KI=; b=pPwufdj15ezyWM2Ib3W7vLph1v2pUt5Jz8zAQ9YI7I/npDxDQ0rFoDNuBhtEVMXAFE ZUf9sHNlCiVQxjsfdDMTROvLtLadesOAHmwimXKfWrgNU6hfPfpDUbFpyTqwgAUTW/mV 5qUEcCkcD2PQ86B5a/C9exWBb2gjUGDHfP82UtaLawP9tzPUUbgbAtARo/7BDJOxh9+L CRc45wZTYSHGbZLGSBDk7URWWTrdl9xVUwhMHomkVGJZPN5BWXtEQejEGvqw4XAjPleh 8SsXxnPRRXXkVsKCUmu1oXxLto0Xq0r/v0YucPZhak2prSQEG2TlUyxlZ6FecT2SWYK/ JVCw== X-Gm-Message-State: APjAAAUkuvBiaYTatHIScoT4g+e5OeGN5RcLOePrjG0Veq7g4ajIgJWC XXG00ZdHHp20cWbCIINx4KwniB7ypjO+e9Hqa0hXNw== X-Google-Smtp-Source: APXvYqwrVotChJHOc1gQ4tOSYYux3CSb94XwfGi2pM+xUD/pX5UTVLUl13osxdhlvdIq6Qr+e00lVRx3xY1hhMgtKq4= X-Received: by 2002:a17:90a:a4cb:: with SMTP id l11mr19561325pjw.47.1575043785141; Fri, 29 Nov 2019 08:09:45 -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: Andrey Konovalov Date: Fri, 29 Nov 2019 17:09:34 +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 , Alexander Viro , Andreas Dilger , Andrew Morton , Andrey Ryabinin , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Christoph Hellwig , Christoph Hellwig , darrick.wong@oracle.com, "David S. Miller" , Dmitry Torokhov , Eric Biggers , Eric Dumazet , ericvh@gmail.com, Greg Kroah-Hartman , harry.wentland@amd.com, Herbert Xu , iii@linux.ibm.com, mingo@elte.hu, Jason Wang , Jens Axboe , Marek Szyprowski , Marco Elver , Mark Rutland , "Martin K. Petersen" , Martin Schwidefsky , Matthew Wilcox , "Michael S . Tsirkin" , Michal Simek , pmladek@suse.com, Qian Cai , Randy Dunlap , Robin Murphy , sergey.senozhatsky@gmail.com, Steven Rostedt , Takashi Iwai , "Theodore Ts'o" , 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: On Fri, Nov 22, 2019 at 12:26 PM 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 > > --- > > 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 */ I'm not sure if this comment is useful here. > +#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 >