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=-19.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL 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 4F4FEC43215 for ; Tue, 3 Dec 2019 11:25:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E779420675 for ; Tue, 3 Dec 2019 11:25:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tL2BKnCW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E779420675 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 5791F6B04A9; Tue, 3 Dec 2019 06:25:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 52C286B04AA; Tue, 3 Dec 2019 06:25:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4189D6B04AB; Tue, 3 Dec 2019 06:25:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 27B1C6B04A9 for ; Tue, 3 Dec 2019 06:25:05 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id D1B71180AD811 for ; Tue, 3 Dec 2019 11:25:04 +0000 (UTC) X-FDA: 76223598528.06.hand62_2c48d4562845b X-HE-Tag: hand62_2c48d4562845b X-Filterd-Recvd-Size: 8067 Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Dec 2019 11:25:04 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id p8so2534683oth.10 for ; Tue, 03 Dec 2019 03:25:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=nrF+r5thKvSc7Wy9EcR1FuJ8kC4Y3/31E/OCWVkTZVg=; b=tL2BKnCWQm086l17+Xq1nMizJ4a4lRyB8YQzimMavm/n8RBRldRywtYuB5+kGkLAPm k4rjyiJ64/jJ7BqJ/vFMMZs1eFamRGtH5BR0+tOWACKJZHOmx0bZzDF3WoLAZ+SqNAb+ bJANqAAKhJbc7CJ5imEMFMG5lp3XZjk9CLShgvCZ7qpW5q40wlCjItpFtja88jUV55/U E3WJUm8OUOioNiBWIvzuUwkzKoAcas1ueewlOgSHr3leU5Q6DQLbub82fvivQC3QSTkV d7urHTVKUb1ksnqrmtAJRhi7+jNf88RTg6LO6m+sb4mua3XtxYTKeCAe8IhTf7JKKxxo VrRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=nrF+r5thKvSc7Wy9EcR1FuJ8kC4Y3/31E/OCWVkTZVg=; b=OQ3OwRaa2VS+BnLJ4PMU7Q/7Hpw9FxXHH1FE0S18ezqmkoWtZixYu4gu2ub1YOGhwW 7/8IUj19aV/mg9U+MUdWEfOo0ISKTnWeuMLJFgAwvI/To1B/3sebjMkTp+nSU0HcMEuu RAAUgT/xFmeXMlbKbDcVg1xRLBV4kFMx4MhHE333jyG67bqHTvqcESdda96nBaR2BqXj 07aO/Dyn02HA+nCNMWuRY9oFOzUhMHJkmX4oL5Blm1GBjA/OBjEF5Ch9d3hpItqg0uVm u5NpP79dGlK1NDTHyaA5fxJ2rJF6HSBVtP8FLW/f5wttQW8htIJItCCUubmf0KhsPhy2 zrUQ== X-Gm-Message-State: APjAAAW+I7HszekOpKvPb8z++zOm/bHy7SmB6styuOxBO05WpMDDNZjk LV56jb4k8rHgICzeVb3DkE+fYg8sV3T6GLTmWbvKYg== X-Google-Smtp-Source: APXvYqxxnckeR1W9ht3WNoap2dZuTEZptfSuTziYVmKfqhW6G8iVq9uM/MaB9VxBItJFqIERMCwJ7360u9JOoS9LE5o= X-Received: by 2002:a9d:7f12:: with SMTP id j18mr2886993otq.17.1575372302948; Tue, 03 Dec 2019 03:25:02 -0800 (PST) MIME-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> <20191122112621.204798-32-glider@google.com> In-Reply-To: From: Marco Elver Date: Tue, 3 Dec 2019 12:24:51 +0100 Message-ID: Subject: Re: [PATCH RFC v3 31/36] kmsan: disable strscpy() optimization under KMSAN To: Alexander Potapenko Cc: Vegard Nossum , Dmitry Vyukov , Linux Memory Management List , Al Viro , Andreas Dilger , Andrew Morton , Andrey Konovalov , 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 Simek , Petr Mladek , Qian Cai , Randy Dunlap , Robin Murphy , Sergey Senozhatsky , Steven Rostedt , Takashi Iwai , "Theodore Ts'o" , Thomas Gleixner , Vasily Gorbik , Wolfram Sang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Tue, 3 Dec 2019 at 12:19, Alexander Potapenko wrote: > > On Mon, Dec 2, 2019 at 5:23 PM Alexander Potapenko wr= ote: > > > > On Mon, Dec 2, 2019 at 4:51 PM Marco Elver wrote: > > > > > > On Fri, 22 Nov 2019 at 12:28, wrote: > > > > > > > > Disable the efficient 8-byte reading under KMSAN to avoid false pos= itives. > > > > > > > > Signed-off-by: Alexander Potapenko > > > > To: Alexander Potapenko > > > > Cc: Vegard Nossum > > > > Cc: Dmitry Vyukov > > > > Cc: linux-mm@kvack.org > > > > > > > > --- > > > > > > > > Change-Id: I25d1acf5c3df6eff85894cd94f5ddbe93308271c > > > > --- > > > > lib/string.c | 5 ++++- > > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/lib/string.c b/lib/string.c > > > > index 08ec58cc673b..15efdc51bda6 100644 > > > > --- a/lib/string.c > > > > +++ b/lib/string.c > > > > @@ -186,7 +186,10 @@ ssize_t strscpy(char *dest, const char *src, s= ize_t count) > > > > if (count =3D=3D 0 || WARN_ON_ONCE(count > INT_MAX)) > > > > return -E2BIG; > > > > > > > > -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS > > > > +/** > > > > > > Why a doc comment? > > Will fix, thanks! > > > > + * Disable the efficient 8-byte reading under KMSAN to avoid false= positives. > > > > + */ > > > > > > AFAIK the CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS case is about > > > unaligned accesses crossing page boundaries. In the #else case it's > > > still going to do word-at-a-time if both src and dest are aligned, so > > > the comment above is somewhat inaccurate. > > Yes, this makes little sense. > > Reading word-at-a-time shouldn't induce any errors, although it may > > generate redundant stack IDs for values that will never be used. > > I'll try to drop this patch. > Turns out the patch is still needed, as read_word_at_a_time may read > uninitialized bytes which are then used in comparisons. > I've changed the patch to always set max=3D0 under KMSAN: > https://github.com/google/kmsan/commit/3ff43863bf53dd871a3d4dc4fbb2a76d79= b4db4f > Will include this version in v4 series. So was the previous version working because all strscpy where this was relevant were unaligned? Re new patch: I think here it should be trivial to use 'if (IS_ENABLED(CONFIG_KMSAN))' instead of #ifdef. Thanks, -- Marco > > > > +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && !defined(CO= NFIG_KMSAN) > > > > /* > > > > * If src is unaligned, don't cross a page boundary, > > > > * since we don't know if the next page is mapped. > > > > -- > > > > 2.24.0.432.g9d3f5f5b63-goog > > > > > > > > > > > > -- > > Alexander Potapenko > > Software Engineer > > > > Google Germany GmbH > > Erika-Mann-Stra=C3=9Fe, 33 > > 80636 M=C3=BCnchen > > > > Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Halimah DeLaine Prado > > Registergericht und -nummer: Hamburg, HRB 86891 > > Sitz der Gesellschaft: Hamburg > > > > -- > Alexander Potapenko > Software Engineer > > Google Germany GmbH > Erika-Mann-Stra=C3=9Fe, 33 > 80636 M=C3=BCnchen > > Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Halimah DeLaine Prado > Registergericht und -nummer: Hamburg, HRB 86891 > Sitz der Gesellschaft: Hamburg