From patchwork Wed Mar 25 16:12:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11458247 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 43349913 for ; Wed, 25 Mar 2020 16:13:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 109AA2073E for ; Wed, 25 Mar 2020 16:13:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YFP5gPzS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 109AA2073E 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 0A23B6B0070; Wed, 25 Mar 2020 12:13:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 028E96B0071; Wed, 25 Mar 2020 12:13:29 -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 EA9866B0072; Wed, 25 Mar 2020 12:13:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id D19926B0070 for ; Wed, 25 Mar 2020 12:13:29 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A51E6824805A for ; Wed, 25 Mar 2020 16:13:29 +0000 (UTC) X-FDA: 76634379738.26.swim31_75c5a9accdb3e X-Spam-Summary: 2,0,0,6e08e14771e1c862,d41d8cd98f00b204,3j4n7xgykcby274z0d2aa270.ya8749gj-886hwy6.ad2@flex--glider.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:968:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2901:3138:3139:3140:3141:3142:3152:3352:3866:3867:3871:3872:3873:3874:4250:4321:5007:6261:6653:6742:6743:7875:7903:8603:9969:10004:10400:11026:11473:11658:11914:12043:12048:12297:12438:12555:12895:12986:13069:13311:13357:13846:14181:14394:14659:14721:21080:21365:21444:21451:21627:21990:30054:30064:30070,0,RBL:209.85.221.74:@flex--glider.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: swim31_75c5a9accdb3e X-Filterd-Recvd-Size: 5301 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 16:13:29 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id e10so1383064wrm.2 for ; Wed, 25 Mar 2020 09:13:28 -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=+xpmqEKFkfsQ8mvB0TOG9SWpDteUMVfpNR7Bt4fBgZY=; b=YFP5gPzSxttH7PjQ7iuPi0g2Yq1PlDzpOniH0JdIj86Y/etBjnpPA2zYbrd0nCQT1L 8TWIBQvUjjy186431RGRX+TiXc+9J7KzuRtthXyKmq7HhcWj7XLzjNO0c2tdMRPH3VMl rnXg+YFF18DReFKVmDm+ZYDc6zF2cJCO88el9ycdFTdyXKoKdLPx7ZuM/WEUwPFXBcB7 C4RmGJUc15muSnKTXot4sLOmWL/wRXbfZGa589MX1XtKk9kJfOBAKb8S/d/G4OGWCt5+ yeFYKfchasSG3llovngjeLouKMyCf6wfLj5u1tbX3XOBrLdWI3Y44mEGwuqp9TRiIf7+ I1uQ== 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=+xpmqEKFkfsQ8mvB0TOG9SWpDteUMVfpNR7Bt4fBgZY=; b=h+f1eavg1rz2j/x7N2HjNc50Jj+bZSVxb3mh8+ArWwodKw68ht3Ve4EeG2puA4iEeQ XEBY/0nqiy2rEfi/uv4WdTqfgGf0/uVEcY5nl9mfXyqLGakBcQ3eDEwIqF9heRP1uDnq nNbyPkiYs+pTOzBIkkZANDdzol9F0qLxS5GKVGe3XCSvuV5unmd3Bql9ORH7MGbzcTtF m5tWTnYn9lJDHTa4LE+2q3aMGOAqmjXcmmMuzYLRRjr+fmwuwew+5v673sES0e7LL3u8 62zikTUnhJwCpadRcROb5njfFvGys5SEDYwdaWTFIol9OEvIrxyc3Q1OVxUoctUN2wYl TvZw== X-Gm-Message-State: ANhLgQ2IA3KtSE284Y3N8GV5FM7Nq3fSjQJJLIVsaA1T7CpK9kTEweYk VToyG8IExsPwDGZxGoG1JwoerhzGPT0= X-Google-Smtp-Source: ADFU+vs3i6YkiixUU6bPaz96DbgaVU2Df6UadPQZZ1DhcaC7ck7GDFUsHt9vG398C7jRiirXIpmRRp9p0Do= X-Received: by 2002:adf:fb0a:: with SMTP id c10mr4212389wrr.272.1585152807722; Wed, 25 Mar 2020 09:13:27 -0700 (PDT) Date: Wed, 25 Mar 2020 17:12:21 +0100 In-Reply-To: <20200325161249.55095-1-glider@google.com> Message-Id: <20200325161249.55095-11-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 10/38] kmsan: define READ_ONCE_NOCHECK() From: glider@google.com To: Mark Rutland , 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, 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: READ_ONCE_NOCHECK() is already used by KASAN to ignore memory accesses from e.g. stack unwinders. Define READ_ONCE_NOCHECK() for KMSAN so that it returns initialized values. This helps defeat false positives from leftover stack contents. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Mark Rutland Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Marco Elver Cc: Andrey Konovalov Cc: linux-mm@kvack.org Reviewed-by: Andrey Konovalov --- v3: - removed unnecessary #ifdef as requested by Mark Rutland v4: - added an #include as requested by Marco Elver Change-Id: Ib38369ba038ab3b581d8e45b81036c3304fb79cb --- include/linux/compiler.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index f504edebd5d71..c6c67729729e3 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -279,6 +279,7 @@ void __write_once_size(volatile void *p, void *res, int size) */ #include #include +#include #define __READ_ONCE(x, check) \ ({ \ @@ -294,9 +295,9 @@ void __write_once_size(volatile void *p, void *res, int size) /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need - * to hide memory access from KASAN. + * to hide memory access from KASAN or KMSAN. */ -#define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0) +#define READ_ONCE_NOCHECK(x) KMSAN_INIT_VALUE(__READ_ONCE(x, 0)) static __no_kasan_or_inline unsigned long read_word_at_a_time(const void *addr)