Skip to contentSkip to conversation

sched_setaffinity/sched_setaffinity01:kill child only when pid is positive

PATCH New Han Pingtian 2 participants 2 messages May 23, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched_setaffinity/sched_setaffinity01:kill child only when pid is positive

If fork() failed, the privileged_pid will be equal to -1. Then the kill() in the cleanup() will kill almost all processes on the system.

---
 testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c +1 -1
index dbaee26..70fda2c 100644
@@ -84,7 +84,7 @@ static void cleanup(void)
 
 	SAFE_SETEUID(NULL, uid);
 
-	if (privileged_pid != 0) {
+	if (privileged_pid > 0) {
 		kill(privileged_pid, SIGKILL);
 		waitpid(privileged_pid, NULL, 0);
 		privileged_pid = 0;
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/1 sched_setaffinity/sched_setaffinity01:kill child only when pid is positive

Hi!
Applied, thanks.

Signature · 2 lines
Cyril Hrubis
[email protected]