Skip to content

Commit

Permalink
[PATCH] selinux: fix tty locking
Browse files Browse the repository at this point in the history
Take tty_mutex when accessing ->signal->tty in selinux code.  Noted by Alan
Cox.  Longer term, we are looking at refactoring the code to provide better
encapsulation of the tty layer, but this is a simple fix that addresses the
immediate bug.

Signed-off-by: Stephen Smalley <[email protected]>
Acked-by: Alan Cox <[email protected]>
Acked-by: James Morris <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
stephensmalley authored and Linus Torvalds committed Sep 26, 2006
1 parent bc7e982 commit b20c812
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1689,10 +1689,12 @@ static inline void flush_unauthorized_files(struct files_struct * files)
{
struct avc_audit_data ad;
struct file *file, *devnull = NULL;
struct tty_struct *tty = current->signal->tty;
struct tty_struct *tty;
struct fdtable *fdt;
long j = -1;

mutex_lock(&tty_mutex);
tty = current->signal->tty;
if (tty) {
file_list_lock();
file = list_entry(tty->tty_files.next, typeof(*file), f_u.fu_list);
Expand All @@ -1712,6 +1714,7 @@ static inline void flush_unauthorized_files(struct files_struct * files)
}
file_list_unlock();
}
mutex_unlock(&tty_mutex);

/* Revalidate access to inherited open files. */

Expand Down

0 comments on commit b20c812

Please sign in to comment.