Message ID | 20220701142310.2188015-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 970B2C43334 for <linux-mm@archiver.kernel.org>; Fri, 1 Jul 2022 14:24:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33ACC6B0083; Fri, 1 Jul 2022 10:24:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EA8C6B0085; Fri, 1 Jul 2022 10:24:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B2AF6B0087; Fri, 1 Jul 2022 10:24:41 -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 0C45C6B0083 for <linux-mm@kvack.org>; Fri, 1 Jul 2022 10:24:41 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D716633B75 for <linux-mm@kvack.org>; Fri, 1 Jul 2022 14:24:40 +0000 (UTC) X-FDA: 79638751920.14.91E4D69 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) by imf25.hostedemail.com (Postfix) with ESMTP id 61CD2A0041 for <linux-mm@kvack.org>; Fri, 1 Jul 2022 14:24:40 +0000 (UTC) Received: by mail-ej1-f73.google.com with SMTP id 7-20020a170906310700b007263068d531so845864ejx.15 for <linux-mm@kvack.org>; Fri, 01 Jul 2022 07:24:40 -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=5N9rqr7HITf8FFSE4yH2hCrYnonc5u0Mk2BxyWMh4Wc=; b=ReMSGptb1gOevOQA5KIOUI2r4Y7KHZlx+U+473Qz+0IYhBm7Zh60skPZL94IWrvGHe OD/b/T8E/9DRBnHYkCik0EMtmERYvMYLmNm2a9PZ3CXqtQvv3NgmYs9l7lSp7JKC2JNu asOUoRmUrLf+MBvhhA5FucNbpwjzToLRIKdYTiOAjk7d5eN8Pd3e+soWyP6PDlWUzRey 6eKr6HZEm15XrcXNJMk7zw70qhG9SX/ZUCNS5t5YyEGHANeY85at4PO2xF7Ipa5N6imk 72H7eRaKJCimZpAza45clzrOO1tWWs5oG5q/zZogSjW/5CpnZ1YyjjTkf+gFTDMx7GOA kGOg== 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=5N9rqr7HITf8FFSE4yH2hCrYnonc5u0Mk2BxyWMh4Wc=; b=ogso0OTqO5CccEP/taL5MPJ5T+lFgbP3ZfPG+TEDlgiM8k18sqxoIW+0/OwETPg/cb cH8MY70zG5GpsX1oyN4toolEgmBK/QwTtmWzFCq5b8i6P4uuvxShAd7oAP2ygMo2IJ5g JnO0MA+ztzPjp1rJIB2ibkVTVx8+egho9Vut25HA4BBurw05Bk5j4C5Y/EbapWVdEVEV KJFAegA/7xo0My6hFAjclXki3MiwB8Gjxn1QPpVWshFaF8eXVUOvczR3itcNFF92k/0u QCO1MzkQzDJfOUB9mGUDyEqQ3E4oOMn1BdtONmuU6ssF99+TyrPQpDjaGQqst9wd2boo SmGQ== X-Gm-Message-State: AJIora8o7/G8ict8WPoLrHKMLzzDMXUwT1Q3Qe/M9deKUOFBJKpMswnI CI4XmlchfR/hHO7Xng0eEqQwXq+hpJg= X-Google-Smtp-Source: AGRyM1uKM3hcXWEB+X983N8ZUuPx4ycBhxuOiVX+On/gdGCeZVb6tOlhn3CoZm88ilqSQUTNpJWyQUtAfdc= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:a6f5:f713:759c:abb6]) (user=glider job=sendgmr) by 2002:a17:906:8501:b0:711:bf65:2a47 with SMTP id i1-20020a170906850100b00711bf652a47mr14797955ejx.150.1656685479201; Fri, 01 Jul 2022 07:24:39 -0700 (PDT) Date: Fri, 1 Jul 2022 16:22:55 +0200 In-Reply-To: <20220701142310.2188015-1-glider@google.com> Message-Id: <20220701142310.2188015-31-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 30/45] 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656685480; a=rsa-sha256; cv=none; b=TeJWEqnl8nrIdRo8bNOvMriz4B0MGHUNlktyT9CWTRaxnlirwINp/KRbQQdRVGvJ5B6UeT PFdGp7v7/Y0VMbmYlpfxBwsnHdPtsT2v1Wzo81/tE+TmmdWQtSJCkMKuJ6KAei+VDlWPac CsOSpGCxAP7i85O1NTrx69OVIR52mmo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ReMSGptb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of 3pwO_YgYKCMYsxupq3s00sxq.o0yxuz69-yyw7mow.03s@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3pwO_YgYKCMYsxupq3s00sxq.o0yxuz69-yyw7mow.03s@flex--glider.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656685480; 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=5N9rqr7HITf8FFSE4yH2hCrYnonc5u0Mk2BxyWMh4Wc=; b=JXozZlBmCpeS9GFFh8bKOLCcq+DmBht33jMXbgXvUGgllptPWNVOhMo4S84bOlRZaxA7kz NShyAQPpPYg2Ighf7slAA5lYu0IqIXpxiCcDJenz0Wdb9nPoOE+y8tTcb1x+7aJueTKcHg TL2j9SUjwKoGDVyonq5zblBqbHJPC14= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 61CD2A0041 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ReMSGptb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of 3pwO_YgYKCMYsxupq3s00sxq.o0yxuz69-yyw7mow.03s@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3pwO_YgYKCMYsxupq3s00sxq.o0yxuz69-yyw7mow.03s@flex--glider.bounces.google.com X-Rspam-User: X-Stat-Signature: ke7n8w355r7e9wzufsterzkjc5immi3z X-HE-Tag: 1656685480-252209 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(+)