[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>
This commit is contained in:
committed by
Linus Torvalds
parent
562f9c574e
commit
24ec839c43
@@ -309,6 +309,12 @@ extern void tty_ldisc_flush(struct tty_struct *tty);
|
||||
extern int tty_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
extern dev_t tty_devnum(struct tty_struct *tty);
|
||||
extern void proc_clear_tty(struct task_struct *p);
|
||||
extern void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
|
||||
extern void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
|
||||
extern struct tty_struct *get_current_tty(void);
|
||||
|
||||
extern struct mutex tty_mutex;
|
||||
|
||||
/* n_tty.c */
|
||||
@@ -335,10 +341,5 @@ extern void console_print(const char *);
|
||||
extern int vt_ioctl(struct tty_struct *tty, struct file * file,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
|
||||
static inline dev_t tty_devnum(struct tty_struct *tty)
|
||||
{
|
||||
return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user