Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4447993ioa; Wed, 27 Apr 2022 04:12:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw84PdNwNkNWz77nBnOv8B7/8iwSIGCPTvjMk1zUf4D031UrFmkKn1LRpku3OiL9H2cyiXC X-Received: by 2002:a63:85c6:0:b0:3ab:4545:e29e with SMTP id u189-20020a6385c6000000b003ab4545e29emr12408080pgd.573.1651057965617; Wed, 27 Apr 2022 04:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651057965; cv=none; d=google.com; s=arc-20160816; b=GqchgkWCquiQDKsaZxazg1qlJR8QzLGj1AKCcj7IsvACf9OwwT0Se9ujg0ZSIM9EeC XDzryYrQ9CHwxVetQDaG3Dyvv4SROG716660BS7Xzs1Mb6Zjr9Sh3oscSfQxn4WgNDLS REtZSt72BMw7jkclAvfPGuwJWCRNPWRAzUFesvK9Kk17NEu1Jx1EyjLHM/1oCbJvLboP VH89xo284qlou0NKLWCWdXtmm4Qgh1T84W6yh1P0vGigQ/uDw8ehp16+Miz+8xomp4mL EeRF3iJ2iALak3wl4/dh4adoi++61ONKqasFii+Qh3DNGy0Yiky0g4UKPbeip2+nz60I L6RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=KHDnEJZlYbtguNecmw4Z0aoQP18cjcWXna880BlF2jg=; b=VwbivEZgW3tHEwelztqjQUoAqHD4sdrplZezyj0rw4lSYYqwpzwQ5O5BxuOv+ayLk4 I8vT4WqGWcJFOxsqj9084Wpz0npJdZd50Szl5FXp8XTYFfiwMXivMPhlIKaEVcbylTxY MuM7qz0aEcQ3ily+WH1YjxyResHDvzTBzaq9/8iBknADaGrmTzCY1BqTDl4LRs3/tlLh +mEFOqDVg8M11I3Ji09Eqk/Pb+nQ020tcW9qMdXZpFVxJzJ1Dkj3+fiGp14CU/ghYFox Gq8HaBtAzdomG3SUMbD2EVnALFQXgCjGot6hmnww3clh2sw3uxxwZKLl056kJIHJU1e6 8BUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Ras6zX6z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bj10-20020a170902850a00b00158b60545dcsi1285941plb.207.2022.04.27.04.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:12:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Ras6zX6z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CCDAF43234A; Wed, 27 Apr 2022 03:06:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353510AbiDZQwr (ORCPT + 99 others); Tue, 26 Apr 2022 12:52:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353350AbiDZQu6 (ORCPT ); Tue, 26 Apr 2022 12:50:58 -0400 Received: from mail-wm1-x349.google.com (mail-wm1-x349.google.com [IPv6:2a00:1450:4864:20::349]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0580148321 for ; Tue, 26 Apr 2022 09:45:50 -0700 (PDT) Received: by mail-wm1-x349.google.com with SMTP id n25-20020a05600c3b9900b0038ff033b654so4011471wms.0 for ; Tue, 26 Apr 2022 09:45:49 -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=KHDnEJZlYbtguNecmw4Z0aoQP18cjcWXna880BlF2jg=; b=Ras6zX6zLyLhsIDtzjqqN9y4Bp5f6rPNvg/NlhbZeOJcSZ0W0h6WszebH9Jl+tDnIj 1d8SC1JokEP9rj0/Uz/B0C8vgBdM75W2cOctkHAhkLUnzcLWel+aJ8n1Z2d27uToZyPD NXcsYuwWmfXUsoUSNdeFpNkCp8Mdmw2X2PM8Z0Xq3w/pvHZee2tgfSDClqP6w/GG0G6Z Mkg5MkTefNZEIo51rh3WSUC/xRWyYaKD3+5kRfKXRqTWJTGdKD34V/dogH3TIl3qdspb r/9R17wsy7X98UcL39rrXIx8RR/Zx48ZWvJVe4g3RHHZ1p7AGTIwvBiDniEVZixdJ1br ihtw== 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=KHDnEJZlYbtguNecmw4Z0aoQP18cjcWXna880BlF2jg=; b=j4qzgF48585Hids6yZc0joP9EM8ittLJyEKvWxGkpM5AkXfMGykvnBGp5i6UdkytQn UxGoVTKJVMs6ZaIf55tyqpSCsSEjiCy4xLriIuvZs3/Q+v6yd6X+YcJRKMzfF1xugkZ1 i6oIXRBeEUceTjfdC8DsV8BYVV6wn0B9rLc8SeVuWEfuA0dkU9oLnu6iqiFiDcsJfZm5 a90gNjE5JC56aP2vU0xi4a+qp4QFuCd9EGNYgF97d2ahAX0GhKVESfLJ55OnXcEh7ZpP 2gvWV+ICqV/rdIpfBONDNoquU37GKY1d2obWh6hMC7UHPmSaNyjHI70aLnK6j5Ikf59k z28A== X-Gm-Message-State: AOAM533zprVr2AqCGswieIKeRyqMm4C278ymkJE+euaLGaHAc45LaOvc y7vKeMdSxSyrNl5cGS0oTn2U/iDYYOk= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:d580:abeb:bf6d:5726]) (user=glider job=sendgmr) by 2002:adf:e289:0:b0:1e3:14ad:75fe with SMTP id v9-20020adfe289000000b001e314ad75femr18987161wri.685.1650991548482; Tue, 26 Apr 2022 09:45:48 -0700 (PDT) Date: Tue, 26 Apr 2022 18:43:03 +0200 In-Reply-To: <20220426164315.625149-1-glider@google.com> Message-Id: <20220426164315.625149-35-glider@google.com> Mime-Version: 1.0 References: <20220426164315.625149-1-glider@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v3 34/46] 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 , 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" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 b3732b2105930..9e38209a7e0a9 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) -- 2.36.0.rc2.479.g8af0fa9b8e-goog