Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Samuel Ortiz <sameo@openedhand.com>
Acked-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Samuel Ortiz and committed by
Linus Torvalds
8792f961 4047727e

+5 -3
+5 -3
drivers/char/vt_ioctl.c
··· 770 770 /* 771 771 * Switching-from response 772 772 */ 773 + acquire_console_sem(); 773 774 if (vc->vt_newvt >= 0) { 774 775 if (arg == 0) 775 776 /* ··· 785 784 * complete the switch. 786 785 */ 787 786 int newvt; 788 - acquire_console_sem(); 789 787 newvt = vc->vt_newvt; 790 788 vc->vt_newvt = -1; 791 789 i = vc_allocate(newvt); ··· 798 798 * other console switches.. 799 799 */ 800 800 complete_change_console(vc_cons[newvt].d); 801 - release_console_sem(); 802 801 } 803 802 } 804 803 ··· 809 810 /* 810 811 * If it's just an ACK, ignore it 811 812 */ 812 - if (arg != VT_ACKACQ) 813 + if (arg != VT_ACKACQ) { 814 + release_console_sem(); 813 815 return -EINVAL; 816 + } 814 817 } 818 + release_console_sem(); 815 819 816 820 return 0; 817 821