From patchwork Tue Dec 14 16:20:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12676379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D29B6C433EF for ; Tue, 14 Dec 2021 16:34:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C3396B0099; Tue, 14 Dec 2021 11:23:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3733D6B009A; Tue, 14 Dec 2021 11:23:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 214646B009B; Tue, 14 Dec 2021 11:23:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id 0CB0D6B0099 for ; Tue, 14 Dec 2021 11:23:05 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C6BAB180DD593 for ; Tue, 14 Dec 2021 16:22:54 +0000 (UTC) X-FDA: 78916918668.11.3A7B079 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf03.hostedemail.com (Postfix) with ESMTP id 646362000D for ; Tue, 14 Dec 2021 16:22:54 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id y125-20020a25dc83000000b005c2326bf744so36916930ybe.21 for ; Tue, 14 Dec 2021 08:22:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xrXvVkI6r4Vmn+7KKReTw1DvnU9RNEXMh/9+RUR+L9Y=; b=Sf/NXwY0Sja8M/PzUs1W+sY8VyA/Djybj8zo8xITaOYjOmAxm2jPwF1T6L9fwmnneP IPag0hEreQOp5npdzJEAderB2zK/8azetsweUYqaC2pZWtDo8K6FwZJl7uwJ1gYr9tQS QCLJNL5Nzb8WvzGLA1v5Risf+XOONz0kc7aMiFz7INAy72z3Yz+SfoeKd39ntJ1lnynL VveKA/P4j1Cqgoi/v1qwzegffbhOteL0iqZW34xOZYPFV7AGuzwyOTrZaf5WBnl/IsMX vHItLWbetXCgCXXM6PkvNRzL3C1XS63MTy0t4Kh7hY7rJ9tzmp71ZeQq4IwZAVp0zBrH F8UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xrXvVkI6r4Vmn+7KKReTw1DvnU9RNEXMh/9+RUR+L9Y=; b=XnEqdCcLfseEEgxA7SGVafrUUbUrK1lsgmy4koyKkOQKaQzN7TNboFl/rA2yAVjxX1 wLMveNQ40TKoy8o7IuPa3XO9g+j+EOevNdWIjeoSPU7WLcPZ7O8MDN33/6J7wPFX0YCm KAC98EMKc+fijnBmYKsyZsOb9pe5C4jzh7Wx/ff3PRYCSjQyxNjL3/fZIPhSiSgbdaRu nWImSzfQpD6mGI13kCzyrkwSBspRYo8Vj4vVSpvHqiGxDajPhCXqsy/e6ZvlfncmCTvj ZmqD6jdzwnOj9f8H7QHQrYx2XcrVgm4BJFEi0xXan8ifCflN10jtyXnOsEICDFnfwFRZ HPhg== X-Gm-Message-State: AOAM533VXWrUULEr/MJRtu/tRpgjcAtwnTq5/fNwZ0go7VnLABheJwxT WGmBzQ3s6lMElIuTXrzylvzNoRcOTPg= X-Google-Smtp-Source: ABdhPJxaoBdLntARzlcI6TdYmeYb+XZlVtgE1jknLgRjufiSnIl0WbIGjxFSocuh1vUQ39TfRs9x7ezE8HA= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:357e:2b9d:5b13:a652]) (user=glider job=sendgmr) by 2002:a25:acc3:: with SMTP id x3mr6310ybd.332.1639498973606; Tue, 14 Dec 2021 08:22:53 -0800 (PST) Date: Tue, 14 Dec 2021 17:20:29 +0100 In-Reply-To: <20211214162050.660953-1-glider@google.com> Message-Id: <20211214162050.660953-23-glider@google.com> Mime-Version: 1.0 References: <20211214162050.660953-1-glider@google.com> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog Subject: [PATCH 22/43] kmsan: initialize the output of READ_ONCE_NOCHECK() From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="Sf/NXwY0"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 33cS4YQYKCF4CHE9ANCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--glider.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=33cS4YQYKCF4CHE9ANCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--glider.bounces.google.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 646362000D X-Stat-Signature: dimi5ozrt5yeti6ib1mdnsmbx1q5q5ip X-HE-Tag: 1639498974-248480 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 --- Link: https://linux-review.googlesource.com/id/I07499eb3e8e59c0ad2fd486cedc932d958b37afd --- include/asm-generic/rwonce.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/rwonce.h b/include/asm-generic/rwonce.h index 8d0a6280e9824..7cf993af8e1ea 100644 --- a/include/asm-generic/rwonce.h +++ b/include/asm-generic/rwonce.h @@ -25,6 +25,7 @@ #include #include #include +#include /* * Yes, this permits 64-bit accesses on 32-bit architectures. These will @@ -69,14 +70,14 @@ unsigned long __read_once_word_nocheck(const void *addr) /* * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a - * word from memory atomically but without telling KASAN/KCSAN. This is + * word from memory atomically but without telling KASAN/KCSAN/KMSAN. This is * usually used by unwinding code when walking the stack of a running process. */ #define READ_ONCE_NOCHECK(x) \ ({ \ compiletime_assert(sizeof(x) == sizeof(unsigned long), \ "Unsupported access size for READ_ONCE_NOCHECK()."); \ - (typeof(x))__read_once_word_nocheck(&(x)); \ + kmsan_init((typeof(x))__read_once_word_nocheck(&(x))); \ }) static __no_kasan_or_inline