From patchwork Wed Mar 25 16:12:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11458227 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38F1114B4 for ; Wed, 25 Mar 2020 16:13:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F105B2073E for ; Wed, 25 Mar 2020 16:13:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cl/fD0b4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F105B2073E 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 5A9FB6B0010; Wed, 25 Mar 2020 12:13:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 50B9F6B0032; Wed, 25 Mar 2020 12:13:10 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FB3E6B0036; Wed, 25 Mar 2020 12:13:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 281D16B0010 for ; Wed, 25 Mar 2020 12:13:10 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id F2CDE1820A8CE for ; Wed, 25 Mar 2020 16:13:09 +0000 (UTC) X-FDA: 76634378898.11.bee71_72ecaf6030e18 X-Spam-Summary: 2,0,0,3ae336390a428013,d41d8cd98f00b204,3e4n7xgykcaiinkfgtiqqing.eqonkpwz-oomxcem.qti@flex--glider.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3871:3872:3874:4250:4321:5007:6119:6261:6653:6742:6743:7875:7903:9969:10004:10400:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:30054:30064,0,RBL:209.85.221.73:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:27,LUA_SUMMARY:none X-HE-Tag: bee71_72ecaf6030e18 X-Filterd-Recvd-Size: 5657 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 16:13:09 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id e10so1372174wru.6 for ; Wed, 25 Mar 2020 09:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=46UM+ohp2sqrA6UyzD9THFYsIoyE+soPYY/25oM+9yU=; b=cl/fD0b44w3XiqB6DK5pDJ/d8//HKxWqCuyvXxlo8p1SrlDFq1bM26wvjZYnymmGcM B/t7A7DrUj7zihBfmwzoWBwh2N03sN/JxOkXujFIpGaNTUCCcZe9tdFsHneg/RLZQ7wz PZ4l0O982WfeOjosqoID/9LthoxC8z9l4UPMJfy01L/V+5ve0pcQFXH3PJ0ffN1Pld8k VYvmUODtAN3c3qcN2hdCTzwqbfz8jXuPnGQ6YiOwgVDolRLSR44YQ10F6EkgYlNza2hS qZNR0JA9X+WDZ+Mu1jhOMfhJaIIlSEbPpriDq0Hi3M8Gz1G41lSE+iEmitrAxR/1sK/s p/Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=46UM+ohp2sqrA6UyzD9THFYsIoyE+soPYY/25oM+9yU=; b=pTPI1tusV/hfK9CnFB38ix+F6XDz9ZxLx2oFdSg/ADwILc0azme5OA7I9iFr8+xh2m s6bFHuQXmfHCvDf6x+ca97kiS3QEdMKNseJRoXDwc+h+oJGIMlEHidlZykOIoFah59x2 z1Za2tLgdIF5NpfKGQZc5Ox6aqnrRyLI88WJp1/tmKaWKjGtrwJk/9y6bOVvA3VODynd U7j3r0V1X+IVvUaku7/KXJ57iYdiIbQZms7yIgEFSwmR+DPnd0VSmdVWyf2RdeJ9emqA xJV9boeqgmnKsntmmiABkGAR4xFER0hI69ix/3Z4KNIBHyu7K83J0WvajO2soZy80X+r oKgg== X-Gm-Message-State: ANhLgQ1Sm1CY+dwXLJtmuozZySQJ9qhVCbog+M3++BlvZzQ+hRJS3Tcp fSbRtRJHpFLDw7NFtjV6D6+xTQeQwKM= X-Google-Smtp-Source: ADFU+vvpRErbPXjpJ6UrQtWtcmNRi7EcD56jU8mRjuA+xMbnAexnncN3fQhcSN/K5mo69WNVdRk7T/jNQKU= X-Received: by 2002:a5d:40cd:: with SMTP id b13mr2234858wrq.405.1585152787785; Wed, 25 Mar 2020 09:13:07 -0700 (PDT) Date: Wed, 25 Mar 2020 17:12:15 +0100 In-Reply-To: <20200325161249.55095-1-glider@google.com> Message-Id: <20200325161249.55095-5-glider@google.com> Mime-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v5 04/38] kmsan: introduce __no_sanitize_memory and __SANITIZE_MEMORY__ From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , Marco Elver , Andrey Konovalov , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, hch@lst.de, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, ebiggers@google.com, edumazet@google.com, 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@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, mhocko@suse.com, monstr@monstr.eu, pmladek@suse.com, cai@lca.pw, rdunlap@infradead.org, robin.murphy@arm.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de 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: __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: Marco Elver Cc: Andrey Konovalov Cc: linux-mm@kvack.org Acked-by: Marco Elver Reviewed-by: Andrey Konovalov --- v4: - dropped an unnecessary comment as requested by Marco Elver Change-Id: I1f1672652c8392f15f7ca8ac26cd4e71f9cc1e4b --- include/linux/compiler-clang.h | 7 +++++++ include/linux/compiler-gcc.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index 2cb42d8bdedc6..d4f929b4a6705 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -33,6 +33,13 @@ #define __no_sanitize_thread #endif +#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 cf294faec2f87..1121557252f88 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -151,6 +151,11 @@ #define __no_sanitize_thread #endif +/* + * GCC doesn't support KMSAN. + */ +#define __no_sanitize_memory + #if GCC_VERSION >= 50100 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 #endif