mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-18 08:46:40 +07:00
tty: the vhangup syscall is racy
We now have the infrastructure to sort this out but rather than teaching the syscall tty lock rules we move the hard work into a tty helper Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
216ba023a9
commit
2cb5998b5f
@ -729,6 +729,25 @@ void tty_vhangup(struct tty_struct *tty)
|
|||||||
|
|
||||||
EXPORT_SYMBOL(tty_vhangup);
|
EXPORT_SYMBOL(tty_vhangup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tty_vhangup_self - process vhangup for own ctty
|
||||||
|
*
|
||||||
|
* Perform a vhangup on the current controlling tty
|
||||||
|
*/
|
||||||
|
|
||||||
|
void tty_vhangup_self(void)
|
||||||
|
{
|
||||||
|
struct tty_struct *tty;
|
||||||
|
|
||||||
|
mutex_lock(&tty_mutex);
|
||||||
|
tty = get_current_tty();
|
||||||
|
if (tty) {
|
||||||
|
tty_vhangup(tty);
|
||||||
|
tty_kref_put(tty);
|
||||||
|
}
|
||||||
|
mutex_unlock(&tty_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tty_hung_up_p - was tty hung up
|
* tty_hung_up_p - was tty hung up
|
||||||
* @filp: file pointer of tty
|
* @filp: file pointer of tty
|
||||||
|
@ -1141,8 +1141,7 @@ EXPORT_SYMBOL(sys_close);
|
|||||||
asmlinkage long sys_vhangup(void)
|
asmlinkage long sys_vhangup(void)
|
||||||
{
|
{
|
||||||
if (capable(CAP_SYS_TTY_CONFIG)) {
|
if (capable(CAP_SYS_TTY_CONFIG)) {
|
||||||
/* XXX: this needs locking */
|
tty_vhangup_self();
|
||||||
tty_vhangup(current->signal->tty);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
@ -361,6 +361,7 @@ extern int is_ignored(int sig);
|
|||||||
extern int tty_signal(int sig, struct tty_struct *tty);
|
extern int tty_signal(int sig, struct tty_struct *tty);
|
||||||
extern void tty_hangup(struct tty_struct *tty);
|
extern void tty_hangup(struct tty_struct *tty);
|
||||||
extern void tty_vhangup(struct tty_struct *tty);
|
extern void tty_vhangup(struct tty_struct *tty);
|
||||||
|
extern void tty_vhangup_self(void);
|
||||||
extern void tty_unhangup(struct file *filp);
|
extern void tty_unhangup(struct file *filp);
|
||||||
extern int tty_hung_up_p(struct file *filp);
|
extern int tty_hung_up_p(struct file *filp);
|
||||||
extern void do_SAK(struct tty_struct *tty);
|
extern void do_SAK(struct tty_struct *tty);
|
||||||
|
Loading…
Reference in New Issue
Block a user