2006-02-08 16:51:40

by Oleg Nesterov

[permalink] [raw]
Subject: [PATCH] fix copy_sighand() vs do_sigaction() race

copy_sighand() should hold ->sighand->siglock while copying
->sighand->action, another thread may be doing sigaction().

Signed-off-by: Oleg Nesterov <[email protected]>

--- RC-1/kernel/fork.c~ 2006-02-07 01:41:14.000000000 +0300
+++ RC-1/kernel/fork.c 2006-02-08 23:38:56.000000000 +0300
@@ -766,7 +766,9 @@ static inline int copy_sighand(unsigned
return -ENOMEM;
spin_lock_init(&sig->siglock);
atomic_set(&sig->count, 1);
+ spin_lock_irq(&current->sighand->siglock);
memcpy(sig->action, current->sighand->action, sizeof(sig->action));
+ spin_unlock_irq(&current->sighand->siglock);
return 0;
}