public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] ltp: Fix races in mmap1
@ 2013-08-28 13:07 Dave Kleikamp
  2013-08-28 13:48 ` Stanislav Kholmanskikh
  2013-08-28 14:33 ` chrubis
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Kleikamp @ 2013-08-28 13:07 UTC (permalink / raw)
  To: ltp-list

Make map_address a volatile pointer so that it is dereferenced in
read_mem() after read_lock is set.

Also read_lock must protect the verbose printf that reads from map_address
as well.

Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>

diff --git a/testcases/kernel/mem/mtest06/mmap1.c b/testcases/kernel/mem/mtest06/mmap1.c
index 7c80bb4..cd1127f 100644
--- a/testcases/kernel/mem/mtest06/mmap1.c
+++ b/testcases/kernel/mem/mtest06/mmap1.c
@@ -62,7 +62,7 @@
 } while (0)
 
 static int verbose_print = 0;
-static char *map_address;
+static char *volatile map_address;
 static jmp_buf jmpbuf;
 static volatile char read_lock = 0;
 
@@ -228,11 +228,13 @@ void *read_mem(void *ptr)
 				tst_resm(TINFO, "page fault occurred due to "
 					 "a read after an unmap");
 		} else {
-			if (verbose_print)
+			if (verbose_print) {
+				read_lock = 1;
 				tst_resm(TINFO,
 					 "read_mem(): content of memory: %s",
 					 (char *)map_address);
-
+				read_lock = 0;
+			}
 			for (j = 0; j < args[1]; j++) {
 				read_lock = 1;
 				if (map_address[j] != 'a')

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2013-08-28 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-28 13:07 [LTP] [PATCH] ltp: Fix races in mmap1 Dave Kleikamp
2013-08-28 13:48 ` Stanislav Kholmanskikh
2013-08-28 14:33 ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox