The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] fix console change race exposed by CFS
@ 2007-09-29 16:47 Jan Luebbe
  2007-09-30  7:20 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Luebbe @ 2007-09-29 16:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: torvalds

From: Jan Lübbe <jluebbe@lasnet.de>

The new behaviour of CFS exposes a race which occurs if a switch is
requested when vt_mode.mode is VT_PROCESS.

The process with vc->vt_pid is signaled before vc->vt_newvt is set. This
causes the switch to fail when triggered by the monitoing process
because the target is still -1.

Signed-off-by: Jan Lübbe <jluebbe@lasnet.de>
---
Index: linux-2.6.22/drivers/char/vt_ioctl.c
===================================================================
--- linux-2.6.22.orig/drivers/char/vt_ioctl.c
+++ linux-2.6.22/drivers/char/vt_ioctl.c
@@ -1208,15 +1208,18 @@
 		/*
 		 * Send the signal as privileged - kill_pid() will
 		 * tell us if the process has gone or something else
-		 * is awry
+		 * is awry.
+		 *
+		 * We need to set vt_newvt *before* sending the signal or we
+		 * have a race.
 		 */
+		vc->vt_newvt = new_vc->vc_num;
 		if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) {
 			/*
 			 * It worked. Mark the vt to switch to and
 			 * return. The process needs to send us a
 			 * VT_RELDISP ioctl to complete the switch.
 			 */
-			vc->vt_newvt = new_vc->vc_num;
 			return;
 		}



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-30 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-29 16:47 [PATCH] fix console change race exposed by CFS Jan Luebbe
2007-09-30  7:20 ` Ingo Molnar
2007-09-30  8:31   ` Jan Luebbe
2007-09-30 15:53     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox