cfg80211: Pass lockdep expression to RCU lists
Subsystems (3)
PATCH 1/1 cfg80211: Pass lockdep expression to RCU lists
rdev->sched_scan_req_list maybe traversed using list_for_each_entry_rcu outside an RCU read-side critical section but under the protection of rtnl_mutex.
Hence, add corresponding lockdep expression to silence false-positive warnings, and harden RCU lists.
--- net/wireless/scan.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/wireless/scan.c +2 -3
@@ -556,9 +556,8 @@ cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid) {struct cfg80211_sched_scan_request *pos; -WARN_ON_ONCE (!rcu_read_lock_held () && !lockdep_rtnl_is_held ()); - -list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list) { +list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list, +lockdep_rtnl_is_held ()) {if (pos->reqid == reqid)return pos; }
Signature · 1 line
2.24.1
Johannes Berg
maintainernet/wireless/scan.c cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid) · line 560
Quoted 6 lines · Amol Grover
net/wireless/scan.c +2
-3-WARN_ON_ONCE (!rcu_read_lock_held () && !lockdep_rtnl_is_held ()); - -list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list) { +list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list, +lockdep_rtnl_is_held ()) {
Huh, I didn't even know you _could_ do that :)
johannes
Quoted 9 lines · Johannes Berg
net/wireless/scan.c cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid) · line 560
Quoted 6 lines · Amol Grover
net/wireless/scan.c +2
-3-WARN_ON_ONCE (!rcu_read_lock_held () && !lockdep_rtnl_is_held ()); - -list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list) { +list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list, +lockdep_rtnl_is_held ()) {Huh, I didn't even know you _could_ do that :)
It is a fairly recent addition, courtesy of Joel Fernandes. ;-)
Thanx, Paul
Quoted 9 lines · Johannes Berg
net/wireless/scan.c cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid) · line 560
Quoted 6 lines · Amol Grover
net/wireless/scan.c +2
-3-WARN_ON_ONCE (!rcu_read_lock_held () && !lockdep_rtnl_is_held ()); - -list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list) { +list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list, +lockdep_rtnl_is_held ()) {Huh, I didn't even know you _could_ do that :)
Me neither ;-). Above you are removing the WARN_ON_ONCE() entirely. Would it not be good to keep the WARN_ON_ONCE() with only the !rcu_read_lock_held() check.
Regards,
Arend
Johannes Berg
maintainerQuoted 11 lines · Arend Van Spriel
Quoted 9 lines · Johannes Berg
net/wireless/scan.c cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid) · line 560
Quoted 6 lines · Amol Grover
net/wireless/scan.c +2
-3-WARN_ON_ONCE (!rcu_read_lock_held () && !lockdep_rtnl_is_held ()); - -list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list) { +list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list, +lockdep_rtnl_is_held ()) {Huh, I didn't even know you _could_ do that :)
Quoted 3 lines
Me neither ;-). Above you are removing the
WARN_ON_ONCE()entirely. Would it not be good to keep theWARN_ON_ONCE()with only the !rcu_read_lock_held() check.
Not needed, the macro expansion will already contain rcu_read_lock_any_held() just like in all the other cases where you pass a lockdep condition to RCU helpers.
johannes
Quoted 12 lines · Johannes Berg
Quoted 11 lines · Arend Van Spriel
Quoted 9 lines · Johannes Berg
net/wireless/scan.c cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid) · line 560
Quoted 6 lines · Amol Grover
net/wireless/scan.c +2
-3-WARN_ON_ONCE (!rcu_read_lock_held () && !lockdep_rtnl_is_held ()); - -list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list) { +list_for_each_entry_rcu (pos, &rdev->sched_scan_req_list, list, +lockdep_rtnl_is_held ()) {Huh, I didn't even know you _could_ do that :)
Quoted 7 lines
Quoted 3 lines
Me neither ;-). Above you are removing the
WARN_ON_ONCE()entirely. Would it not be good to keep theWARN_ON_ONCE()with only the !rcu_read_lock_held() check.Not needed, the macro expansion will already contain
rcu_read_lock_any_held()just like in all the other cases where you pass a lockdep condition to RCU helpers.
Ah, yes. I see it in __list_check_rcu().
Thanks,
Arend