Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp241444ybf; Thu, 27 Feb 2020 20:12:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyoNzzWN3ryC4aVwJo8ydwd/acnbg9FLCbu6BlnLyw71XT1BALqFTs+GgFTcxh24wWtX+KT X-Received: by 2002:a05:6830:210d:: with SMTP id i13mr1816921otc.192.1582863164199; Thu, 27 Feb 2020 20:12:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582863164; cv=none; d=google.com; s=arc-20160816; b=NOgxGv7xqxr7VauQriYbC46hx1/MOV4I19qDNDvPddaZmAPvyjwhudxzc9rZYomkmJ BnF0IA/CoI0E18BUDgvQDpYbBJ6U+QC8sOabhYWrY0PUzBObMajcY8qvVRqsu6tVYsuL oa+HtuoqkHrTnsBhUIeNZkpMd1J20LqTbnBLlP+5VSdTryT6GUFBH4Dn/L9KOkKKtKOM I+wXTOFqm1mMSBFdd89VocF8iap+pHJmCFGjtmWDm9NC6pqizP3V/r25NMSstDQumzCL vnFkb1nQXlloTICuO7Zne6l64sTtSu64Pp6wnWqpfCZcTyxcLaF3r5P0Hlw28EcdLhQb nQPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=c/0BZmvFIWG/S0jY2dKBCKsq754S5g+ieeEgODnPeNg=; b=tu6PcjsHRmFl63VvPLhskEuXBc9OKD8furr66SbEI9DNqSb4oRHfeV7+v2EllE2Qov ToMejiEq435KB7cNnsXeR2WEffvYLJoNvQCA3oC83ypF+tbkmUIBNjfePYCRcNqVnDrc A9R+VUR8AX9P8/4NBhqvOFupqVpGc1MEsLnsq48rrYP1UCfsQ35v4gplk673FowCbyzP y/+qbXF/9fTs2PFQ096GYOc8F563CIpK3loJmTga8mqfoyEE7f+aUvF0te4yFVRSP04X MGSRYUtyuQyD6pMxInuM8R0vl/wolXcI0SjwzHNiRP/Zbknt66FewtYeIt3YeT6mqkIG bcRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si1046302oij.179.2020.02.27.20.12.32; Thu, 27 Feb 2020 20:12:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730893AbgB1ELZ (ORCPT + 99 others); Thu, 27 Feb 2020 23:11:25 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:54396 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730712AbgB1ELY (ORCPT ); Thu, 27 Feb 2020 23:11:24 -0500 Received: from callcc.thunk.org (guestnat-104-133-8-109.corp.google.com [104.133.8.109] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 01S4BEUH028088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Feb 2020 23:11:16 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 99EFC421A71; Thu, 27 Feb 2020 23:11:14 -0500 (EST) Date: Thu, 27 Feb 2020 23:11:14 -0500 From: "Theodore Y. Ts'o" To: Qian Cai Cc: elver@google.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] char/random: fix data races at timer_rand_state Message-ID: <20200228041114.GC101220@mit.edu> References: <1582648024-13111-1-git-send-email-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1582648024-13111-1-git-send-email-cai@lca.pw> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 25, 2020 at 11:27:04AM -0500, Qian Cai wrote: > Fields in "struct timer_rand_state" could be accessed concurrently. > Lockless plain reads and writes result in data races. Fix them by adding > pairs of READ|WRITE_ONCE(). The data races were reported by KCSAN, > > BUG: KCSAN: data-race in add_timer_randomness / add_timer_randomness > > write to 0xffff9f320a0a01d0 of 8 bytes by interrupt on cpu 22: > add_timer_randomness+0x100/0x190 > add_timer_randomness at drivers/char/random.c:1152 > add_disk_randomness+0x85/0x280 > scsi_end_request+0x43a/0x4a0 > scsi_io_completion+0xb7/0x7e0 > scsi_finish_command+0x1ed/0x2a0 > scsi_softirq_done+0x1c9/0x1d0 > blk_done_softirq+0x181/0x1d0 > __do_softirq+0xd9/0x57c > irq_exit+0xa2/0xc0 > do_IRQ+0x8b/0x190 > ret_from_intr+0x0/0x42 > cpuidle_enter_state+0x15e/0x980 > cpuidle_enter+0x69/0xc0 > call_cpuidle+0x23/0x40 > do_idle+0x248/0x280 > cpu_startup_entry+0x1d/0x1f > start_secondary+0x1b2/0x230 > secondary_startup_64+0xb6/0xc0 > > no locks held by swapper/22/0. > irq event stamp: 32871382 > _raw_spin_unlock_irqrestore+0x53/0x60 > _raw_spin_lock_irqsave+0x21/0x60 > _local_bh_enable+0x21/0x30 > irq_exit+0xa2/0xc0 > > read to 0xffff9f320a0a01d0 of 8 bytes by interrupt on cpu 2: > add_timer_randomness+0xe8/0x190 > add_disk_randomness+0x85/0x280 > scsi_end_request+0x43a/0x4a0 > scsi_io_completion+0xb7/0x7e0 > scsi_finish_command+0x1ed/0x2a0 > scsi_softirq_done+0x1c9/0x1d0 > blk_done_softirq+0x181/0x1d0 > __do_softirq+0xd9/0x57c > irq_exit+0xa2/0xc0 > do_IRQ+0x8b/0x190 > ret_from_intr+0x0/0x42 > cpuidle_enter_state+0x15e/0x980 > cpuidle_enter+0x69/0xc0 > call_cpuidle+0x23/0x40 > do_idle+0x248/0x280 > cpu_startup_entry+0x1d/0x1f > start_secondary+0x1b2/0x230 > secondary_startup_64+0xb6/0xc0 > > no locks held by swapper/2/0. > irq event stamp: 37846304 > _raw_spin_unlock_irqrestore+0x53/0x60 > _raw_spin_lock_irqsave+0x21/0x60 > _local_bh_enable+0x21/0x30 > irq_exit+0xa2/0xc0 > > Reported by Kernel Concurrency Sanitizer on: > Hardware name: HP ProLiant BL660c Gen9, BIOS I38 10/17/2018 > > Signed-off-by: Qian Cai Thanks, applied. - Ted