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 /security/selinux | |
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 'security/selinux')
-rw-r--r-- | security/selinux/hooks.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 44e9cd470543..f5df8c70a9b5 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -1695,9 +1695,10 @@ static inline void flush_unauthorized_files(struct files_struct * files) | |||
1695 | struct tty_struct *tty; | 1695 | struct tty_struct *tty; |
1696 | struct fdtable *fdt; | 1696 | struct fdtable *fdt; |
1697 | long j = -1; | 1697 | long j = -1; |
1698 | int drop_tty = 0; | ||
1698 | 1699 | ||
1699 | mutex_lock(&tty_mutex); | 1700 | mutex_lock(&tty_mutex); |
1700 | tty = current->signal->tty; | 1701 | tty = get_current_tty(); |
1701 | if (tty) { | 1702 | if (tty) { |
1702 | file_list_lock(); | 1703 | file_list_lock(); |
1703 | file = list_entry(tty->tty_files.next, typeof(*file), f_u.fu_list); | 1704 | file = list_entry(tty->tty_files.next, typeof(*file), f_u.fu_list); |
@@ -1710,12 +1711,14 @@ static inline void flush_unauthorized_files(struct files_struct * files) | |||
1710 | struct inode *inode = file->f_dentry->d_inode; | 1711 | struct inode *inode = file->f_dentry->d_inode; |
1711 | if (inode_has_perm(current, inode, | 1712 | if (inode_has_perm(current, inode, |
1712 | FILE__READ | FILE__WRITE, NULL)) { | 1713 | FILE__READ | FILE__WRITE, NULL)) { |
1713 | /* Reset controlling tty. */ | 1714 | drop_tty = 1; |
1714 | current->signal->tty = NULL; | ||
1715 | current->signal->tty_old_pgrp = 0; | ||
1716 | } | 1715 | } |
1717 | } | 1716 | } |
1718 | file_list_unlock(); | 1717 | file_list_unlock(); |
1718 | |||
1719 | /* Reset controlling tty. */ | ||
1720 | if (drop_tty) | ||
1721 | proc_set_tty(current, NULL); | ||
1719 | } | 1722 | } |
1720 | mutex_unlock(&tty_mutex); | 1723 | mutex_unlock(&tty_mutex); |
1721 | 1724 | ||