From patchwork Fri Nov 22 11:25:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11257883 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 1ACE114DB for ; Fri, 22 Nov 2019 11:27:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DBA9A20672 for ; Fri, 22 Nov 2019 11:27:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hCp69/HJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBA9A20672 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 558176B04D6; Fri, 22 Nov 2019 06:27:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4E20F6B04D8; Fri, 22 Nov 2019 06:27:06 -0500 (EST) 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 383096B04D9; Fri, 22 Nov 2019 06:27:06 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 206B46B04D6 for ; Fri, 22 Nov 2019 06:27:06 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id D670A5DD8 for ; Fri, 22 Nov 2019 11:27:05 +0000 (UTC) X-FDA: 76183686810.15.geese37_3b16118e2910 X-Spam-Summary: 2,0,0,c9919f8a15ab3a88,d41d8cd98f00b204,3b8bxxqykcoyotqlmzowwotm.kwutqvcf-uusdiks.wzo@flex--glider.bounces.google.com,:mark.rutland@arm.com:vegard.nossum@oracle.com:dvyukov@google.com::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org:andreyknvl@google.com: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:elver@google.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.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@li X-HE-Tag: geese37_3b16118e2910 X-Filterd-Recvd-Size: 4897 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Nov 2019 11:27:05 +0000 (UTC) Received: by mail-wm1-f74.google.com with SMTP id i23so2942383wmb.3 for ; Fri, 22 Nov 2019 03:27:05 -0800 (PST) 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=KFTcgBQ32sVGGcQfRo2nqWcFIAnRGV7Y5fUZiWdCP/E=; b=hCp69/HJC02U22QVF/5QRP7AFTkMIm+ts/7baU34LVb/3++Z2hsYGEOmZ/HWqY+OYg aKwfMj70fvwwzNAQKYrVbWX3MOrt2yTQeqnut6WkkkgP/mt6mf1spI2C4SZRgdbP+gSx 3D3McKIdvbCESduC7j2Y1RaaDHwDXJZsPfZOmZeRidX9sVqnbql8FcU/eIwe1ddHhM9s AVbd60DDaK0UhkCiUppP1AIff7DF/RIkyNUDVqZqgb0rBJBTQwwPoKVka83kaOVormrW H9Pt/w4JeC6VCalVmJTuabeAmw+AzvmbNaGezYeX48SWiYZj4Rl0OVg+78HtocEem5AJ u9Uw== 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=KFTcgBQ32sVGGcQfRo2nqWcFIAnRGV7Y5fUZiWdCP/E=; b=W3mvWEx+pPSWmeoSfzLPYcthxz0h8zSfjxjip1AVx06kpKvE/ni5e4EFf6NHFAXPFR +7UCdvJGtlAemdiongm+zpxmWQINn9L9kpXTVRONpApKBgSG//QF0tBF7DCljNYJ4FdT mqoXyWqQRws5KCoeYsJog2swg+s3LgRYVwFaOONGlI2t7pQKJLgC+uCg49ZpUR3kTjRy S70tK5NUhqlocAN2SaL37JGLygBsrabDNMUImgzEjJFSu+JmJizsQ5POVjkp8BXMjvla TyB7rmSsNSqB3zMqWURtH7VxYMorZUc7qzqnnTX+HfZpP/GEF6xUSZNvx6J1VTSdWJjn W03A== X-Gm-Message-State: APjAAAXDBiRQcxBhDsmMrMv24iTWaNU3rWiHSwIn2a8UtrdD2E6BW4Bj e0JCC3uxpEuaTnnrqG37w5dAhQv+eAs= X-Google-Smtp-Source: APXvYqxODPXc36SwLdK/gQGiW3NYNrwuYA91lrVC+q1hSTf6XNaWI1XQv1yFdJ2l6bfg1DDkVNvK9g1LmUE= X-Received: by 2002:a05:6000:104:: with SMTP id o4mr16637812wrx.309.1574422023764; Fri, 22 Nov 2019 03:27:03 -0800 (PST) Date: Fri, 22 Nov 2019 12:25:57 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-13-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 12/36] kmsan: define READ_ONCE_NOCHECK() From: glider@google.com To: Mark Rutland , Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, andreyknvl@google.com, 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, elver@google.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.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: linux-mm@kvack.org --- v3: - removed unnecessary #ifdef as requested by Mark Rutland Change-Id: Ib38369ba038ab3b581d8e45b81036c3304fb79cb --- include/linux/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 5e88e7e33abe..99d40f31a2c3 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -270,9 +270,9 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s /* * 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)