lkml.org 
[lkml]   [2008]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[2.6.22.y] {01/17} - do_anonymous_page-race - series for stable kernel
-- 
Thanks,
Oliver
commit 8327e0f191341cc32fb89bf4d7bee7c2524ae4e0
Author: Andrea Arcangeli <andrea@suse.de>
Date: Mon Jan 28 20:52:29 2008 +0100

Subject: Race condition in userspace testcase
References: 46948, LTC11574


Additional Comment #103 From Andrea Arcangeli 2004-10-15 19:41
the last patch I attached is the safest I believe.

I'm not sure if a lock_unlock or lock_unlock is always guaranteed to happen
after the I/O, and this makes sure no race can happen anymore.

diff --git a/fs/bio.c b/fs/bio.c
index 093345f..984d589 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1028,6 +1028,15 @@ void bio_endio(struct bio *bio, unsigned int bytes_done, int error)
bio->bi_size -= bytes_done;
bio->bi_sector += (bytes_done >> 9);

+ if (bio_data_dir(bio) == READ)
+ /*
+ * If the current cpu has written to the page by hand
+ * without dma, we must enforce ordering to be sure
+ * this written data will be visible before we expose
+ * the page contents to other cpus (for example with
+ * a set_pte).
+ */
+ smp_wmb();
if (bio->bi_end_io)
bio->bi_end_io(bio, bytes_done, error);
}
\
 
 \ /
  Last update: 2008-01-29 00:17    [W:0.038 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site