Message ID | 20220701142310.2188015-27-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 85D3DC433EF for <linux-mm@archiver.kernel.org>; Fri, 1 Jul 2022 14:24:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 166C76B0071; Fri, 1 Jul 2022 10:24:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1171C6B007D; Fri, 1 Jul 2022 10:24:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EABE56B0082; Fri, 1 Jul 2022 10:24:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DBF2B6B0071 for <linux-mm@kvack.org>; Fri, 1 Jul 2022 10:24:29 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B6CBD6D5 for <linux-mm@kvack.org>; Fri, 1 Jul 2022 14:24:29 +0000 (UTC) X-FDA: 79638751458.09.89054E4 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) by imf16.hostedemail.com (Postfix) with ESMTP id 46282180009 for <linux-mm@kvack.org>; Fri, 1 Jul 2022 14:24:29 +0000 (UTC) Received: by mail-ej1-f73.google.com with SMTP id hd35-20020a17090796a300b0072a707cfac4so840869ejc.8 for <linux-mm@kvack.org>; Fri, 01 Jul 2022 07:24:29 -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=BanD6+8XMfAM/imhDA9kzvs2Y65ZtmV55Antiu9BWiI=; b=mRTIF6L84JAlg2BdRm6GzX0JAROwRk/sEAnHEyfcCrrVzpgYQDP4s07FuADnqgr6wB ksMNaoreBTcwNzLVqW2CLQ5LB7q3aAIulZLYB9nuQCnWIkiiRq/Q6VQMDSS0zlOVULIz Ix5FQ2wgYo7L210aM/fKxFuU2tFPKcIZsO4Bd7Rml1N7o3/Qm7KUm5NB65g2Iem/FeNl 60bw+n3Gge8W8wvYFmfBqE0m7x4Rd1oXGrEp9Fu06BG/VFY3yN6zDkc7HdcrNddl9RFZ bKRR73XyhRvmnmBNBCirP4336bKCGzJJU7II1NZsV//Tb+lcEnJtFA9n/GAdR4WOxrCR uhTA== 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=BanD6+8XMfAM/imhDA9kzvs2Y65ZtmV55Antiu9BWiI=; b=Yk67brTUYCMKg9DM1d8Ps852GXqzM47EVY37VmuFKmau8I6zcUdUaBu7IQaJ4FN3ru 5C7oIDJ1gQwrPnRuKiXvxOB1gKcBsvAwsbPF7EF7+8O73YpvZIEyKI1+42K+pQGa8DI0 YMZ55d5UEUmn33THPBn28DuXGaXAp4QGUK6+AvhkM2/JFOmFbqZBCxQgqnX243NRo1DV 8YxNRfuZ52yx1Yixc+kwOAzfK6cybvj+p21dlZABzpUb/Q+lSlUqUCzK9lS8iTPthhDx 8h566RpI4I19JCGFwfuRfW4BZoe6/BfAihmLUHJlNOnW8YIWI+m8hRu09q52EQbUik9N vp5w== X-Gm-Message-State: AJIora8LctF+SSwXiqsXfhSOc2F6uBo2VW2xmaEc9PVa3Wy1H2pG0qDC 711dWrUC++spxwF6ky6vp22Rz7y0Tfs= X-Google-Smtp-Source: AGRyM1siOEbFYB7M2t/Uxp+hgW7r6Fq8QtqzrawcUEK1N9TlhUHD1diimHPgmIHCv/uA9yMN9zjsG0VRP+I= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:a6f5:f713:759c:abb6]) (user=glider job=sendgmr) by 2002:a50:fe0c:0:b0:435:510a:9f1f with SMTP id f12-20020a50fe0c000000b00435510a9f1fmr19625057edt.297.1656685468052; Fri, 01 Jul 2022 07:24:28 -0700 (PDT) Date: Fri, 1 Jul 2022 16:22:51 +0200 In-Reply-To: <20220701142310.2188015-1-glider@google.com> Message-Id: <20220701142310.2188015-27-glider@google.com> Mime-Version: 1.0 References: <20220701142310.2188015-1-glider@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v4 26/45] kmsan: disable strscpy() optimization under KMSAN From: Alexander Potapenko <glider@google.com> To: glider@google.com Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Alexei Starovoitov <ast@kernel.org>, 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>, 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656685469; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BanD6+8XMfAM/imhDA9kzvs2Y65ZtmV55Antiu9BWiI=; b=sNS3F9Fa05oa71wjr2AqCaq5HyMtUhikUNGD4yiVCsVg1P4qVZ6hfZQdDiXJXMGgphqVZB Ttac+AFqfLkQ2QCYPh7mhgue9sm0kGtHb2Tc5kV9hOhkLS778OfqLYBhW0sxjKeHvEd7ws E03aOryGYwKUrK17REfWE7S9ROnUY3k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656685469; a=rsa-sha256; cv=none; b=u0SHMJ7bPUG6ciC8I2s49x+SAc7HW1zk83hmnanZROSUhBSkYMhGN/NoAjwOTiKWb+vCKZ yh/0eoYyr54wH8NozTApYz4n6WzaXXL34YIRdPUmf6iKzckJSyfgj3UQY7mAFHICqiLX5D LdVzzqTsJhZgpt5rS66Oabx4hoGi8Co= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=mRTIF6L8; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3nAO_YgYKCLshmjefshpphmf.dpnmjovy-nnlwbdl.psh@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3nAO_YgYKCLshmjefshpphmf.dpnmjovy-nnlwbdl.psh@flex--glider.bounces.google.com X-Stat-Signature: 9umt614uoj5qc4kjgzq9ojmj9otk4mbe X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=mRTIF6L8; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3nAO_YgYKCLshmjefshpphmf.dpnmjovy-nnlwbdl.psh@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3nAO_YgYKCLshmjefshpphmf.dpnmjovy-nnlwbdl.psh@flex--glider.bounces.google.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 46282180009 X-HE-Tag: 1656685469-596652 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 6f334420f6871..3371d26a0e390 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(+)