All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH]2.6 test1 mm2 user.c race (?)
       [not found] <200307281204.h6SC4soV001044@fire-1.osdl.org>
@ 2003-07-28 19:14 ` Andrew Morton
  2003-07-30  2:53   ` Bill Davidsen
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2003-07-28 19:14 UTC (permalink / raw)
  To: ffrederick; +Cc: linux-kernel

<ffrederick@prov-liege.be> wrote:
>
> +	spin_lock(&uidhash_lock);
>  	uid_hash_insert(&root_user, uidhashentry(0));
> +	spin_unlock(&uidhash_lock);	

This code runs within an initcall, so it is very unlikely that anything
will race with us here.

But SMP is up, and this code gets dropped out of memory later (the
out-of-line spinlock code doesn't get dropped though).

So yes, I'd prefer that the locking be there, if only for documentary
purposes.  A /* comment */ which explains why the locking was omitted would
also be suitabe.


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

* Re: [PATCH]2.6 test1 mm2 user.c race (?)
  2003-07-28 19:14 ` [PATCH]2.6 test1 mm2 user.c race (?) Andrew Morton
@ 2003-07-30  2:53   ` Bill Davidsen
  0 siblings, 0 replies; 3+ messages in thread
From: Bill Davidsen @ 2003-07-30  2:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: ffrederick, linux-kernel

On Mon, 28 Jul 2003, Andrew Morton wrote:

> <ffrederick@prov-liege.be> wrote:
> >
> > +	spin_lock(&uidhash_lock);
> >  	uid_hash_insert(&root_user, uidhashentry(0));
> > +	spin_unlock(&uidhash_lock);	
> 
> This code runs within an initcall, so it is very unlikely that anything
> will race with us here.
> 
> But SMP is up, and this code gets dropped out of memory later (the
> out-of-line spinlock code doesn't get dropped though).
> 
> So yes, I'd prefer that the locking be there, if only for documentary
> purposes.  A /* comment */ which explains why the locking was omitted would
> also be suitabe.

I like the locking better than the comment, I trust the analysis today,
but with SMP and preempt, the lock protects the future (and you may be
missing something even today).

-- 
bill davidsen <davidsen@tmr.com>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.


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

* [PATCH]2.6 test1 mm2 user.c race (?)
@ 2003-07-28 12:31 ffrederick
  0 siblings, 0 replies; 3+ messages in thread
From: ffrederick @ 2003-07-28 12:31 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Andrew,

        Trivial patch against possible smp race (?) in user.c
or do we have bkl above ?

Regards,
Fabian

diff -Naur orig/kernel/user.c edited/kernel/user.c
--- orig/kernel/user.c	2003-07-14 05:32:42.000000000 +0200
+++ edited/kernel/user.c	2003-07-28 13:44:55.000000000 +0200
@@ -146,8 +146,11 @@
 	for(n = 0; n < UIDHASH_SZ; ++n)
 		INIT_LIST_HEAD(uidhash_table + n);
 
-	/* Insert the root user immediately - init already runs with this */
+	/* Insert the root user immediately (init already runs as root) */
+	spin_lock(&uidhash_lock);
 	uid_hash_insert(&root_user, uidhashentry(0));
+	spin_unlock(&uidhash_lock);	
+
 	return 0;
 }
 


___________________________________




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

end of thread, other threads:[~2003-07-30  3:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200307281204.h6SC4soV001044@fire-1.osdl.org>
2003-07-28 19:14 ` [PATCH]2.6 test1 mm2 user.c race (?) Andrew Morton
2003-07-30  2:53   ` Bill Davidsen
2003-07-28 12:31 ffrederick

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.