瀏覽代碼

Fixed potential reentrancy of suspend signal handler by blocking all signals upon entering it (its signal mask is temporarily replaced when calling sigsuspend)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7742 8c9fc860-2736-0410-a75d-ab315db34111
negelef 7 年之前
父節點
當前提交
3707c36a71
共有 2 個文件被更改,包括 6 次插入8 次删除
  1. 3 4
      source/Generic.Linux.AMD64.Unix.Mod
  2. 3 4
      source/Generic.Linux.I386.Unix.Mod

+ 3 - 4
source/Generic.Linux.AMD64.Unix.Mod

@@ -826,7 +826,7 @@ VAR
 
 	PROCEDURE ThrInitialize*( VAR low, high: LONGINT ): BOOLEAN;
 	VAR
-		param: Sched_param;
+		param: Sched_param; res: LONGINT;
 	BEGIN
 		ASSERT(pthread_mutex_init( ADDRESS OF suspend_mutex, NIL ) = 0);
 		mainthread := pthread_self();
@@ -838,9 +838,8 @@ VAR
 			Perror("ThrInitialize: setparam");
 		END;
 
-		sigemptyset( ADDRESS OF sasuspend.sa_mask );
-		sigaddset(  ADDRESS OF sasuspend.sa_mask, T_SIGRESUME );
-		sasuspend.sa_flags := SA_SIGINFO + (*SA_ONSTACK +*) SA_NODEFER;
+		res := sigfillset( ADDRESS OF sasuspend.sa_mask );
+		sasuspend.sa_flags := SA_SIGINFO;
 		sasuspend.sa_handler := suspend_handler_wrapper;
 		ASSERT(sigaction( T_SIGSUSPEND, ADDRESS OF sasuspend, NIL ) = 0);
 

+ 3 - 4
source/Generic.Linux.I386.Unix.Mod

@@ -795,7 +795,7 @@ VAR
 
 	PROCEDURE ThrInitialize*( VAR low, high: LONGINT ): BOOLEAN;
 	VAR
-		param: Sched_param;
+		param: Sched_param; res: LONGINT;
 	BEGIN
 		ASSERT(pthread_mutex_init( ADDRESS OF suspend_mutex, NIL ) = 0);
 		mainthread := pthread_self();
@@ -807,9 +807,8 @@ VAR
 			Perror("ThrInitialize: setparam");
 		END;
 
-		sigemptyset( ADDRESS OF sasuspend.sa_mask );
-		sigaddset(  ADDRESS OF sasuspend.sa_mask, T_SIGRESUME );
-		sasuspend.sa_flags := SA_SIGINFO + (*SA_ONSTACK +*) SA_NODEFER;
+		res := sigfillset( ADDRESS OF sasuspend.sa_mask );
+		sasuspend.sa_flags := SA_SIGINFO;
 		sasuspend.sa_handler := suspend_handler;
 		ASSERT(sigaction( T_SIGSUSPEND, ADDRESS OF sasuspend, NIL ) = 0);