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 /kernel/sys.c | |
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 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index a0c1a29a507f..1ac2d1c5d84e 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1484,7 +1484,6 @@ asmlinkage long sys_setsid(void) | |||
1484 | pid_t session; | 1484 | pid_t session; |
1485 | int err = -EPERM; | 1485 | int err = -EPERM; |
1486 | 1486 | ||
1487 | mutex_lock(&tty_mutex); | ||
1488 | write_lock_irq(&tasklist_lock); | 1487 | write_lock_irq(&tasklist_lock); |
1489 | 1488 | ||
1490 | /* Fail if I am already a session leader */ | 1489 | /* Fail if I am already a session leader */ |
@@ -1504,12 +1503,15 @@ asmlinkage long sys_setsid(void) | |||
1504 | 1503 | ||
1505 | group_leader->signal->leader = 1; | 1504 | group_leader->signal->leader = 1; |
1506 | __set_special_pids(session, session); | 1505 | __set_special_pids(session, session); |
1506 | |||
1507 | spin_lock(&group_leader->sighand->siglock); | ||
1507 | group_leader->signal->tty = NULL; | 1508 | group_leader->signal->tty = NULL; |
1508 | group_leader->signal->tty_old_pgrp = 0; | 1509 | group_leader->signal->tty_old_pgrp = 0; |
1510 | spin_unlock(&group_leader->sighand->siglock); | ||
1511 | |||
1509 | err = process_group(group_leader); | 1512 | err = process_group(group_leader); |
1510 | out: | 1513 | out: |
1511 | write_unlock_irq(&tasklist_lock); | 1514 | write_unlock_irq(&tasklist_lock); |
1512 | mutex_unlock(&tty_mutex); | ||
1513 | return err; | 1515 | return err; |
1514 | } | 1516 | } |
1515 | 1517 | ||