Message ID | 20220329124017.737571-37-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 46DA0C433EF for <linux-mm@archiver.kernel.org>; Tue, 29 Mar 2022 12:42:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCCA98D000E; Tue, 29 Mar 2022 08:42:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7BAB8D000A; Tue, 29 Mar 2022 08:42:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C95128D000E; Tue, 29 Mar 2022 08:42:07 -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 B97068D000A for <linux-mm@kvack.org>; Tue, 29 Mar 2022 08:42:07 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 9809460C90 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:42:07 +0000 (UTC) X-FDA: 79297386294.03.1674AB3 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) by imf05.hostedemail.com (Postfix) with ESMTP id 32E2D100004 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:42:07 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id 13-20020a170906328d00b006982d0888a4so8050005ejw.9 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 05:42:06 -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=XAH4acQx+nIWehlAydXzel6kNYbNIXLv2CmwLsxzisk=; b=YpPQVEPURN2ajRY1n46PwqwFtWp7RlcVqb0MoMfwIeS/m0CwFkAlmK9veRToXX/Nh0 b6E4uZScKbMj2h/RFOMhq1XJYUrJq4RW8RMzRp9Z6yBNz7KYsvHe+FzobtEv1SE+z8z0 bBRHxkEnq08sMogy1ImUi3Oswt0oie9fh2FqU81kZAPoJIolXyiL4DuviryqlAYyJ0cl fP2//D93tGjpn2gvBqCfUGSh263yJnEsQm+Ik3DPQuyteuBuA1cheprPsGBkm0p9BeA1 Z+owbpU+GHDWSgeR7eKuS6SEv9VgACxZntokNlAC2HOBzVv0eGiDKuMeIWei48sQH+i1 OfdQ== 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=XAH4acQx+nIWehlAydXzel6kNYbNIXLv2CmwLsxzisk=; b=PyqIDb/FvWtjJ8Afmo46EbxFaHcsolBXwr2LA+lhL2suGQuw3YI7Dyz8JvY9z+skji YwVEr6eCJJU3xKtN+3/QRqb2v3vCiruMtCx5CFEBnuVAG2JzZffAw0LqyONVVilPNYYd 06GUByFBoi6eGel0dFd0XArFCaqJOrAUbY1hdPVvJs1TxnqXmz0bMKHo5daQTVOJ7aMG 25vA5ggGNcXvL5FtcVJH/PJLXhNZPhvp0YTly8SdbtPGxBQ+kRNK8YVnA9eKQ4/8559N bLrphQeuZfz0XQvFWLPpyn0sgZh1pvr+tp6/8T3BdfyGzPIX7TLf9SwAioktZ3XCzz64 aO0g== X-Gm-Message-State: AOAM531RUGzxfNA3eWiA3M6hwnCzInKVfkFZir5WAMcMkzs/6es5gBk1 duZWyuQeQ/HVsvSnizcXKuEPIFMVglI= X-Google-Smtp-Source: ABdhPJw8wyFM62Ut2Sf7rG+vUT6fWVoAt6oG05coCAtugWeflqaBDOLOCgDn81VaIvvOcjBAOP8lwoc0QHY= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:36eb:759:798f:98c3]) (user=glider job=sendgmr) by 2002:a17:906:4313:b0:6b8:b3e5:a46 with SMTP id j19-20020a170906431300b006b8b3e50a46mr33446870ejm.417.1648557725791; Tue, 29 Mar 2022 05:42:05 -0700 (PDT) Date: Tue, 29 Mar 2022 14:40:05 +0200 In-Reply-To: <20220329124017.737571-1-glider@google.com> Message-Id: <20220329124017.737571-37-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 36/48] kmsan: kcov: unpoison area->list in kcov_remote_area_put() 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-Stat-Signature: np3zmuxb5r86npa7wpsg5h78ecwqw4mo Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=YpPQVEPU; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3nf5CYgYKCL4kpmhivksskpi.gsqpmry1-qqozego.svk@flex--glider.bounces.google.com designates 209.85.218.74 as permitted sender) smtp.mailfrom=3nf5CYgYKCL4kpmhivksskpi.gsqpmry1-qqozego.svk@flex--glider.bounces.google.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 32E2D100004 X-HE-Tag: 1648557727-215411 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/kernel/kcov.c b/kernel/kcov.c index 36ca640c4f8e7..88ffdddc99ba1 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -11,6 +11,7 @@ #include <linux/fs.h> #include <linux/hashtable.h> #include <linux/init.h> +#include <linux/kmsan-checks.h> #include <linux/mm.h> #include <linux/preempt.h> #include <linux/printk.h> @@ -152,6 +153,12 @@ static void kcov_remote_area_put(struct kcov_remote_area *area, INIT_LIST_HEAD(&area->list); area->size = size; list_add(&area->list, &kcov_remote_areas); + /* + * KMSAN doesn't instrument this file, so it may not know area->list + * is initialized. Unpoison it explicitly to avoid reports in + * kcov_remote_area_get(). + */ + kmsan_unpoison_memory(&area->list, sizeof(struct list_head)); } static notrace bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t)
KMSAN does not instrument kernel/kcov.c for performance reasons (with CONFIG_KCOV=y virtually every place in the kernel invokes kcov instrumentation). Therefore the tool may miss writes from kcov.c that initialize memory. When CONFIG_DEBUG_LIST is enabled, list pointers from kernel/kcov.c are passed to instrumented helpers in lib/list_debug.c, resulting in false positives. To work around these reports, we unpoison the contents of area->list after initializing it. Signed-off-by: Alexander Potapenko <glider@google.com> --- Link: https://linux-review.googlesource.com/id/Ie17f2ee47a7af58f5cdf716d585ebf0769348a5a --- kernel/kcov.c | 7 +++++++ 1 file changed, 7 insertions(+)