* [PATCH] cfg80211: Pass lockdep expression to RCU lists
@ 2020-02-19 9:11 Amol Grover
2020-02-19 9:13 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Amol Grover @ 2020-02-19 9:11 UTC (permalink / raw)
To: Johannes Berg, David S . Miller, Jakub Kicinski
Cc: linux-wireless, netdev, linux-kernel, linux-kernel-mentees,
Joel Fernandes, Madhuparna Bhowmik, Paul E . McKenney,
Amol Grover
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.
Signed-off-by: Amol Grover <frextrite@gmail.com>
---
net/wireless/scan.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index aef240fdf8df..7f1af8f347b1 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -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;
}
--
2.24.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] cfg80211: Pass lockdep expression to RCU lists
2020-02-19 9:11 [PATCH] cfg80211: Pass lockdep expression to RCU lists Amol Grover
@ 2020-02-19 9:13 ` Johannes Berg
2020-02-19 12:47 ` Paul E. McKenney
2020-02-19 21:27 ` Arend Van Spriel
0 siblings, 2 replies; 6+ messages in thread
From: Johannes Berg @ 2020-02-19 9:13 UTC (permalink / raw)
To: Amol Grover, David S . Miller, Jakub Kicinski
Cc: linux-wireless, netdev, linux-kernel, linux-kernel-mentees,
Joel Fernandes, Madhuparna Bhowmik, Paul E . McKenney
On Wed, 2020-02-19 at 14:41 +0530, Amol Grover wrote:
>
> - 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cfg80211: Pass lockdep expression to RCU lists
2020-02-19 9:13 ` Johannes Berg
@ 2020-02-19 12:47 ` Paul E. McKenney
2020-02-19 21:27 ` Arend Van Spriel
1 sibling, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2020-02-19 12:47 UTC (permalink / raw)
To: Johannes Berg
Cc: Amol Grover, David S . Miller, Jakub Kicinski, linux-wireless,
netdev, linux-kernel, linux-kernel-mentees, Joel Fernandes,
Madhuparna Bhowmik
On Wed, Feb 19, 2020 at 10:13:36AM +0100, Johannes Berg wrote:
> On Wed, 2020-02-19 at 14:41 +0530, Amol Grover wrote:
> >
> > - 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cfg80211: Pass lockdep expression to RCU lists
2020-02-19 9:13 ` Johannes Berg
2020-02-19 12:47 ` Paul E. McKenney
@ 2020-02-19 21:27 ` Arend Van Spriel
2020-02-19 21:29 ` Johannes Berg
1 sibling, 1 reply; 6+ messages in thread
From: Arend Van Spriel @ 2020-02-19 21:27 UTC (permalink / raw)
To: Johannes Berg, Amol Grover, David S . Miller, Jakub Kicinski
Cc: linux-wireless, netdev, linux-kernel, linux-kernel-mentees,
Joel Fernandes, Madhuparna Bhowmik, Paul E . McKenney
On 2/19/2020 10:13 AM, Johannes Berg wrote:
> On Wed, 2020-02-19 at 14:41 +0530, Amol Grover wrote:
>>
>> - 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cfg80211: Pass lockdep expression to RCU lists
2020-02-19 21:27 ` Arend Van Spriel
@ 2020-02-19 21:29 ` Johannes Berg
2020-02-19 21:33 ` Arend Van Spriel
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2020-02-19 21:29 UTC (permalink / raw)
To: Arend Van Spriel, Amol Grover, David S . Miller, Jakub Kicinski
Cc: linux-wireless, netdev, linux-kernel, linux-kernel-mentees,
Joel Fernandes, Madhuparna Bhowmik, Paul E . McKenney
On Wed, 2020-02-19 at 22:27 +0100, Arend Van Spriel wrote:
> On 2/19/2020 10:13 AM, Johannes Berg wrote:
> > On Wed, 2020-02-19 at 14:41 +0530, Amol Grover wrote:
> > >
> > > - 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.
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cfg80211: Pass lockdep expression to RCU lists
2020-02-19 21:29 ` Johannes Berg
@ 2020-02-19 21:33 ` Arend Van Spriel
0 siblings, 0 replies; 6+ messages in thread
From: Arend Van Spriel @ 2020-02-19 21:33 UTC (permalink / raw)
To: Johannes Berg, Amol Grover, David S . Miller, Jakub Kicinski
Cc: linux-wireless, netdev, linux-kernel, linux-kernel-mentees,
Joel Fernandes, Madhuparna Bhowmik, Paul E . McKenney
On 2/19/2020 10:29 PM, Johannes Berg wrote:
> On Wed, 2020-02-19 at 22:27 +0100, Arend Van Spriel wrote:
>> On 2/19/2020 10:13 AM, Johannes Berg wrote:
>>> On Wed, 2020-02-19 at 14:41 +0530, Amol Grover wrote:
>>>>
>>>> - 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.
>
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-02-19 21:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 9:11 [PATCH] cfg80211: Pass lockdep expression to RCU lists Amol Grover
2020-02-19 9:13 ` Johannes Berg
2020-02-19 12:47 ` Paul E. McKenney
2020-02-19 21:27 ` Arend Van Spriel
2020-02-19 21:29 ` Johannes Berg
2020-02-19 21:33 ` Arend Van Spriel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).