netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -rt] Fix initialization of spinlock in irttp_dup()
@ 2007-03-20 19:22 Deepak Saxena
  2007-03-20 21:50 ` Samuel Ortiz
  2007-03-21  7:11 ` Ingo Molnar
  0 siblings, 2 replies; 3+ messages in thread
From: Deepak Saxena @ 2007-03-20 19:22 UTC (permalink / raw)
  To: samuel; +Cc: netdev, Andrew Morton, Ingo Molnar, Daniel Walker

This was found around the 2.6.10 timeframe when testing with the -rt patch
and I believe is still is an issue. irttp_dup() does a memcpy() of the tsap_cb 
structure causing the spinlock protecting various fields in the structure to be 
duped.  This works OK in the non-RT case but in the RT case we end up with two 
mutexes pointing to the same wait_list and leading to an OOPS. Fix is to simply
initialize the spinlock after the memcpy().

Signed-off-by: Deepak Saxena <dsaxena@mvista.com>

diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index a7486b3..df2b2f7 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -1441,6 +1441,7 @@ struct tsap_cb *irttp_dup(struct tsap_cb
 	}
 	/* Dup */
 	memcpy(new, orig, sizeof(struct tsap_cb));
+	spin_lock_init(&new->lock);
 
 	/* We don't need the old instance any more */
 	spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);


-- 
Deepak Saxena - dsaxena@plexity.net - http://www.plexity.net

In the end, they will not say, "those were dark times,"  they will ask
"why were their poets silent?" - Bertolt Brecht

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

* Re: [PATCH -rt] Fix initialization of spinlock in irttp_dup()
  2007-03-20 19:22 [PATCH -rt] Fix initialization of spinlock in irttp_dup() Deepak Saxena
@ 2007-03-20 21:50 ` Samuel Ortiz
  2007-03-21  7:11 ` Ingo Molnar
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Ortiz @ 2007-03-20 21:50 UTC (permalink / raw)
  To: Deepak Saxena; +Cc: netdev, Andrew Morton, Ingo Molnar, Daniel Walker

Hi Deepak,

On Tue, Mar 20, 2007 at 12:22:33PM -0700, Deepak Saxena wrote:
> This was found around the 2.6.10 timeframe when testing with the -rt patch
> and I believe is still is an issue. irttp_dup() does a memcpy() of the tsap_cb 
> structure causing the spinlock protecting various fields in the structure to be 
> duped.  This works OK in the non-RT case but in the RT case we end up with two 
> mutexes pointing to the same wait_list and leading to an OOPS. Fix is to simply
> initialize the spinlock after the memcpy().
This has just made it to the netdev and stable trees.
See:
http://git.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commit;h=7bb1bbe615de25d955b974cb47d40fa198154bb9

Cheers,
Samuel.


> Signed-off-by: Deepak Saxena <dsaxena@mvista.com>
> 
> diff --git a/net/irda/irttp.c b/net/irda/irttp.c
> index a7486b3..df2b2f7 100644
> --- a/net/irda/irttp.c
> +++ b/net/irda/irttp.c
> @@ -1441,6 +1441,7 @@ struct tsap_cb *irttp_dup(struct tsap_cb
>  	}
>  	/* Dup */
>  	memcpy(new, orig, sizeof(struct tsap_cb));
> +	spin_lock_init(&new->lock);
>  
>  	/* We don't need the old instance any more */
>  	spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
> 
> 
> -- 
> Deepak Saxena - dsaxena@plexity.net - http://www.plexity.net
> 
> In the end, they will not say, "those were dark times,"  they will ask
> "why were their poets silent?" - Bertolt Brecht


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

* Re: [PATCH -rt] Fix initialization of spinlock in irttp_dup()
  2007-03-20 19:22 [PATCH -rt] Fix initialization of spinlock in irttp_dup() Deepak Saxena
  2007-03-20 21:50 ` Samuel Ortiz
@ 2007-03-21  7:11 ` Ingo Molnar
  1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2007-03-21  7:11 UTC (permalink / raw)
  To: Deepak Saxena; +Cc: samuel, netdev, Andrew Morton, Daniel Walker


* Deepak Saxena <dsaxena@plexity.net> wrote:

> This was found around the 2.6.10 timeframe when testing with the -rt 
> patch and I believe is still is an issue. irttp_dup() does a memcpy() 
> of the tsap_cb structure causing the spinlock protecting various 
> fields in the structure to be duped.  This works OK in the non-RT case 
> but in the RT case we end up with two mutexes pointing to the same 
> wait_list and leading to an OOPS. Fix is to simply initialize the 
> spinlock after the memcpy().

note that memcpy based lock initialization is a problem for lockdep too.

	Ingo

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

end of thread, other threads:[~2007-03-21  7:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-20 19:22 [PATCH -rt] Fix initialization of spinlock in irttp_dup() Deepak Saxena
2007-03-20 21:50 ` Samuel Ortiz
2007-03-21  7:11 ` Ingo Molnar

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