diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2006-12-08 05:36:04 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-08 11:28:38 -0500 |
commit | 24ec839c431eb79bb8f6abc00c4e1eb3b8c4d517 (patch) | |
tree | 2ff478b1925159eeac007913c2a8f19d5f5e6010 /arch | |
parent | 562f9c574e0707f9159a729ea41faf53b221cd30 (diff) |
[PATCH] tty: ->signal->tty locking
Fix the locking of signal->tty.
Use ->sighand->siglock to protect ->signal->tty; this lock is already used
by most other members of ->signal/->sighand. And unless we are 'current'
or the tasklist_lock is held we need ->siglock to access ->signal anyway.
(NOTE: sys_unshare() is broken wrt ->sighand locking rules)
Note that tty_mutex is held over tty destruction, so while holding
tty_mutex any tty pointer remains valid. Otherwise the lifetime of ttys
are governed by their open file handles. This leaves some holes for tty
access from signal->tty (or any other non file related tty access).
It solves the tty SLAB scribbles we were seeing.
(NOTE: the change from group_send_sig_info to __group_send_sig_info needs to
be examined by someone familiar with the security framework, I think
it is safe given the SEND_SIG_PRIV from other __group_send_sig_info
invocations)
[schwidefsky@de.ibm.com: 3270 fix]
[akpm@osdl.org: various post-viro fixes]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Alan Cox <alan@redhat.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: James Morris <jmorris@namei.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Jan Kara <jack@ucw.cz>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc64/solaris/misc.c | 4 | ||||
-rw-r--r-- | arch/um/kernel/exec.c | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/arch/sparc64/solaris/misc.c b/arch/sparc64/solaris/misc.c index 9ed997982f8d..e84241d5f7f4 100644 --- a/arch/sparc64/solaris/misc.c +++ b/arch/sparc64/solaris/misc.c | |||
@@ -423,9 +423,7 @@ asmlinkage int solaris_procids(int cmd, s32 pid, s32 pgid) | |||
423 | Solaris setpgrp and setsid? */ | 423 | Solaris setpgrp and setsid? */ |
424 | ret = sys_setpgid(0, 0); | 424 | ret = sys_setpgid(0, 0); |
425 | if (ret) return ret; | 425 | if (ret) return ret; |
426 | mutex_lock(&tty_mutex); | 426 | proc_clear_tty(current); |
427 | current->signal->tty = NULL; | ||
428 | mutex_unlock(&tty_mutex); | ||
429 | return process_group(current); | 427 | return process_group(current); |
430 | } | 428 | } |
431 | case 2: /* getsid */ | 429 | case 2: /* getsid */ |
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c index 0561c43b4685..8d56ec6cca79 100644 --- a/arch/um/kernel/exec.c +++ b/arch/um/kernel/exec.c | |||
@@ -39,12 +39,13 @@ static long execve1(char *file, char __user * __user *argv, | |||
39 | char __user *__user *env) | 39 | char __user *__user *env) |
40 | { | 40 | { |
41 | long error; | 41 | long error; |
42 | struct tty_struct *tty; | ||
42 | 43 | ||
43 | #ifdef CONFIG_TTY_LOG | 44 | #ifdef CONFIG_TTY_LOG |
44 | mutex_lock(&tty_mutex); | 45 | mutex_lock(&tty_mutex); |
45 | task_lock(current); /* FIXME: is this needed ? */ | 46 | tty = get_current_tty(); |
46 | log_exec(argv, current->signal->tty); | 47 | if (tty) |
47 | task_unlock(current); | 48 | log_exec(argv, tty); |
48 | mutex_unlock(&tty_mutex); | 49 | mutex_unlock(&tty_mutex); |
49 | #endif | 50 | #endif |
50 | error = do_execve(file, argv, env, ¤t->thread.regs); | 51 | error = do_execve(file, argv, env, ¤t->thread.regs); |