Message ID | 20220329124017.737571-33-glider@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6040C433EF for <linux-mm@archiver.kernel.org>; Tue, 29 Mar 2022 12:41:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B67B8D0010; Tue, 29 Mar 2022 08:41:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5663C8D000F; Tue, 29 Mar 2022 08:41:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45A2E8D0010; Tue, 29 Mar 2022 08:41:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 307AA8D000F for <linux-mm@kvack.org>; Tue, 29 Mar 2022 08:41:57 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 13FC4606CD for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:41:57 +0000 (UTC) X-FDA: 79297385874.10.471CFDD Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) by imf25.hostedemail.com (Postfix) with ESMTP id 89EE9A0009 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:41:56 +0000 (UTC) Received: by mail-ed1-f74.google.com with SMTP id i4-20020aa7c9c4000000b00419c542270dso5230674edt.8 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 05:41:56 -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=RDAmLqPngdYXKHnjNo9GDMAFOLr0Hdlw9RyMH9Gzg2s=; b=FNcO9gUSy3+PyH4e35W5RF6+lKn5SBE99oNAhVPz9pbYEq9m/C8L6ZgtW5ZmHXHd88 hQHJyPhLbOckmp0EqPMhP2HFzsxaGQxiGxliYPsshxLsXZvRvNDQ3UiI+w2rcId/Pty2 F64ZcwqpBt31uCBn0TdlaFTImU9JlBg1RYV2VHIqSgThEHMQahV/qTUZD+t5uPqd7ue6 fH/tn196F1PiJHLimD7A+gQDUww4aLBtiNt+XEamDrdfD269XRiydzui+vDM+yTJPgEp rF70JXIzeqHaym/T57YbYOQSbgbJ7VSdFIY7t07gue+zb/IWNfau8QfmJWCRW+7p6THF iMvw== 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=RDAmLqPngdYXKHnjNo9GDMAFOLr0Hdlw9RyMH9Gzg2s=; b=mbJ2rMssxiWQLOD1bqQq8p5mMRlFWJzgax6nYvLYgX/e8+hTbI7gIx2I5BW4Ua+pVy 6AjtJov7hpiY+JE2r22qHM9ThkDRcK6jSQYGqiJVuZzG19L8K8I4Hk79hkSq3pgNlOZz BJN/3Y9w1wgl+nLVA2X606Isk6CWV9yediM7uQWqMCSENxf9ShA5kwd0e38ZU0GG6rJK /LYaf/UDlKxXvVO19hFLoLa037mxYPZPaK4lzGfFrzh0ZflZBAcBS+0KWl3H3MJ+0cf+ x+3j0KlboKRjcB0iwaKyBI9k4Bq7RaD3rpM0znQuDE9411EgcAz/Eizs+IG58QIKBLCZ 5fsg== X-Gm-Message-State: AOAM531CIWAcyoi4bvMeZIgXHMshb4twfxSKnXppd9TTyYGCheRAtdwb d2y+DJ7OHPaslbxLYF776peEx3Tg1Ho= X-Google-Smtp-Source: ABdhPJzvRP1sTqhryqj6ueAWd65Bk5TF0Xd1dq7WPSkbBowXyk0DvSiadnoCaN6qak+2HIZ7cYi2Zk2fLDo= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:36eb:759:798f:98c3]) (user=glider job=sendgmr) by 2002:a17:906:af6b:b0:6df:83a9:67db with SMTP id os11-20020a170906af6b00b006df83a967dbmr34685899ejb.222.1648557715258; Tue, 29 Mar 2022 05:41:55 -0700 (PDT) Date: Tue, 29 Mar 2022 14:40:01 +0200 In-Reply-To: <20220329124017.737571-1-glider@google.com> Message-Id: <20220329124017.737571-33-glider@google.com> Mime-Version: 1.0 References: <20220329124017.737571-1-glider@google.com> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog Subject: [PATCH v2 32/48] kmsan: disable strscpy() optimization under KMSAN From: Alexander Potapenko <glider@google.com> To: glider@google.com Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Andrew Morton <akpm@linux-foundation.org>, Andrey Konovalov <andreyknvl@google.com>, Andy Lutomirski <luto@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Borislav Petkov <bp@alien8.de>, Christoph Hellwig <hch@lst.de>, Christoph Lameter <cl@linux.com>, David Rientjes <rientjes@google.com>, Dmitry Vyukov <dvyukov@google.com>, Eric Dumazet <edumazet@google.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Herbert Xu <herbert@gondor.apana.org.au>, Ilya Leoshkevich <iii@linux.ibm.com>, Ingo Molnar <mingo@redhat.com>, Jens Axboe <axboe@kernel.dk>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Kees Cook <keescook@chromium.org>, Marco Elver <elver@google.com>, Mark Rutland <mark.rutland@arm.com>, Matthew Wilcox <willy@infradead.org>, "Michael S. Tsirkin" <mst@redhat.com>, Pekka Enberg <penberg@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Petr Mladek <pmladek@suse.com>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, Vasily Gorbik <gor@linux.ibm.com>, Vegard Nossum <vegard.nossum@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: mx7yms1pjpfxr7omturooiz8tqqfiub9 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=FNcO9gUS; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of 3k_5CYgYKCLQafcXYlaiiafY.Wigfchor-ggepUWe.ila@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3k_5CYgYKCLQafcXYlaiiafY.Wigfchor-ggepUWe.ila@flex--glider.bounces.google.com X-Rspamd-Queue-Id: 89EE9A0009 X-HE-Tag: 1648557716-462174 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: <linux-mm.kvack.org> |
Series |
Add KernelMemorySanitizer infrastructure
|
expand
|
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;
Disable the efficient 8-byte reading under KMSAN to avoid false positives. Signed-off-by: Alexander Potapenko <glider@google.com> --- Link: https://linux-review.googlesource.com/id/Iffd8336965e88fce915db2e6a9d6524422975f69 --- lib/string.c | 8 ++++++++ 1 file changed, 8 insertions(+)