Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3101247ybl; Mon, 20 Jan 2020 16:03:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzVjoAi8E14IHRXVPBoz/Bk7MSFoAYhjvBDwGTSIFKndTIMtQ92/wU+Af3T/yGqqd5GBUwN X-Received: by 2002:a9d:461b:: with SMTP id y27mr1686825ote.280.1579564990309; Mon, 20 Jan 2020 16:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579564990; cv=none; d=google.com; s=arc-20160816; b=NFrkJt7+Dqdybk4v9Xps2Caa/Q+HfQPeKEtwQD6JFO7p+zyTyk98YmwXZdXDca2ysv 87zG+CSIrXu74PdfW4vBiddnbPO84cLamyxsMhzJqkBjl2RJPyVl1q5gH0QNkzHYn+NF 2nQUde1q5GylcLkCZNbVWRls9dm0EUI0JIHaMWxQ/k8PWy+KhNJrovyu4DXTChBZM9j9 +oFqSAyT+UaeO2zCmsDlcnHHpRkBE5wBewakvNQrjRbI4yJieCgCZKI7MUyJk7OPq0vh +jqfFCDmhJ/NXU5hLw3rLJcn8Nta1+VPVJh/4qMy0+Q+V9h6joWRxDCeDeK+NqnaiWwO 3j7A== 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=lCl0EZiixAW65lJauKtDv2w2JpQBLaOhlrci4XVuIkM=; b=IwViEmVi6TdjjUYD9GOl/7Jy20hTP5Ac5vjwVRvEoY/8LpNZztO1QQN46pCn2XpCmA EPBuO2jVY1WHlkXZamgSv+bqFAWaX0xkiw9xgvgNRplp0IFjmf3f+7m17g9kiV+24/h/ U35TtJ/BGwIkwMFXTPE7dza/+yuGGBY5sCUQH9wE6FDmGk/GAFw/cxXOlqf0aQBDsm3q Hex2BDr5yBW9k9PMegV2f2YTY8S/wft0KRZQ9tMpCJom0TkW78zVxh1srHkQLsgWY4Kp rRJVuqXum+0EYFpoLAez9LlxdSJkSBRCAHO1MtJxwEEb0i6dR2uvDgp5o/ee5GyelVqq ICCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B3m2tFnN; 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 d7si18847736otf.84.2020.01.20.16.02.57; Mon, 20 Jan 2020 16:03:10 -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=B3m2tFnN; 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 S1728655AbgAUAA7 (ORCPT + 99 others); Mon, 20 Jan 2020 19:00:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:36976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727009AbgAUAA7 (ORCPT ); Mon, 20 Jan 2020 19:00:59 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (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 CB61C22527; Tue, 21 Jan 2020 00:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579564858; bh=TL8+hTSU7hnDRNLe87x5EES6PdrZ165vhPZ0MkxtH7w=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=B3m2tFnN8sclNa990iPCP6BKZEo+QP6mX6mcW1I8tZxdj1fuV0nFEY4IGCTWjV3WJ OlaaNeX6URKcr3F3H/xx1O3IDKWUOnrL3OiXV3mGJpCRmB3PqBoLj26KCVnEQjdPRq A9A+97FTG+oG/guc93qspT2KDwGDNUH/DQ/BQ1cs= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 9C7DF3522745; Mon, 20 Jan 2020 16:00:58 -0800 (PST) Date: Mon, 20 Jan 2020 16:00:58 -0800 From: "Paul E. McKenney" To: Joel Fernandes Cc: Amol Grover , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Madhuparna Bhowmik Subject: Re: [PATCH] rculist: Add brackets around cond argument in __list_check_rcu macro Message-ID: <20200121000058.GI2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200118165417.12325-1-frextrite@gmail.com> <20200119021425.GH244899@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200119021425.GH244899@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 Sat, Jan 18, 2020 at 09:14:25PM -0500, Joel Fernandes wrote: > On Sat, Jan 18, 2020 at 10:24:18PM +0530, Amol Grover wrote: > > Passing a complex lockdep condition to __list_check_rcu results > > in false positive lockdep splat due to incorrect expression > > evaluation. > > > > For example, a lockdep check condition `cond1 || cond2` is > > evaluated as `!cond1 || cond2 && !rcu_read_lock_any_held()` > > which, according to operator precedence, evaluates to > > `!cond1 || (cond2 && !rcu_read_lock_any_held())`. > > This would result in a lockdep splat when cond1 is false > > and cond2 is true which is logically incorrect. > > > > Signed-off-by: Amol Grover > > Good catch! > > Acked-by: Joel Fernandes (Google) Queued for v5.7, thank you both! Thanx, Paul > thanks, > > - Joel > > > > --- > > include/linux/rculist.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/rculist.h b/include/linux/rculist.h > > index 4158b7212936..dce491f0b354 100644 > > --- a/include/linux/rculist.h > > +++ b/include/linux/rculist.h > > @@ -50,9 +50,9 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list) > > #define __list_check_rcu(dummy, cond, extra...) \ > > ({ \ > > check_arg_count_one(extra); \ > > - RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ > > + RCU_LOCKDEP_WARN(!(cond) && !rcu_read_lock_any_held(), \ > > "RCU-list traversed in non-reader section!"); \ > > - }) > > + }) > > #else > > #define __list_check_rcu(dummy, cond, extra...) \ > > ({ check_arg_count_one(extra); }) > > -- > > 2.24.1 > >