All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] dm-raid1.c  fix  a race bug in __rh_alloc()
@ 2005-06-17  2:21 Zhao Qian
  2005-06-24 15:33 ` Jonathan E Brassow
  0 siblings, 1 reply; 4+ messages in thread
From: Zhao Qian @ 2005-06-17  2:21 UTC (permalink / raw)
  To: dm-devel

after write_unlock_irq and just before read_lock, there's a small window which enables a race causing deletion of the region struct in function rh_update_states(). then in rh_dec(), the __rh_lookup() will return null, causing kernel panic. 


[root@darkstar md]# diff -u dm-raid1.orig.c dm-raid1.c 
--- dm-raid1.orig.c     2005-06-16 14:17:04.000000000 +0800
+++ dm-raid1.c  2005-06-17 10:02:04.000000000 +0800
@@ -252,15 +252,16 @@
 
        else {
                __rh_insert(rh, nreg);
-               if (nreg->state == RH_CLEAN) {
-                       spin_lock(&rh->region_lock);
-                       list_add(&nreg->list, &rh->clean_regions);
-                       spin_unlock(&rh->region_lock);
-               }
                reg = nreg;
        }
        write_unlock_irq(&rh->hash_lock);
        read_lock(&rh->hash_lock);
+       if (reg->state == RH_CLEAN) {
+               spin_lock(&rh->region_lock);
+               if ( list_empty(&reg->list) )
+                       list_add(&reg->list, &rh->clean_regions);
+               spin_unlock(&rh->region_lock);
+       }
 
        return reg;
 }

Sincerely,
    Johnson <dujun@aaastor.com>
    AiM9 <zhaoqian@aaastor.com>

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

end of thread, other threads:[~2005-06-29  1:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-17  2:21 [patch] dm-raid1.c fix a race bug in __rh_alloc() Zhao Qian
2005-06-24 15:33 ` Jonathan E Brassow
2005-06-28 13:46   ` Jun'ichi Nomura
2005-06-29  1:32     ` Du Jun

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.