Skip to content

Commit 4dfd5cd

Browse files
frextritepaulmckrcu
authored andcommitted
rculist: Add brackets around cond argument in __list_check_rcu macro
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 <[email protected]> Acked-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent aa24f93 commit 4dfd5cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/linux/rculist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
6060
#define __list_check_rcu(dummy, cond, extra...) \
6161
({ \
6262
check_arg_count_one(extra); \
63-
RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \
63+
RCU_LOCKDEP_WARN(!(cond) && !rcu_read_lock_any_held(), \
6464
"RCU-list traversed in non-reader section!"); \
65-
})
65+
})
6666
#else
6767
#define __list_check_rcu(dummy, cond, extra...) \
6868
({ check_arg_count_one(extra); })

0 commit comments

Comments
 (0)