From patchwork Tue Mar 29 12:40:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12794786 Return-Path: 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 ; 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 ; 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 ; 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 ; Tue, 29 Mar 2022 12:42:07 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id 13-20020a170906328d00b006982d0888a4so8050005ejw.9 for ; 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 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 , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org 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: 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 --- Link: https://linux-review.googlesource.com/id/Ie17f2ee47a7af58f5cdf716d585ebf0769348a5a --- kernel/kcov.c | 7 +++++++ 1 file changed, 7 insertions(+) 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 #include #include +#include #include #include #include @@ -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)