[gtk-vnc-devel] Fix mmap permissions for coroutine stacks



Our current code mmaps a region with PROT_EXEC for use as stack space in 
the swapcontext() calls. This is bogus because the stack should not be
executable. On any Fedora / RHEL system with SELinux enabled this results
in the process being terminated with extreme prejudice the moment we do
the swapcontext() call.

The attach patch removes the use of PROT_EXEC, and it also switches to use
MAP_PRIVATE instead of MAP_SHARED since ther is no reason for stack to be
shared across processes, and finally removes MAP_GROWSDOWN since it is a
broken concept that should not be used according to GLibC guys.

I notice that there have been a few mysterious crash reports in the Vinagre
bugzilla  which could well be explained by this bug, so it'd be worth getting
the users in question to try this patch too.

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
diff -rup gtk-vnc-0.2.0.orig/src/coroutine.c gtk-vnc-0.2.0.new/src/coroutine.c
--- gtk-vnc-0.2.0.orig/src/coroutine.c	2007-09-13 17:11:29.000000000 -0400
+++ gtk-vnc-0.2.0.new/src/coroutine.c	2007-09-26 15:48:23.000000000 -0400
@@ -44,8 +44,8 @@ int coroutine_init(struct coroutine *co)
 
 	co->cc.stack_size = co->stack_size;
 	co->cc.stack = mmap(0, co->stack_size,
-			    PROT_READ | PROT_WRITE | PROT_EXEC,
-			    MAP_SHARED | MAP_ANONYMOUS | MAP_GROWSDOWN,
+			    PROT_READ | PROT_WRITE,
+			    MAP_PRIVATE | MAP_ANONYMOUS,
 			    -1, 0);
 	if (co->cc.stack == MAP_FAILED)
 		return -1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]