Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4369068ioa; Wed, 27 Apr 2022 02:09:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKb5PoSbpoKQQI9FNlLdZZp5wPnh5lmDAtwW4Az7wKaK3fcqBTPBvj+YRUEMLhc3LnhdvF X-Received: by 2002:a63:2113:0:b0:399:2df0:ff07 with SMTP id h19-20020a632113000000b003992df0ff07mr22792010pgh.374.1651050568025; Wed, 27 Apr 2022 02:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651050568; cv=none; d=google.com; s=arc-20160816; b=SVEslz9LAEDv7RFbVpcND4loHvlbSESdg6Nf/CZrwuZXXlbtCFs9l0Y3jVLaXsu58J QScg/K12fFvg0h2gBLgDcuvgTRjBF1jCS0Aa7WEieGpUIG7mUTn1i7yez8bTokdTTVzg fD4Z5FE4EtJkuPStNSuWtUwafwEqiZQC1CmzHOCgf+gVr9ABHalys0kn6sZ2MVPRbENQ lxbyYErnU+rMNyzsBEwW+OCkE7tBFQ++2U9yr6GXm94lOfBVuvni88rgRypecgKphULr P+F6DQ0h4tHHBRvs1P2LvF4UC3DUvmFd9o9r4g9cB+0P7J1/FgadIOTg0S8bQ95wQNuD NgZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=bWOHkFAZUowQhXbgV/15IRTSfhe/pFIeo0hpg6VoqgU=; b=Kt9AaZWtMHXEl2P54O5msAEvTDK8jdFKU7JutrDA4RCwNg6ipdg00Xpd8FeAoTRNqy VbnGZXfxB6C9occfyu2Zs2euHcu1hIcBbJjWQIs3LsTV9SOLghRP9IobzLj7wTzfpJPB u3UfI60qu9+p0o5vcfv7FjbkRHz7dnDCmCUYXyTbGAcSkm3Qshhq0VemFEc4oOaRXDdk cviWEIt6MSwM880Y7eFHvQpNWmt1lLWc+o6PlibwDPEiakq3dgEoE/IaqNMlD982+4PW my0O0mn6VmxHlbCsKWPQ7cJIKj4Tr4vCooA0eNOb/ryv+WczrLMdxiHsjQ2tab1rVNd4 +DAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Y425LRYJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e63-20020a636942000000b003a99c678853si849004pgc.590.2022.04.27.02.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 02:09:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Y425LRYJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 465CD139748; Wed, 27 Apr 2022 02:00:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353526AbiDZQxB (ORCPT + 99 others); Tue, 26 Apr 2022 12:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353284AbiDZQuS (ORCPT ); Tue, 26 Apr 2022 12:50:18 -0400 Received: from mail-ej1-x649.google.com (mail-ej1-x649.google.com [IPv6:2a00:1450:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 973AC4739C for ; Tue, 26 Apr 2022 09:45:39 -0700 (PDT) Received: by mail-ej1-x649.google.com with SMTP id o8-20020a170906974800b006f3a8be7502so2044232ejy.8 for ; Tue, 26 Apr 2022 09:45:39 -0700 (PDT) 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=bWOHkFAZUowQhXbgV/15IRTSfhe/pFIeo0hpg6VoqgU=; b=Y425LRYJ7pqp2qUV4Un5BKaPtlMc56oRipAYvk35bNiZHMqwQj5K1oHUY+3UtaBrm8 6F8LD23RH7puAqmN6VxxN3dzRPCX2o3jtXwChLes9m38UGHVO/PjltBdViFuvOO0/pv+ 9a5CV3vayhrQVrbmrEv1bjS0Nmz7caoEnvxuLCxERX2znPJk4SiPOZ9Qb7HS9LCHG3Lh qNuuAbPiqTn/Kfp6058UKfvV0NLpFCO10Egzm+8gacy2cKWG5HhTdR3sVdEPim8XyvUO oM/6bhYxYTS9e2sL18gV9sczR7Og8Y4lewCULG7qERx2rzD5bbV+C50LUjYRSUrnHoTG GPqg== 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=bWOHkFAZUowQhXbgV/15IRTSfhe/pFIeo0hpg6VoqgU=; b=ihYk+y9wfGQu2tclZzzhdM7bqKD6byTpsOSpPh5Jvy2gqqEi6rL4k0SwSmhtLWkjAy teMw/EImpxPF9RPrZma8JX1UNFwmOuKKCA0HyU4afVcUFWfnkT4SDhY1XRZ8gafZ7w62 7knj+AstYV+LREyUIIUi668ryrE/BgHbx/mlq2QXtQa5Gzd3fwJtxuG3Y85noylLfa5v G4iUTiUDwqyiyDtf7xMCr8J40U3kL1orG7PnU6jX2yN5WIIouxsAsYO5UCAqdpZphIeS K28u5BiOl7rwdp/jvsXSJ8lymF/5vFvUTl8u7BiPCUOSVW7lFNuUPtutjENxeyzCt8cT 53sg== X-Gm-Message-State: AOAM533UDF3b83IjobGRfVMLWfLqCDyrh2UMHRyJd4S4hEPXZqlpfYKl q4SI2gvOScltDjjGtJnGKWBHn1kvkYY= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:d580:abeb:bf6d:5726]) (user=glider job=sendgmr) by 2002:aa7:c789:0:b0:413:605d:8d17 with SMTP id n9-20020aa7c789000000b00413605d8d17mr25370617eds.100.1650991538395; Tue, 26 Apr 2022 09:45:38 -0700 (PDT) Date: Tue, 26 Apr 2022 18:42:59 +0200 In-Reply-To: <20220426164315.625149-1-glider@google.com> Message-Id: <20220426164315.625149-31-glider@google.com> Mime-Version: 1.0 References: <20220426164315.625149-1-glider@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v3 30/46] kmsan: disable strscpy() optimization under KMSAN From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Andrew Morton , Andrey Konovalov , Andy Lutomirski , 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 , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Disable the efficient 8-byte reading under KMSAN to avoid false positives. Signed-off-by: Alexander Potapenko --- Link: https://linux-review.googlesource.com/id/Iffd8336965e88fce915db2e6a9d6524422975f69 --- lib/string.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/string.c b/lib/string.c index 485777c9da832..4ece4c7e7831b 100644 --- a/lib/string.c +++ b/lib/string.c @@ -197,6 +197,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; + while (max >= sizeof(unsigned long)) { unsigned long c, data; -- 2.36.0.rc2.479.g8af0fa9b8e-goog