From patchwork Wed Oct 30 14:22:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11219625 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 BE148112B for ; Wed, 30 Oct 2019 14:23:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8A20720656 for ; Wed, 30 Oct 2019 14:23:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EVCxrwaV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A20720656 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 608356B026B; Wed, 30 Oct 2019 10:23:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 568596B026C; Wed, 30 Oct 2019 10:23:16 -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 455C36B026D; Wed, 30 Oct 2019 10:23:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 21E8A6B026B for ; Wed, 30 Oct 2019 10:23:16 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id C0BFD180ACEE4 for ; Wed, 30 Oct 2019 14:23:15 +0000 (UTC) X-FDA: 76100668350.16.beam51_398b4fc5b5a35 X-Spam-Summary: 2,0,0,8e0b06f70b6492bb,d41d8cd98f00b204,30py5xqykcounspklynvvnsl.jvtspube-ttrchjr.vyn@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com::viro@zeniv.linux.org.uk:akpm@linux-foundation.org:aryabinin@virtuozzo.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@lst.de:dmitry.torokhov@gmail.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:mingo@elte.hu:axboe@kernel.dk:martin.petersen@oracle.com:schwidefsky@de.ibm.com:mst@redhat.com:monstr@monstr.eu:pmladek@suse.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu:tglx@linutronix.de:wsa@the-dreams.de:gor@linux.ibm.com:iii@linux.ibm.com:mark.rutland@arm.com:willy@infradead.org:rdunlap@infradead.org:andreyknvl@google.com:elver@google.com:glider@google.com,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747 :1777:17 X-HE-Tag: beam51_398b4fc5b5a35 X-Filterd-Recvd-Size: 4640 Received: from mail-vs1-f74.google.com (mail-vs1-f74.google.com [209.85.217.74]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 14:23:15 +0000 (UTC) Received: by mail-vs1-f74.google.com with SMTP id z20so286335vsf.1 for ; Wed, 30 Oct 2019 07:23:15 -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=EGPzaL+niyswOznwvIuwrUyCjjQExKUEjV+KnYXXwaQ=; b=EVCxrwaV/qTVAvzAb/1nrTFltIfxcpwtmokBEcUO8dcStmv4nNRQ/QQ5XIYnLJvgHr HETCNvWv6divvbLP07WbqseTy+rRM0gz0HOpHyFGKykBsvtKsx7WhH5D8qHBqJr605M4 zZSOfd556o4FVy4wMe8+BK+Nw9sUIdfE6Mb82j6VILOY0Hycbdc/123Ton8ZEVvrbzaX 17RaepM1xxGYPJer7Ojx282mmw09A43IsdYPLqUuGqCiOCo/f7usgp1tT2TcFHsOtrc/ toib/+DQQtT2rh2bi5NEy3bI2bGbBYFXd6YDASTat4uENRA172hFLRUSvVnpzpSeAUvW 5Igw== 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=EGPzaL+niyswOznwvIuwrUyCjjQExKUEjV+KnYXXwaQ=; b=hqInchzUDqoTXihsXDA0czldF93qu6biypIFRyNOdJ15vz74JUHoEdhU0u55JqWZpx AFcTVbEGpl8MCiX84wdFgXAJT/E6IXMTgGbgGwzBB1ZuSZnfvr6cJsseT1ZJBxpYYeaB V7579BqUzSW2AOgXo8n9ex8FJ3Lr/JF8yAShtuEF81tk0EnJuccG9Qpsnpqow0b6OmtV GhMPGPOp1eXO0xjpOiDI9EBF8PeoXzzoowsCjioiOKHVlINL+3IABlclY34ESQu2+KYT 15CXlHsTxvoCbAcjWgAMPLkavI1sbdkdTTeEeXgbdnnSH3PER1wreL9rOweO2bEuMLq3 GbjQ== X-Gm-Message-State: APjAAAUaranw1kutoTf/rcoH5loxoAZVfNw9MQ0WVKxYpo6gpcymtMkc PWy/BGvxiaKuzWrg27rPYUaTaxqXdUQ= X-Google-Smtp-Source: APXvYqwNLWD3F36CmMBJqVa4XZ6mG+R5g5iwr7WEW+oS0TijyHTuSxkWJ+7a/Bzxl79P2EdyTRHbc3LThsA= X-Received: by 2002:a67:dd97:: with SMTP id i23mr5176139vsk.79.1572445394336; Wed, 30 Oct 2019 07:23:14 -0700 (PDT) Date: Wed, 30 Oct 2019 15:22:22 +0100 In-Reply-To: <20191030142237.249532-1-glider@google.com> Message-Id: <20191030142237.249532-11-glider@google.com> Mime-Version: 1.0 References: <20191030142237.249532-1-glider@google.com> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog Subject: [PATCH RFC v2 10/25] kmsan: define READ_ONCE_NOCHECK() From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@lst.de, dmitry.torokhov@gmail.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, mingo@elte.hu, axboe@kernel.dk, martin.petersen@oracle.com, schwidefsky@de.ibm.com, mst@redhat.com, monstr@monstr.eu, pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, wsa@the-dreams.de, gor@linux.ibm.com, iii@linux.ibm.com, mark.rutland@arm.com, willy@infradead.org, rdunlap@infradead.org, andreyknvl@google.com, elver@google.com, Alexander Potapenko 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: Vegard Nossum Cc: Dmitry Vyukov Cc: linux-mm@kvack.org --- Change-Id: Ib38369ba038ab3b581d8e45b81036c3304fb79cb --- include/linux/compiler.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 5e88e7e33abe..e8c86debdb2b 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -270,9 +270,13 @@ 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. */ +#ifndef CONFIG_KMSAN #define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0) +#else +#define READ_ONCE_NOCHECK(x) KMSAN_INIT_VALUE(__READ_ONCE(x, 0)) +#endif static __no_kasan_or_inline unsigned long read_word_at_a_time(const void *addr)