提交 8792f961 编写于 作者: S Samuel Ortiz 提交者: Linus Torvalds

VT ioctl race fix

When calling the RELDISP VT ioctl, we are reading vt_newvt while the
console workqueue could be messing with it (through change_console()).  We
fix this race by taking the console semaphore before reading vt_newvt.
Signed-off-by: NSamuel Ortiz <sameo@openedhand.com>
Acked-by: NAntonino Daplas <adaplas@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 4047727e
...@@ -770,6 +770,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -770,6 +770,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
/* /*
* Switching-from response * Switching-from response
*/ */
acquire_console_sem();
if (vc->vt_newvt >= 0) { if (vc->vt_newvt >= 0) {
if (arg == 0) if (arg == 0)
/* /*
...@@ -784,7 +785,6 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -784,7 +785,6 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
* complete the switch. * complete the switch.
*/ */
int newvt; int newvt;
acquire_console_sem();
newvt = vc->vt_newvt; newvt = vc->vt_newvt;
vc->vt_newvt = -1; vc->vt_newvt = -1;
i = vc_allocate(newvt); i = vc_allocate(newvt);
...@@ -798,7 +798,6 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -798,7 +798,6 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
* other console switches.. * other console switches..
*/ */
complete_change_console(vc_cons[newvt].d); complete_change_console(vc_cons[newvt].d);
release_console_sem();
} }
} }
...@@ -810,9 +809,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -810,9 +809,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
/* /*
* If it's just an ACK, ignore it * If it's just an ACK, ignore it
*/ */
if (arg != VT_ACKACQ) if (arg != VT_ACKACQ) {
release_console_sem();
return -EINVAL; return -EINVAL;
}
} }
release_console_sem();
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册