Message ID | 20220915150417.722975-26-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 573CEC6FA8A for <linux-mm@archiver.kernel.org>; Thu, 15 Sep 2022 15:05:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84B5180019; Thu, 15 Sep 2022 11:05:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8203480007; Thu, 15 Sep 2022 11:05:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EA9080019; Thu, 15 Sep 2022 11:05:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5A8A180007 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 11:05:48 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2A38B801F7 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 15:05:48 +0000 (UTC) X-FDA: 79914644376.28.0018E1C Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) by imf16.hostedemail.com (Postfix) with ESMTP id E218C1800A9 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 15:05:47 +0000 (UTC) Received: by mail-ed1-f74.google.com with SMTP id w17-20020a056402269100b0045249bc17a9so6685092edd.9 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 08:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=PRETZsLeKtd8er/vGZIvwJ67UbRQnpYPS7VnNd6iitc=; b=IWkX75T/Q/431JKoP2sw1gGv+TRTk4KNLPsHPqPmF3DWGGkurKMl+8ONAEiBTDmheE /bRfKFH3UY7lflgk+tGWw2/6W93k+canHKGQEEM6HO9CEQKXMkCUdWv2f4MdMGWOzrIJ G1jDnp7yxG83XTB77HooBd8pj1DXFnHlOsQNax7eY08XATzldTmtPTs26zPGXzgiy0Mz qNMjVTPKt1EwXBmVdFMqJwU0Hi3WzmYliSNKgIFTflzD9qXlcsCQbN9DI90LX0j/d90o XtOjNQuQkTbxe0CH70hTFyO24aVCsu/CiMUIXLlZA1dstaOwJf3am2bgGgOOrjIMUJcm Q/jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=PRETZsLeKtd8er/vGZIvwJ67UbRQnpYPS7VnNd6iitc=; b=R8qfEHZ9hfzdYrbFxcGEyyjn4nyg0YlJ9SqUuU1YnCArJA/XpySwwrEWOteOOR2fqB FwmN+XJgIV0OEKytGHmkT65QKDqDrSR+ZdCuFVTK8bLijTExAWajh897A4lp4+AGlrAf 5OKwI9kfMFqn1cAYQ10hJk4bNBYZzTqYhyg/RiN8w5GCi6xtXh3NcRjproqvQQkkRNvk JyhIgBv9pIJTlYcA+v+Uufcw5E7nXAt5lS+MU1yOAIBHjzAh0jy5DlqzpA1YlnttNcid Sv7KFvYUAXW2RyrPBysE1wIE8aD2S1jRjcD1UslzkzsoUkeNSKvfEd8tzpC9dB1Z/RY+ UccQ== X-Gm-Message-State: ACrzQf2u41lsQPTqHltrSmZcBs7pWUpQupN4yAtamgCPD3slTBaR4Tgi oRwyS4vjNj4Jpqt+7Uoi+V8bqMqDTfc= X-Google-Smtp-Source: AMsMyM6VUn1IGxuterUYBQnBqfqJp+t0ecAEWvO8gXW0QL3/We8FwA+dhbmbRRZVNw5aXpi14wf65X3+jsg= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:686d:27b5:495:85b7]) (user=glider job=sendgmr) by 2002:a17:906:cc59:b0:779:f094:af3d with SMTP id mm25-20020a170906cc5900b00779f094af3dmr278250ejb.239.1663254346675; Thu, 15 Sep 2022 08:05:46 -0700 (PDT) Date: Thu, 15 Sep 2022 17:03:59 +0200 In-Reply-To: <20220915150417.722975-1-glider@google.com> Mime-Version: 1.0 References: <20220915150417.722975-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220915150417.722975-26-glider@google.com> Subject: [PATCH v7 25/43] 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 Biggers <ebiggers@kernel.org>, 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>, Stephen Rothwell <sfr@canb.auug.org.au>, 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=1663254347; 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=PRETZsLeKtd8er/vGZIvwJ67UbRQnpYPS7VnNd6iitc=; b=aca5gCy0MPGOc0vQIW21RgVwlP64h3kvWq9eAXcGqZKZUpxvUCYqLqN/ZDfE7+UA42dNp3 nQPuREP1TjqU0wI5QnPFMaIkcjNmfglXhJMUk/LrQa9VocqvzqVtAJXfmX26EC5IoPYz7f 04kACTT6ICUQHwu++09kF2b5m+fOVpE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="IWkX75T/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3Sj8jYwYKCHUZebWXkZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3Sj8jYwYKCHUZebWXkZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--glider.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663254347; a=rsa-sha256; cv=none; b=8T/Shl8zXJLIIPqXTP3u9/znl2hMcuxTVmsDC/N0TCgHNu0fjGEcP4TmAS+Bi0nlP0Nqof r9JrqglMYilbljpmHtc2pvJiu6nsyw4jjhmwXAEndexdnZDrq3hG9yEGPz5U4B+shlnkUw IFcAsjeRiAhZW8fqzxtg2DU1Q9IMOxg= Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="IWkX75T/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3Sj8jYwYKCHUZebWXkZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3Sj8jYwYKCHUZebWXkZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--glider.bounces.google.com X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: E218C1800A9 X-Stat-Signature: 8xgkwbd7cjmbxb9crr1mdecijctukr7m X-HE-Tag: 1663254347-263890 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(+)