From patchwork Fri Dec 20 18:49:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11306159 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 3BCA9139A for ; Fri, 20 Dec 2019 18:50:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 061BA206DA for ; Fri, 20 Dec 2019 18:50:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Rttsh5iU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 061BA206DA 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 3DC848E01B0; Fri, 20 Dec 2019 13:50:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3B4B18E019D; Fri, 20 Dec 2019 13:50:44 -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 2065D8E01B0; Fri, 20 Dec 2019 13:50:44 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id 0652B8E019D for ; Fri, 20 Dec 2019 13:50:44 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id BD8B64DCB for ; Fri, 20 Dec 2019 18:50:43 +0000 (UTC) X-FDA: 76286411166.24.kite70_7aba1d20cc509 X-Spam-Summary: 2,0,0,757cb8d45e7d6699,d41d8cd98f00b204,3ahj9xqykcb09eb67k9hh9e7.5hfebgnq-ffdo35d.hk9@flex--glider.bounces.google.com,:mark.rutland@arm.com:vegard.nossum@oracle.com:dvyukov@google.com:elver@google.com:andreyknvl@google.com::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.c om:tytso X-HE-Tag: kite70_7aba1d20cc509 X-Filterd-Recvd-Size: 5354 Received: from mail-vk1-f201.google.com (mail-vk1-f201.google.com [209.85.221.201]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Dec 2019 18:50:43 +0000 (UTC) Received: by mail-vk1-f201.google.com with SMTP id c127so3801545vkh.18 for ; Fri, 20 Dec 2019 10:50:43 -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=t3LuU95uaD990YAMlwsnbs2ht0cPi0LD4EWutad09LQ=; b=Rttsh5iUmJ963QAJ0nHp/h6uORM7oUc0BvOI3Py11ntJNoL7VvC7nn6B5/x840PxIo 27p5dg5vpb1UGRIxax7xbARBbLTpPc/v4dQlvRvsvV97NP/AxwMAVKNRWs2eXbWS66xX EpGvZO3N6zc5Bm1U6T1jp6CJCgtCP87husm9v/jgkEIJfOhNpc9QjejC0f0vCp+mfjOS CtFk0VIFmpzjlA5jbCM7kDp9BVOdDu3tK/w5Z1hUiuW0JRxUa4I9UtiUqgM3PATf0JoG 2u3Zjzolx1w3WCdJT1SZTL4SKBvmzESCPXmOYlobUGqviOIoa49xvREg4sbt6WPWjaJM e0JA== 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=t3LuU95uaD990YAMlwsnbs2ht0cPi0LD4EWutad09LQ=; b=RKrantGzmTL0gvQn/80YUneXsCN9v/Lvlifhq74xCUGNYtnKFMHirwfR1T4xrFxSKU JXXkY3+EV2BEKidZBQvs/0Ymv6S0UUiI4x1/rwOKOjcAzvVonFJCo4c0t+xPARMTIeBa UF4O78OxmR0r2ZqLtf0rqgFpLi6b+HVL3fQxcae7VWa4IW31/APUysv6la+9v7Qj0v5w C//dnrZ+uedRIgcFtXAlAxkzyVJG9u15If1E6lYPyWK88LyADS0er9sCF0LxiOdYJSt/ 9JfXP51706jTITISzTjW4Y+38Y28IGg6n1cAZpfsvUZDyYu8JhxDWxAuNFUFNjSz1Yoj VZrA== X-Gm-Message-State: APjAAAU01cBzEMNuxDWkFLp9G+ZAEjVZjh+k5zA43Ij0zWgYFD5llDLw BbdIZ8kb71IjHZCNIFKG9EDLWu6lnIQ= X-Google-Smtp-Source: APXvYqzJGHkLpp4tlXjg6G1q9tdmpPDWIswlRmJd5kJ5a4ADBO4uJySFOj55tXPTvVg5/t0KsdOs4z6AYlE= X-Received: by 2002:a05:6122:1065:: with SMTP id k5mr11070466vko.14.1576867842537; Fri, 20 Dec 2019 10:50:42 -0800 (PST) Date: Fri, 20 Dec 2019 19:49:26 +0100 In-Reply-To: <20191220184955.223741-1-glider@google.com> Message-Id: <20191220184955.223741-14-glider@google.com> Mime-Version: 1.0 References: <20191220184955.223741-1-glider@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH RFC v4 13/42] 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 --- 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 5e88e7e33abe..de7942423836 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -255,6 +255,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s */ #include #include +#include #define __READ_ONCE(x, check) \ ({ \ @@ -270,9 +271,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)