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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 F2414CA9EC3 for ; Thu, 31 Oct 2019 11:49:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C06DE20862 for ; Thu, 31 Oct 2019 11:49:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C06DE20862 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 463026B0003; Thu, 31 Oct 2019 07:49:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4133F6B0005; Thu, 31 Oct 2019 07:49:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34F596B0007; Thu, 31 Oct 2019 07:49:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 0E37E6B0003 for ; Thu, 31 Oct 2019 07:49:23 -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 ACAB0180ACF86 for ; Thu, 31 Oct 2019 11:49:22 +0000 (UTC) X-FDA: 76103909364.16.seat36_51d2475a3863c X-HE-Tag: seat36_51d2475a3863c X-Filterd-Recvd-Size: 4514 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 31 Oct 2019 11:49:22 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 791F0B205; Thu, 31 Oct 2019 11:49:19 +0000 (UTC) Date: Thu, 31 Oct 2019 12:49:16 +0100 From: Petr Mladek To: glider@google.com Cc: Andrew Morton , Greg Kroah-Hartman , Eric Dumazet , Wolfram Sang , Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org, viro@zeniv.linux.org.uk, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@lst.de, dmitry.torokhov@gmail.com, ericvh@gmail.com, 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, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.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 Subject: Re: [PATCH RFC v2 18/25] kmsan: call KMSAN hooks where needed Message-ID: <20191031114916.ikz3phubs4jqdmnf@pathway.suse.cz> References:<20191030142237.249532-1-glider@google.com> <20191030142237.249532-19-glider@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To:<20191030142237.249532-19-glider@google.com> User-Agent: NeoMutt/20170912 (1.9.0) 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 Wed 2019-10-30 15:22:30, glider@google.com wrote: > Insert KMSAN hooks that check for potential memory errors and/or make > necessary bookkeeping changes: > - allocate/split/deallocate metadata pages in > alloc_pages()/split_page()/free_page(); > - clear page shadow and origins in clear_page(), copy_user_highpage(); > - copy page metadata in copy_highpage(), wp_page_copy(); > - handle vmap()/vunmap()/iounmap(); > - handle task creation and deletion; > - initialize result of vscnprintf() in vprintk_store(); > - call softirq entry/exit hooks in kernel/softirq.c; > - check/initialize memory sent to/read from USB, I2C, and network > > Signed-off-by: Alexander Potapenko > To: Alexander Potapenko > Cc: Andrew Morton > Cc: Greg Kroah-Hartman > Cc: Eric Dumazet > Cc: Wolfram Sang > Cc: Petr Mladek > Cc: Vegard Nossum > Cc: Dmitry Vyukov > Cc: linux-mm@kvack.org > --- > > v2: > - dropped call to kmsan_handle_vprintk, updated comment in printk.c > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index ca65327a6de8..4b0dbed0333a 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -1914,7 +1914,13 @@ int vprintk_store(int facility, int level, > * The printf needs to come first; we need the syslog > * prefix which might be passed-in as a parameter. > */ > - text_len = vscnprintf(text, sizeof(textbuf), fmt, args); > + /* Please, separate the two comments with an empty line instead of using */ and /*. > + * If any of vscnprintf() arguments is uninitialized, KMSAN will report > + * one or more errors and also probably mark text_len as uninitialized. > + * Initialize |text_len| to prevent the errors from spreading further. > + */ > + text_len = KMSAN_INIT_VALUE(vscnprintf(text, sizeof(textbuf), fmt, > + args)); Please, keep it on a single line. This seems to be the case where the 80-characters limit rule just breaks readability. I still think that KMSAN should report only the first use of an uninitialized value. It should _not_ report locations where the value is spread. The root of the problem must be fixed. Everything else looks like an unnecessary noise. Well, this fake initialization is added only 4 times in this patchset. So, it is not a disaster. I could live with the change. And if people like/want this behavior... With the two cosmetic changes, feel free to use: Acked-by: Petr Mladek # printk part Best Regards, Petr