Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp24884pxb; Wed, 14 Apr 2021 08:36:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgAS+Ztnulm1S5M0ahvfubOjOYGIAbRAW777YNw73uiFKv0enHOFPT8oNNckk7aHFF2+rA X-Received: by 2002:a17:906:b0f:: with SMTP id u15mr22258269ejg.156.1618414597598; Wed, 14 Apr 2021 08:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618414597; cv=none; d=google.com; s=arc-20160816; b=sxEXm9VGSE5bxv4B+Nk8DWfzJIF8mNWu7ch19y8EG2F+7WtV/cyH2RxLqhaZYcwzYF O6DydWTK4YtMFEPceBjxT7LTLfJWX/SBoFla9wY2t6t3bse1+M+mjHarEXSqm/8fyO8w /Ew1vbvEYkATEaxVNvQcjY12F9LYURRTgxN5a18WzuiMHFVJ4pbotghsNEslOi7bFZ+R g4GcaMd7qU2R/TPvQdnAAyvNvyioGxU2JCl7keW70ff+KN7DH5FbDLj3Ip4H+AsDXsC0 4OMNOeILnxo1UQsolCJ1Y+ow3vTx6KfDXUuLXftI6K6A2hLVyGG+nz2U/NMdQt8fyBmd MAnw== 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=sgGFXp+rNeY0o6f3MUrh3kWdEuk4SzRpLTB8DWBZoJA=; b=X0HZ1eQxJY6QKwtyqkDELGk5PvBIKaZ2jIJ2VVuTtE0EHuWI+BoMnWaZs8p8jlUwsq ft5LvRdwhpAe83KcRPfbVfVHbMQapaIzkwgZoDv897qcndRz59kaz5xia8YXpqmWSRVM VcSEjjcMHGbaujpRro2/3R49Fk8yuhdFDoIJccx7IQ9FJ9f9GfVZ5MKSyUxa95s+CaZ9 wVI5AFu0pixDLazGdrM+6oPTPWtMsjcDGLdPjd7M7UvUgMCsV+V8G7ydPmd004Y/SFFX CqjmlONhiGVXnlTyQKjDMM0UP+8qR6IUp5ihBrKAKBSrY78bnQglneHrdI2AvB+J5tQr aRGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Mrg9DeYb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si11058315ejc.453.2021.04.14.08.36.12; Wed, 14 Apr 2021 08:36:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Mrg9DeYb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350651AbhDNLaM (ORCPT + 99 others); Wed, 14 Apr 2021 07:30:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350607AbhDNL31 (ORCPT ); Wed, 14 Apr 2021 07:29:27 -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 50B8BC061574 for ; Wed, 14 Apr 2021 04:29:05 -0700 (PDT) Received: by mail-wm1-x349.google.com with SMTP id v65-20020a1cde440000b029012853a35ee7so2384939wmg.2 for ; Wed, 14 Apr 2021 04:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sgGFXp+rNeY0o6f3MUrh3kWdEuk4SzRpLTB8DWBZoJA=; b=Mrg9DeYbsVFmqByT7WSz/VKUGSLUGKubp3ngSi2EXnW85azU37YqyHrgAp4XEg7t6p B8/d3PnRVCjAr9dDtSGNtdAtDzAP32wWT2ZRXFPc6JJy2AohrbSbLXTMmeiXsgpkE8D5 Z86QdRaeYlDdc12oyGvuUNi8Jklf8ODdj3BzNxAwPcUuhyrkUGAR/4kczsdIwwz1UKUa tEVDSv3XyrR0dhCsk8TbCWrhSPJUDqRAm1xbYtIhW016fsZFO0nzZStMHhQAJcId7GAm yI5Nk80b683NXKuuG13xIgV+6fAWG/mWNibqEEotlUAXAPJp4Prinw6gGwQvgtc1kFfi gDuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sgGFXp+rNeY0o6f3MUrh3kWdEuk4SzRpLTB8DWBZoJA=; b=BDihkvxZck59FpinxWeKlD6Du/6c1n4Ng5LrO9hzFVSm9MzlpfcYIg3DWXV/J9Nrlf kvKr1mH9MWkm5u3MI6RMUe3NHBWleyeFDspQ2Vtzd2O/irq023E4ym5sSE5PdujJja9n jnhJIxVbJhuiADs2P780MCQilWvxOx8Cik4ZDOfLqp0936ufpejOE0t9nnKjc/2q1cq/ 7m4/PlCWOVEBOeCDOExhm8jWLbwRy3XD6ocZqTtfXY7SG06phjXR5oMkmhncHy5TS3qW I8zH2+SlkBBAAsHaF/5TeEaBYTlPLE/15G2VBHu1QTtvufdcBMicXw7Q3vhpQ4JxeQzf dSAw== X-Gm-Message-State: AOAM533wN2U54uBPfIBeLIMPSNRDnzaQ2522Jaau4aEC8nmMeKzLBlJ1 cxDvIgkRPuOs6P32nmW7iXEaWeNO4A== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:4051:8ddb:9de4:c1bb]) (user=elver job=sendgmr) by 2002:a1c:f618:: with SMTP id w24mr2517462wmc.93.1618399744094; Wed, 14 Apr 2021 04:29:04 -0700 (PDT) Date: Wed, 14 Apr 2021 13:28:25 +0200 In-Reply-To: <20210414112825.3008667-1-elver@google.com> Message-Id: <20210414112825.3008667-10-elver@google.com> Mime-Version: 1.0 References: <20210414112825.3008667-1-elver@google.com> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog Subject: [PATCH 9/9] kcsan: Document "value changed" line From: Marco Elver To: elver@google.com, paulmck@kernel.org Cc: mark.rutland@arm.com, will@kernel.org, dvyukov@google.com, glider@google.com, boqun.feng@gmail.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the example reports based on the latest reports generated by kcsan_test module, which now include the "value changed" line. Add a brief description of the "value changed" line. Signed-off-by: Marco Elver --- Documentation/dev-tools/kcsan.rst | 88 ++++++++++++------------------- 1 file changed, 35 insertions(+), 53 deletions(-) diff --git a/Documentation/dev-tools/kcsan.rst b/Documentation/dev-tools/kcsan.rst index d85ce238ace7..ba059df10b7d 100644 --- a/Documentation/dev-tools/kcsan.rst +++ b/Documentation/dev-tools/kcsan.rst @@ -27,75 +27,57 @@ Error reports A typical data race report looks like this:: ================================================================== - BUG: KCSAN: data-race in generic_permission / kernfs_refresh_inode - - write to 0xffff8fee4c40700c of 4 bytes by task 175 on cpu 4: - kernfs_refresh_inode+0x70/0x170 - kernfs_iop_permission+0x4f/0x90 - inode_permission+0x190/0x200 - link_path_walk.part.0+0x503/0x8e0 - path_lookupat.isra.0+0x69/0x4d0 - filename_lookup+0x136/0x280 - user_path_at_empty+0x47/0x60 - vfs_statx+0x9b/0x130 - __do_sys_newlstat+0x50/0xb0 - __x64_sys_newlstat+0x37/0x50 - do_syscall_64+0x85/0x260 - entry_SYSCALL_64_after_hwframe+0x44/0xa9 - - read to 0xffff8fee4c40700c of 4 bytes by task 166 on cpu 6: - generic_permission+0x5b/0x2a0 - kernfs_iop_permission+0x66/0x90 - inode_permission+0x190/0x200 - link_path_walk.part.0+0x503/0x8e0 - path_lookupat.isra.0+0x69/0x4d0 - filename_lookup+0x136/0x280 - user_path_at_empty+0x47/0x60 - do_faccessat+0x11a/0x390 - __x64_sys_access+0x3c/0x50 - do_syscall_64+0x85/0x260 - entry_SYSCALL_64_after_hwframe+0x44/0xa9 + BUG: KCSAN: data-race in test_kernel_read / test_kernel_write + + write to 0xffffffffc009a628 of 8 bytes by task 487 on cpu 0: + test_kernel_write+0x1d/0x30 + access_thread+0x89/0xd0 + kthread+0x23e/0x260 + ret_from_fork+0x22/0x30 + + read to 0xffffffffc009a628 of 8 bytes by task 488 on cpu 6: + test_kernel_read+0x10/0x20 + access_thread+0x89/0xd0 + kthread+0x23e/0x260 + ret_from_fork+0x22/0x30 + + value changed: 0x00000000000009a6 -> 0x00000000000009b2 Reported by Kernel Concurrency Sanitizer on: - CPU: 6 PID: 166 Comm: systemd-journal Not tainted 5.3.0-rc7+ #1 - Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 + CPU: 6 PID: 488 Comm: access_thread Not tainted 5.12.0-rc2+ #1 + Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 ================================================================== The header of the report provides a short summary of the functions involved in the race. It is followed by the access types and stack traces of the 2 threads -involved in the data race. +involved in the data race. If KCSAN also observed a value change, the observed +old value and new value are shown on the "value changed" line respectively. The other less common type of data race report looks like this:: ================================================================== - BUG: KCSAN: data-race in e1000_clean_rx_irq+0x551/0xb10 - - race at unknown origin, with read to 0xffff933db8a2ae6c of 1 bytes by interrupt on cpu 0: - e1000_clean_rx_irq+0x551/0xb10 - e1000_clean+0x533/0xda0 - net_rx_action+0x329/0x900 - __do_softirq+0xdb/0x2db - irq_exit+0x9b/0xa0 - do_IRQ+0x9c/0xf0 - ret_from_intr+0x0/0x18 - default_idle+0x3f/0x220 - arch_cpu_idle+0x21/0x30 - do_idle+0x1df/0x230 - cpu_startup_entry+0x14/0x20 - rest_init+0xc5/0xcb - arch_call_rest_init+0x13/0x2b - start_kernel+0x6db/0x700 + BUG: KCSAN: data-race in test_kernel_rmw_array+0x71/0xd0 + + race at unknown origin, with read to 0xffffffffc009bdb0 of 8 bytes by task 515 on cpu 2: + test_kernel_rmw_array+0x71/0xd0 + access_thread+0x89/0xd0 + kthread+0x23e/0x260 + ret_from_fork+0x22/0x30 + + value changed: 0x0000000000002328 -> 0x0000000000002329 Reported by Kernel Concurrency Sanitizer on: - CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.3.0-rc7+ #2 - Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 + CPU: 2 PID: 515 Comm: access_thread Not tainted 5.12.0-rc2+ #1 + Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 ================================================================== This report is generated where it was not possible to determine the other racing thread, but a race was inferred due to the data value of the watched -memory location having changed. These can occur either due to missing -instrumentation or e.g. DMA accesses. These reports will only be generated if -``CONFIG_KCSAN_REPORT_RACE_UNKNOWN_ORIGIN=y`` (selected by default). +memory location having changed. These reports always show a "value changed" +line. A common reason for reports of this type are missing instrumentation in +the racing thread, but could also occur due to e.g. DMA accesses. Such reports +are shown only if ``CONFIG_KCSAN_REPORT_RACE_UNKNOWN_ORIGIN=y``, which is +enabled by default. Selective analysis ~~~~~~~~~~~~~~~~~~ -- 2.31.1.295.g9ea45b61b8-goog