Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1078271ybl; Sat, 18 Jan 2020 18:15:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxFuGRf3we0b3LzPhhUFAa8FmmQ8AQclk6//M5MjOgUGLWsk0aLz+gvoyHxq0/ff26FWNrt X-Received: by 2002:a05:6830:2009:: with SMTP id e9mr11653346otp.160.1579400131283; Sat, 18 Jan 2020 18:15:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579400131; cv=none; d=google.com; s=arc-20160816; b=j1yeCZrd7oc4rX9QZeLkYQpG4RM1/SQ+2KHOYfPaJEKff3Lwek6dOXV1QCEJ/2LHlL TX8GJk+3RNBFEqhT+/r5lU1YnDSuRqOgd7a7YsghGWlDqWWyAECgZikRz/o/az78Q10K GvEej8HVdGgeS6ZicSpiGP4enJ2gexuVZ9uZHUUAOlG0X59bO7LeVbqABDIn22+Nn/U2 tu0BlnGqX1KUm+m9znfJQAXkoNsZwufq7l61DsLmTC/rAq5IWAHGxy6WR4olBADZMwIT cUNXtM9nPV4AtrKRYz3ctE1DsEZK9loOpIPzpV9IGxRrZ8+3pmS2agXysNmwla3H4/e3 PVbg== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=wKnHTOsGYbWMuEtHLalSufdyt5LKcQfM0ik/ggkorb8=; b=PZD64OqOxTxIrrl2p0fx6dvl02h+jBqli2KIk6xGRweveHcCnXXGWEFPkxoUIW9KOI MmrQpUhdI4F9MDaMJUV2nzTh/RcOHwu84N/0Hrz57HTBgzTIGagAZOvgRzD6UMSBPF0A K7UJd6XD51NbOAm77u0Tl1lnrvAYj7wFOYhB12GyW3yKlZ3nP4GG8LSVwbrrtizYNk/4 Xk0ICRsVl1Ya0cNmYM+TmwdQXhftc8bR2O1XQP7AENy3HXFKUnpuvcKQI3qsK6sKEk7R 605BQeWLwdUg2j0URu9O77LNe3jAA0BFPoB1FB4jDgD2VoP88ZIthSzU+xj2brgdRD7g 9LCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=MSAL+3bf; 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 m3si16608096otf.42.2020.01.18.18.15.19; Sat, 18 Jan 2020 18:15:31 -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=@joelfernandes.org header.s=google header.b=MSAL+3bf; 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 S1728655AbgASCO1 (ORCPT + 99 others); Sat, 18 Jan 2020 21:14:27 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:50359 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbgASCO1 (ORCPT ); Sat, 18 Jan 2020 21:14:27 -0500 Received: by mail-pj1-f67.google.com with SMTP id r67so5004963pjb.0 for ; Sat, 18 Jan 2020 18:14:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wKnHTOsGYbWMuEtHLalSufdyt5LKcQfM0ik/ggkorb8=; b=MSAL+3bf/Sr2q37mtoS4XEMfewmJNpRseZ6b4abZn9jW7t3K12vCcgectB7jCIDb7/ j6RbLWT4TqX3yfnuGs+zMOw7LRrOGeL5RmzFVP9zcT49BJEUaASoMtd4wJqKyv97Ir+q BXawhfdNbTXCBZp2wkM2yRwSvg0ywrzs26GfU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wKnHTOsGYbWMuEtHLalSufdyt5LKcQfM0ik/ggkorb8=; b=YIb4iuaZkDs9Hchd35Z/P41WcvAmCG6kieO97BJFUHLOz1yJQe/ySzZPoihU2185/w /pXwpFWtryV24WR6lNjAqZKtOcUAi3Dw1FM/YUGNYgNqY8OvG3tJYFIJ46+aDjITMRe9 Or7PRPdk6GYGydBkG63SnLLuD95YF2ISQgp9onHtJZIO2WUxPxy6po6GmmM+nQOSQgkk hENy/KzGHnmiPl7cHIoORwTxcHC4M8QTfEKE9Qo4mep170vv/EU/scUbcYIxm2JNtPT3 FQ0wLy0nL1l8CFbe2Be+ZNug2YzG+TACAvdam3tUUNEemlr6Q6Kr0Ax6Y0GTRoFU5Kr1 xqeA== X-Gm-Message-State: APjAAAVg+/RvGeLg+lHLGK/Q97T04bZq6TRnlSFUVxa1xC0UYAHJOxZy 6eZGsBky2mRcACd9BZo4//yM6A== X-Received: by 2002:a17:902:9a8e:: with SMTP id w14mr7598767plp.315.1579400066308; Sat, 18 Jan 2020 18:14:26 -0800 (PST) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id h7sm35796636pfq.36.2020.01.18.18.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jan 2020 18:14:25 -0800 (PST) Date: Sat, 18 Jan 2020 21:14:25 -0500 From: Joel Fernandes To: Amol Grover Cc: "Paul E. McKenney" , 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: <20200119021425.GH244899@google.com> References: <20200118165417.12325-1-frextrite@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200118165417.12325-1-frextrite@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 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) 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 >