aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorPeter Zijlstra <[email protected]>2006-12-08 10:36:04 +0000
committerLinus Torvalds <[email protected]>2006-12-08 16:28:38 +0000
commit24ec839c431eb79bb8f6abc00c4e1eb3b8c4d517 (patch)
tree2ff478b1925159eeac007913c2a8f19d5f5e6010 /security/selinux/hooks.c
parent[PATCH] time: re-add verify_pmtmr_rate (diff)
downloadkernel-24ec839c431eb79bb8f6abc00c4e1eb3b8c4d517.tar.gz
kernel-24ec839c431eb79bb8f6abc00c4e1eb3b8c4d517.zip
[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) [[email protected]: 3270 fix] [[email protected]: various post-viro fixes] Signed-off-by: Peter Zijlstra <[email protected]> Acked-by: Alan Cox <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Prarit Bhargava <[email protected]> Cc: Chris Wright <[email protected]> Cc: Roland McGrath <[email protected]> Cc: Stephen Smalley <[email protected]> Cc: James Morris <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jeff Dike <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: Jan Kara <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c11
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)
struct tty_struct *tty;
struct fdtable *fdt;
long j = -1;
+ int drop_tty = 0;
mutex_lock(&tty_mutex);
- tty = current->signal->tty;
+ tty = get_current_tty();
if (tty) {
file_list_lock();
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)
struct inode *inode = file->f_dentry->d_inode;
if (inode_has_perm(current, inode,
FILE__READ | FILE__WRITE, NULL)) {
- /* Reset controlling tty. */
- current->signal->tty = NULL;
- current->signal->tty_old_pgrp = 0;
+ drop_tty = 1;
}
}
file_list_unlock();
+
+ /* Reset controlling tty. */
+ if (drop_tty)
+ proc_set_tty(current, NULL);
}
mutex_unlock(&tty_mutex);