linux/kernel
GOTO Masanori f9a3879abf [PATCH] Fix sigaltstack corruption among cloned threads
This patch fixes alternate signal stack corruption among cloned threads
with CLONE_SIGHAND (and CLONE_VM) for linux-2.6.16-rc6.

The value of alternate signal stack is currently inherited after a call of
clone(...  CLONE_SIGHAND | CLONE_VM).  But if sigaltstack is set by a
parent thread, and then if multiple cloned child threads (+ parent threads)
call signal handler at the same time, some threads may be conflicted -
because they share to use the same alternative signal stack region.
Finally they get sigsegv.  It's an undesirable race condition.  Note that
child threads created from NPTL pthread_create() also hit this conflict
when the parent thread uses sigaltstack, without my patch.

To fix this problem, this patch clears the child threads' sigaltstack
information like exec().  This behavior follows the SUSv3 specification.
In SUSv3, pthread_create() says "The alternate stack shall not be inherited
(when new threads are initialized)".  It means that sigaltstack should be
cleared when sigaltstack memory space is shared by cloned threads with
CLONE_SIGHAND.

Note that I chose "if (clone_flags & CLONE_SIGHAND)" line because:
  - If clone_flags line is not existed, fork() does not inherit sigaltstack.
  - CLONE_VM is another choice, but vfork() does not inherit sigaltstack.
  - CLONE_SIGHAND implies CLONE_VM, and it looks suitable.
  - CLONE_THREAD is another candidate, and includes CLONE_SIGHAND + CLONE_VM,
    but this flag has a bit different semantics.
I decided to use CLONE_SIGHAND.

[ Changed to test for CLONE_VM && !CLONE_VFORK after discussion --Linus ]

Signed-off-by: GOTO Masanori <gotom@sanori.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Acked-by: Linus Torvalds <torvalds@osdl.org>
Cc: Ulrich Drepper <drepper@redhat.com>
Cc: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-14 07:57:17 -08:00
..
irq
power [PATCH] swsusp: fix breakage with swap on LVM 2006-02-17 13:59:27 -08:00
.gitignore
acct.c
audit.c
auditsc.c [PATCH] GFP_KERNEL allocations in atomic (auditsc) 2006-02-18 15:41:50 -05:00
capability.c
compat.c [PATCH] remove bogus asm/bug.h includes. 2006-02-07 20:56:35 -05:00
configs.c
cpu.c
cpuset.c [PATCH] cpuset: oops in exit on null cpuset fix 2006-02-15 15:32:21 -08:00
dma.c
exec_domain.c
exit.c [PATCH] kjournald keeps reference to namespace 2006-02-20 20:27:38 -08:00
extable.c
fork.c [PATCH] Fix sigaltstack corruption among cloned threads 2006-03-14 07:57:17 -08:00
futex.c
hrtimer.c [PATCH] fix next_timer_interrupt() for hrtimer 2006-03-06 18:40:44 -08:00
intermodule.c [PATCH] missing license tag in intermodule 2006-02-05 11:06:52 -08:00
itimer.c
kallsyms.c
Kconfig.hz
Kconfig.preempt
kexec.c
kfifo.c
kmod.c
kprobes.c
ksysfs.c
kthread.c
Makefile
module.c [PATCH] module: strlen_user() race fix 2006-02-07 16:12:32 -08:00
mutex-debug.c
mutex-debug.h
mutex.c
mutex.h
panic.c [PATCH] prevent recursive panic from softlockup watchdog 2006-02-10 08:13:12 -08:00
params.c
pid.c
posix-cpu-timers.c
posix-timers.c
printk.c
profile.c
ptrace.c [PATCH] fix zap_thread's ptrace related problems 2006-02-15 11:05:43 -08:00
rcupdate.c [PATCH] rcu batch tuning 2006-03-08 14:14:01 -08:00
rcutorture.c
resource.c
sched.c [PATCH] remove __put_task_struct_cb export again 2006-03-11 09:19:34 -08:00
seccomp.c
signal.c [PATCH] do_sigaction: cleanup ->sa_mask manipulation 2006-02-09 16:17:36 -08:00
softirq.c
softlockup.c
spinlock.c
stop_machine.c
sys.c [PATCH] kernel/sys.c NULL noise removal 2006-02-07 20:57:47 -05:00
sys_ni.c [PATCH] Fix compile for CONFIG_SYSVIPC=n or CONFIG_SYSCTL=n 2006-02-20 20:00:11 -08:00
sysctl.c [PATCH] fix file counting 2006-03-08 14:14:01 -08:00
time.c
timer.c [PATCH] time: add barrier after updating jiffies_64 2006-03-06 18:40:44 -08:00
uid16.c
user.c
wait.c
workqueue.c