[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190716040743.78343-1-joel@joelfernandes.org>
Date: Tue, 16 Jul 2019 00:07:43 -0400
From: "Joel Fernandes (Google)" <joel@...lfernandes.org>
To: linux-kernel@...r.kernel.org
Cc: "Joel Fernandes (Google)" <joel@...lfernandes.org>,
Paul McKenney <paulmck@...ux.vnet.ibm.com>,
Alexey Kuznetsov <kuznet@....inr.ac.ru>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Borislav Petkov <bp@...en8.de>, c0d1n61at3@...il.com,
"David S. Miller" <davem@...emloft.net>, edumazet@...gle.com,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
Jonathan Corbet <corbet@....net>,
Josh Triplett <josh@...htriplett.org>, keescook@...omium.org,
kernel-hardening@...ts.openwall.com, kernel-team@...roid.com,
Lai Jiangshan <jiangshanlai@...il.com>,
Len Brown <lenb@...nel.org>, linux-acpi@...r.kernel.org,
linux-doc@...r.kernel.org, linux-pci@...r.kernel.org,
linux-pm@...r.kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
neilb@...e.com, netdev@...r.kernel.org,
Oleg Nesterov <oleg@...hat.com>,
"Paul E. McKenney" <paulmck@...ux.ibm.com>,
Pavel Machek <pavel@....cz>, peterz@...radead.org,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
Rasmus Villemoes <rasmus.villemoes@...vas.dk>,
rcu@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
Tejun Heo <tj@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, will@...nel.org,
x86@...nel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT))
Subject: [PATCH] rculist: Add build check for single optional list argument
In a previous patch series [1], we added an optional lockdep expression
argument to list_for_each_entry_rcu() and the hlist equivalent. This
also meant more than one optional argument can be passed to them with
that error going unnoticed. To fix this, let us force a compiler error
more than one optional argument is passed.
[1] https://lore.kernel.org/patchwork/project/lkml/list/?series=402150
Suggested-by: Paul McKenney <paulmck@...ux.vnet.ibm.com>
Signed-off-by: Joel Fernandes (Google) <joel@...lfernandes.org>
---
include/linux/rculist.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index 1048160625bb..86659f6d72dc 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -44,14 +44,18 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
* Check during list traversal that we are within an RCU reader
*/
+#define check_arg_count_one(dummy)
+
#ifdef CONFIG_PROVE_RCU_LIST
-#define __list_check_rcu(dummy, cond, ...) \
+#define __list_check_rcu(dummy, cond, extra...) \
({ \
+ check_arg_count_one(extra); \
RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \
"RCU-list traversed in non-reader section!"); \
})
#else
-#define __list_check_rcu(dummy, cond, ...) ({})
+#define __list_check_rcu(dummy, cond, extra...) \
+ ({ check_arg_count_one(extra); })
#endif
/*
--
2.22.0.510.g264f2c817a-goog
Powered by blists - more mailing lists