Skip to contentSkip to conversation

vt: VT ioctl race fix

PATCH In review Antonino A. Daplas 1 participant 1 message Sep 29, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/17 vt: VT ioctl race fix

From: Samuel Ortiz <[email protected]>

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.

---

 drivers/char/vt_ioctl.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/char/vt_ioctl.c +5 -3
index 60111a7..c872774 100644
@@ -812,6 +812,7 @@ #endif
 		/*
 		 * Switching-from response
 		 */
+		acquire_console_sem();
 		if (vc->vt_newvt >= 0) {
 			if (arg == 0)
 				/*
@@ -826,7 +827,6 @@ #endif
 				 * complete the switch.
 				 */
 				int newvt;
-				acquire_console_sem();
 				newvt = vc->vt_newvt;
 				vc->vt_newvt = -1;
 				i = vc_allocate(newvt);
@@ -840,7 +840,6 @@ #endif
 				 * other console switches..
 				 */
 				complete_change_console(vc_cons[newvt].d);
-				release_console_sem();
 			}
 		}
 
@@ -852,9 +851,12 @@ #endif
 			/*
 			 * If it's just an ACK, ignore it
 			 */
-			if (arg != VT_ACKACQ)
+			if (arg != VT_ACKACQ) {
+				release_console_sem();
 				return -EINVAL;
+			}
 		}
+		release_console_sem();
 
 		return 0;
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/