netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] macvtap: rcu_dereference outside read-lock section
@ 2012-08-11 10:05 Denis Efremov
  2012-08-12  1:16 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Efremov @ 2012-08-11 10:05 UTC (permalink / raw)
  To: David S. Miller
  Cc: Denis Efremov, Michael S. Tsirkin, Jason Wang, Eric W. Biederman,
	Ian Campbell, netdev, linux-kernel, ldv-project

In this case it is not an error. rcu_dereference
occurs in update section. Replacement by
rcu_dereference_protected (with spinlock) in order to
prevent lockdep complaint.

Found by Linux Driver Verification project (linuxtesting.org)

Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
---
 drivers/net/macvtap.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 0737bd4..8ef11a8 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -94,7 +94,8 @@ static int get_slot(struct macvlan_dev *vlan, struct macvtap_queue *q)
 	int i;
 
 	for (i = 0; i < MAX_MACVTAP_QUEUES; i++) {
-		if (rcu_dereference(vlan->taps[i]) == q)
+		if (rcu_dereference_protected(vlan->taps[i],
+				lockdep_is_held(&macvtap_lock)) == q)
 			return i;
 	}
 
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] macvtap: rcu_dereference outside read-lock section
  2012-08-11 10:05 [PATCH] macvtap: rcu_dereference outside read-lock section Denis Efremov
@ 2012-08-12  1:16 ` David Miller
  2012-08-12  6:26   ` [PATCH v2] " Denis Efremov
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2012-08-12  1:16 UTC (permalink / raw)
  To: yefremov.denis
  Cc: mst, jasowang, ebiederm, ian.campbell, netdev, linux-kernel,
	ldv-project

From: Denis Efremov <yefremov.denis@gmail.com>
Date: Sat, 11 Aug 2012 14:05:27 +0400

> -		if (rcu_dereference(vlan->taps[i]) == q)
> +		if (rcu_dereference_protected(vlan->taps[i],
> +				lockdep_is_held(&macvtap_lock)) == q)

You must use the proper combination of TAB character and spaces
to line up the lockdep_is_held() argument with the first column
after openning "(" on the previous line.

Never be lazy and use only TABs.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] macvtap: rcu_dereference outside read-lock section
  2012-08-12  1:16 ` David Miller
@ 2012-08-12  6:26   ` Denis Efremov
  2012-08-12  8:49     ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Efremov @ 2012-08-12  6:26 UTC (permalink / raw)
  To: David S. Miller
  Cc: Denis Efremov, Michael S. Tsirkin, Jason Wang, Eric W. Biederman,
	Ian Campbell, netdev, linux-kernel, ldv-project

rcu_dereference occurs in update section. Replacement by
rcu_dereference_protected in order to prevent lockdep
complaint.

Found by Linux Driver Verification project (linuxtesting.org)

Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
---
 drivers/net/macvtap.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 0737bd4..0f0f9ce 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -94,7 +94,8 @@ static int get_slot(struct macvlan_dev *vlan, struct macvtap_queue *q)
 	int i;
 
 	for (i = 0; i < MAX_MACVTAP_QUEUES; i++) {
-		if (rcu_dereference(vlan->taps[i]) == q)
+		if (rcu_dereference_protected(vlan->taps[i],
+					      lockdep_is_held(&macvtap_lock)) == q)
 			return i;
 	}
 
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] macvtap: rcu_dereference outside read-lock section
  2012-08-12  6:26   ` [PATCH v2] " Denis Efremov
@ 2012-08-12  8:49     ` Michael S. Tsirkin
  2012-08-12 20:41       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-08-12  8:49 UTC (permalink / raw)
  To: Denis Efremov
  Cc: David S. Miller, Jason Wang, Eric W. Biederman, Ian Campbell,
	netdev, linux-kernel, ldv-project

On Sun, Aug 12, 2012 at 10:26:31AM +0400, Denis Efremov wrote:
> rcu_dereference occurs in update section. Replacement by
> rcu_dereference_protected in order to prevent lockdep
> complaint.
> 
> Found by Linux Driver Verification project (linuxtesting.org)
> 
> Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
> ---
>  drivers/net/macvtap.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> index 0737bd4..0f0f9ce 100644
> --- a/drivers/net/macvtap.c
> +++ b/drivers/net/macvtap.c
> @@ -94,7 +94,8 @@ static int get_slot(struct macvlan_dev *vlan, struct macvtap_queue *q)
>  	int i;
>  
>  	for (i = 0; i < MAX_MACVTAP_QUEUES; i++) {
> -		if (rcu_dereference(vlan->taps[i]) == q)
> +		if (rcu_dereference_protected(vlan->taps[i],
> +					      lockdep_is_held(&macvtap_lock)) == q)

And now it's too long.  Maybe a temporary would be better?

		struct macvtap_queue *t;
		t = rcu_dereference_protected(vlan->taps[i],
					      lockdep_is_held(&macvtap_lock));
		if (t == q)
  			return i;
		
?

Anyway -

Acked-by: Michael S. Tsirkin <mst@redhat.com>


>  			return i;
>  	}
>  
> -- 
> 1.7.7

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] macvtap: rcu_dereference outside read-lock section
  2012-08-12  8:49     ` Michael S. Tsirkin
@ 2012-08-12 20:41       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2012-08-12 20:41 UTC (permalink / raw)
  To: mst
  Cc: yefremov.denis, jasowang, ebiederm, ian.campbell, netdev,
	linux-kernel, ldv-project

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Sun, 12 Aug 2012 11:49:29 +0300

> On Sun, Aug 12, 2012 at 10:26:31AM +0400, Denis Efremov wrote:
>> rcu_dereference occurs in update section. Replacement by
>> rcu_dereference_protected in order to prevent lockdep
>> complaint.
>> 
>> Found by Linux Driver Verification project (linuxtesting.org)
>> 
>> Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
...
> Acked-by: Michael S. Tsirkin <mst@redhat.com>

Applied, thanks everyone.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-08-12 20:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-11 10:05 [PATCH] macvtap: rcu_dereference outside read-lock section Denis Efremov
2012-08-12  1:16 ` David Miller
2012-08-12  6:26   ` [PATCH v2] " Denis Efremov
2012-08-12  8:49     ` Michael S. Tsirkin
2012-08-12 20:41       ` David Miller

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).