Message ID | 20220905122452.2258262-31-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 79D79ECAAD3 for <linux-mm@archiver.kernel.org>; Mon, 5 Sep 2022 12:26:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 129408D0085; Mon, 5 Sep 2022 08:26:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 089C08D0076; Mon, 5 Sep 2022 08:26:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6B1F8D0085; Mon, 5 Sep 2022 08:26:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D5EF18D0076 for <linux-mm@kvack.org>; Mon, 5 Sep 2022 08:26:21 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BE72D407AC for <linux-mm@kvack.org>; Mon, 5 Sep 2022 12:26:21 +0000 (UTC) X-FDA: 79877954562.08.979B048 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf16.hostedemail.com (Postfix) with ESMTP id 6AF3C180068 for <linux-mm@kvack.org>; Mon, 5 Sep 2022 12:26:21 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id e15-20020adf9bcf000000b002285faa9bd4so740156wrc.8 for <linux-mm@kvack.org>; Mon, 05 Sep 2022 05:26:21 -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=TqyxH/L5MkAtosS0jWqWllGGzUIesiLdVg3wG3p7XtY=; b=SRHbIOUb4DGUSlckCuBIb5D5nY2hugScbD5wJSkj9+gz5MDYNGyreOoUjr426hDozZ eIZwnOJAR9QbuL6MBljpr+ef5VyWMq7LE+MGIMu63m/ooGwVOtY9Wymo4x+ItRsbPuMF 3x3WktXqUtSalOy5ST4UA3C+QVvz/PUjD2mQzbD9n6SlVfmNFgRe+dRr3wA+uShralze F5IELO9fjYSA2cgSGi/7JeC9JLPRXPbVVnHX/AfgjNsTAchbmP+32JYRVNVmU8xLiZ/2 5IjHNbRGxFz5C2uzmzWFN1Wc7yPI/jBEojh1hnBnCwk9zy4n2ozIysDaR+/OsHRccZvb k9Lg== 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=TqyxH/L5MkAtosS0jWqWllGGzUIesiLdVg3wG3p7XtY=; b=V/tkXZI/8nUM1B3wwXUgSw+6q3oEN1ncnz/rKfDqArPQ+BSZjaePS9C5uIsfUgXGgf gUGyLYrTIeof5aOMjZA/rK4vLHw+zVbFLpBgD7POYmfdJsWMIJbo4OrdMFQmEOQAC9Xd kdBkIBvFOVwsoFC33PbnnuB0LfsYwHHVRiagwxjtBsHFabPV1zC755GgDbCGzgmWwgZW Vom9rUmsYXJPPHUk63FHuN1GfqHWYDYwZycXVngAuIwAV2OfMSz7NWwOhuhi5+IyOLn/ pG9/im8ek5sWntRicPuAjIzAT9/9sPT0WCQiZiUDJKdzMe63K74iSg9L/qDscno3zLTV TlJA== X-Gm-Message-State: ACgBeo3mzZeodSvuNPeEMPfyu7xsHNmpESZa4qzVmrwAHcMqQ+t+QiYV fTdGxhUk3ZYUIZSfPkeTOrqW3PvDcXc= X-Google-Smtp-Source: AA6agR7gpIA9Ys+R+97x8E6SItr56wFcMnWLG4Y2aVvt4HKxaJejCTap6PHw9s2SK+DWSs3ZsGMtcLcy1oM= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:b808:8d07:ab4a:554c]) (user=glider job=sendgmr) by 2002:a5d:584b:0:b0:220:7624:5aae with SMTP id i11-20020a5d584b000000b0022076245aaemr24101908wrf.119.1662380780114; Mon, 05 Sep 2022 05:26:20 -0700 (PDT) Date: Mon, 5 Sep 2022 14:24:38 +0200 In-Reply-To: <20220905122452.2258262-1-glider@google.com> Mime-Version: 1.0 References: <20220905122452.2258262-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220905122452.2258262-31-glider@google.com> Subject: [PATCH v6 30/44] kcov: kmsan: 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>, 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=1662380781; 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=TqyxH/L5MkAtosS0jWqWllGGzUIesiLdVg3wG3p7XtY=; b=dQsGTi5ccHX98RVVyya9b0r45DZlGsj2a47s9gepvtsXSHStr/uH3IO4okJ16MqPbTmOfG an5PiJ0cMi6xOdLK+ltxoPO3uLx8ZUyOqqEe9z0pKpSCNUGTvXSJByfEMQ/AFAvCevFOlV f6Fe0MQn8Y1pIQZxvnV3lkBsXYyzmzw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=SRHbIOUb; spf=pass (imf16.hostedemail.com: domain of 37OoVYwYKCDkbgdYZmbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--glider.bounces.google.com designates 209.85.221.74 as permitted sender) smtp.mailfrom=37OoVYwYKCDkbgdYZmbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662380781; a=rsa-sha256; cv=none; b=UbR+d6ny0RcKwGpj/wAHRnmerOMFRGiCg92T93EuY1xGnQx9p8AMxqUq1jBMVTd3GATAPT nvYO65SWmZPsqDS5vvZQdYKoKn9jCrt3wSSnXuEPFFg24rD+k0csKc6G2pN2bP+h00RDhT 6dnBLg709012EMLHEayAzwzNzG525kE= X-Rspam-User: X-Stat-Signature: 5mg6cf8dwi5kq4wehs1inspcf7743y4w X-Rspamd-Queue-Id: 6AF3C180068 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=SRHbIOUb; spf=pass (imf16.hostedemail.com: domain of 37OoVYwYKCDkbgdYZmbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--glider.bounces.google.com designates 209.85.221.74 as permitted sender) smtp.mailfrom=37OoVYwYKCDkbgdYZmbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam04 X-HE-Tag: 1662380781-611030 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 e19c84b02452e..e5cd09fd8a050 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(area->list)); } 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> --- v4: -- change sizeof(type) to sizeof(*ptr) -- swap kcov: and kmsan: in the subject Link: https://linux-review.googlesource.com/id/Ie17f2ee47a7af58f5cdf716d585ebf0769348a5a --- kernel/kcov.c | 7 +++++++ 1 file changed, 7 insertions(+)