LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [2.6.22.y] {14+1} - NM!!! - Race condition in userspace testcase - on top of 2.6.22.17
@ 2008-02-07 20:04 Oliver Pinter
  0 siblings, 0 replies; only message in thread
From: Oliver Pinter @ 2008-02-07 20:04 UTC (permalink / raw)
  To: Linux Kernel, stable, stable-commits

aka: do_anonymous_page-race.patch

From: Andrea Arcangeli <andrea@suse.de>
Subject: Race condition in userspace testcase
References: 46948, LTC11574

NOT IN MAINLINE

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.

---
 fs/bio.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/fs/bio.c	2007-07-08 19:32:17.000000000 -0400
+++ b/fs/bio.c	2007-08-27 14:01:21.000000000 -0400
@@ -1028,6 +1028,15 @@ void bio_endio(struct bio *bio, unsigned
 	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);
 }


-- 
Thanks,
Oliver

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-07 20:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-07 20:04 [2.6.22.y] {14+1} - NM!!! - Race condition in userspace testcase - on top of 2.6.22.17 Oliver Pinter

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