Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3842390ybv; Mon, 10 Feb 2020 07:23:24 -0800 (PST) X-Google-Smtp-Source: APXvYqx5jBoD4fnNeMlydbeQNkYtiMivB1q10faRcjpS7kQLmPOCGeYL4rxzrOKGTlSAu0Qbhc7Q X-Received: by 2002:a05:6830:1db3:: with SMTP id z19mr1494249oti.292.1581348204229; Mon, 10 Feb 2020 07:23:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581348204; cv=none; d=google.com; s=arc-20160816; b=SRpUak8M0OdQQ/MW9EmA3cFoX/NCog3V1Z5z/Q4flCMxC0qNHOAHQzKIVJAPCdOiZP RHD3gA64HA8d68+DCYZoYGJlqt3pWUCn7QPDTMADvaCWkDdZeURiXINsiG9tb1cQKD6Z 92sjDI0qb2hNViQoVpOzcecWZDYiW0j6BpZk3WdT2ZDhzAYEA3+n9INWntr7b8xXFBob Zp/5tUyqkiqxkgy29vudr+Rdf25oKfufzEJGwgGoiwHp6meT++3G1KsH84T3H0ztduM4 5yGBqjjShuSE7R1CBrwI5lK9brjIvcaHwtjTyBkYXlYtBAsdBQfy+Pp3oMaT9se9rYk0 A8Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=wL77na+4Tr8fLRCxWeTcL2vUCczRx43y4v3artlyPL4=; b=u4TI1EEKHuCYxqLafgGGYWQu38N9iFRF9Dr0Bl0pX201XDA3lqgi51mW7dgViYMVTb DgdJWKSAPLPVIcjHAN5nfVlBSf3hIpNlcLGN0EThd4m0UKia/379cLyi6V/nk008mARi XVvW22/ccJ/Yb6FQMB1ORp354PFR/26du1Mjogo2NsfBI0fHiKVZXIOhNOusFUadfbOb hx2BvWNW+IjmKMDjgdbsylEi4qscj2s4oxAAcC51m6YyLKejVXJ6bNy0cMw8hHcgzcZz khEm5JyJJZ/Qgh4UAHnWOMCUt22XK4iqZC9DfXteJIoA0nlEWtttGZlATqnZGnjEI7sA UM6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p542MkWc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h28si354317otg.63.2020.02.10.07.23.11; Mon, 10 Feb 2020 07:23:24 -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; dkim=pass header.i=@kernel.org header.s=default header.b=p542MkWc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729364AbgBJPV6 (ORCPT + 99 others); Mon, 10 Feb 2020 10:21:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:43870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727363AbgBJPV5 (ORCPT ); Mon, 10 Feb 2020 10:21:57 -0500 Received: from paulmck-ThinkPad-P72.home (unknown [193.85.242.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5DB872082F; Mon, 10 Feb 2020 15:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581348117; bh=H/nYGXOoJ9XQc05LV8U38gSp+jP0pv2BrR9tJM36noo=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=p542MkWc8cSnDtsdb7NqIlx70Z1Q/+ToiQ04R/WRnYkYzb6IHv3jkxy9JlpPcgf7j R48UtIp1EjDJ8Fb3qDXCJ+WyRqRDIyECqrTzmrhbZHXpU3hj5yI5l5NiWVvij7CFcS 54eYPatRAy+21UOaFYd1xJQn7QXi2KSi/u8jIVz4= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 11DD33522700; Mon, 10 Feb 2020 07:21:54 -0800 (PST) Date: Mon, 10 Feb 2020 07:21:54 -0800 From: "Paul E. McKenney" To: Marco Elver Cc: andreyknvl@google.com, glider@google.com, dvyukov@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kcsan: Fix misreporting if concurrent races on same address Message-ID: <20200210152154.GY2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200210145639.169712-1-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200210145639.169712-1-elver@google.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 10, 2020 at 03:56:39PM +0100, Marco Elver wrote: > If there are more than 3 threads racing on the same address, it can > happen that 'other_info' is populated not by the thread that consumed > the calling thread's watchpoint but by one of the others. > > To avoid deadlock, we have to consume 'other_info' regardless. In case > we observe that we only have information about readers, we discard the > 'other_info' and skip the report. > > Signed-off-by: Marco Elver Queued for testing and review, thank you!!! Thanx, Paul > --- > kernel/kcsan/report.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/kernel/kcsan/report.c b/kernel/kcsan/report.c > index 3bc590e6be7e3..e046dd26a2459 100644 > --- a/kernel/kcsan/report.c > +++ b/kernel/kcsan/report.c > @@ -422,6 +422,26 @@ static bool prepare_report(unsigned long *flags, const volatile void *ptr, > return false; > } > > + access_type |= other_info.access_type; > + if ((access_type & KCSAN_ACCESS_WRITE) == 0) { > + /* > + * This is not the other_info from the thread that > + * consumed our watchpoint. > + * > + * There are concurrent races between more than 3 > + * threads on the same address. The thread that set up > + * the watchpoint here was a read, as well as the one > + * that is currently in other_info. > + * > + * It's fine if we simply omit this report, since the > + * chances of one of the other reports including the > + * same info is high, as well as the chances that we > + * simply re-report the race again. > + */ > + release_report(flags, KCSAN_REPORT_RACE_SIGNAL); > + return false; > + } > + > /* > * Matching & usable access in other_info: keep other_info_lock > * locked, as this thread consumes it to print the full report; > -- > 2.25.0.341.g760bfbb309-goog >