From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E3B0C2BA2B for ; Mon, 13 Apr 2020 15:32:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 44FFA20735 for ; Mon, 13 Apr 2020 15:32:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44FFA20735 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5BF08E0125; Mon, 13 Apr 2020 11:32:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D32568E0104; Mon, 13 Apr 2020 11:32:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C48748E0125; Mon, 13 Apr 2020 11:32:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id ACD9E8E0104 for ; Mon, 13 Apr 2020 11:32:54 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 754B98248047 for ; Mon, 13 Apr 2020 15:32:54 +0000 (UTC) X-FDA: 76703224668.20.camp32_8dbc6f5b3580f X-HE-Tag: camp32_8dbc6f5b3580f X-Filterd-Recvd-Size: 5255 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Apr 2020 15:32:53 +0000 (UTC) Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF1BF2072D; Mon, 13 Apr 2020 15:32:48 +0000 (UTC) Date: Mon, 13 Apr 2020 11:32:47 -0400 From: Steven Rostedt To: Alexander Potapenko Cc: Andrey Konovalov , Vegard Nossum , Dmitry Vyukov , Marco Elver , Linux Memory Management List , Alexander Viro , Andreas Dilger , Andrew Morton , Andrey Ryabinin , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Christoph Hellwig , Christoph Hellwig , "Darrick J. Wong" , "David S. Miller" , Dmitry Torokhov , Eric Biggers , Eric Dumazet , Eric Van Hensbergen , Greg Kroah-Hartman , Harry Wentland , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jason Wang , Jens Axboe , Marek Szyprowski , Mark Rutland , "Martin K. Petersen" , Martin Schwidefsky , Matthew Wilcox , "Michael S . Tsirkin" , Michal Hocko , Michal Simek , Petr Mladek , Qian Cai , Randy Dunlap , Robin Murphy , Sergey Senozhatsky , Takashi Iwai , "Theodore Ts'o" , Thomas Gleixner , Vasily Gorbik , Wolfram Sang Subject: Re: [PATCH v5 32/38] kmsan: disable strscpy() optimization under KMSAN Message-ID: <20200413113247.0752010b@gandalf.local.home> In-Reply-To: References: <20200325161249.55095-1-glider@google.com> <20200325161249.55095-33-glider@google.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: On Mon, 13 Apr 2020 16:19:40 +0200 Alexander Potapenko wrote: > On Wed, Apr 8, 2020 at 6:01 PM Andrey Konovalov wrote: > > > > On Wed, Mar 25, 2020 at 5:14 PM wrote: > > > > > > Disable the efficient 8-byte reading under KMSAN to avoid false positives. > > > > Another user of read_word_at_a_time() is dentry_string_cmp() in > > dcache.c, should we disable it there as well? > > > > I think we'd better disable DCACHE_WORD_ACCESS if KMSAN is enabled. > Will do that in v6. > > > > > > > Signed-off-by: Alexander Potapenko > > > To: Alexander Potapenko > > > Cc: Vegard Nossum > > > Cc: Dmitry Vyukov > > > Cc: Marco Elver > > > Cc: Andrey Konovalov > > > Cc: linux-mm@kvack.org > > > > > > --- > > > > > > v4: > > > - actually disable the optimization under KMSAN via max=0 > > > - use IS_ENABLED as requested by Marco Elver > > > > > > Change-Id: I25d1acf5c3df6eff85894cd94f5ddbe93308271c > > > --- > > > lib/string.c | 8 ++++++++ > > > 1 file changed, 8 insertions(+) > > > > > > diff --git a/lib/string.c b/lib/string.c > > > index 6012c385fb314..fec929e70f1a5 100644 > > > --- a/lib/string.c > > > +++ b/lib/string.c > > > @@ -202,6 +202,14 @@ ssize_t strscpy(char *dest, const char *src, size_t count) > > > max = 0; > > > #endif > > > > > > + /* > > > + * read_word_at_a_time() below may read uninitialized bytes after the > > > + * trailing zero and use them in comparisons. Disable this optimization > > > + * under KMSAN to prevent false positive reports. > > > + */ > > > + if (IS_ENABLED(CONFIG_KMSAN)) > > > + max = 0; > > > + Instead of disabling the optimization, can't you make KMSAN aware of the "has_zero()" call (which I believe is the part that will trip up KMSAN) and just not report it? -- Steve > > > while (max >= sizeof(unsigned long)) { > > > unsigned long c, data; > > > > > > -- > > > 2.25.1.696.g5e7596f4ac-goog > > > > > >