The patch titled
     vt: fix potential race in VT_WAITACTIVE handler
has been added to the -mm tree.  Its filename is
     vt-fix-potential-race-in-vt_waitactive-handler.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: vt: fix potential race in VT_WAITACTIVE handler
From: Michal Januszewski <[EMAIL PROTECTED]>

On a multiprocessor machine the VT_WAITACTIVE ioctl call may return 0 if
fg_console has already been updated in redraw_screen() but the console
switch itself hasn't been completed.  Fix this by checking fg_console in
vt_waitactive() with the console sem held.

Signed-off-by: Michal Januszewski <[EMAIL PROTECTED]>
Acked-by: Antonino Daplas <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/char/vt_ioctl.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff -puN 
drivers/char/vt_ioctl.c~vt-fix-potential-race-in-vt_waitactive-handler 
drivers/char/vt_ioctl.c
--- a/drivers/char/vt_ioctl.c~vt-fix-potential-race-in-vt_waitactive-handler
+++ a/drivers/char/vt_ioctl.c
@@ -1039,10 +1039,22 @@ int vt_waitactive(int vt)
 
        add_wait_queue(&vt_activate_queue, &wait);
        for (;;) {
-               set_current_state(TASK_INTERRUPTIBLE);
                retval = 0;
-               if (vt == fg_console)
+
+               /*
+                * Synchronize with redraw_screen(). By acquiring the console
+                * semaphore we make sure that the console switch is completed
+                * before we return. If we didn't wait for the semaphore, we
+                * could return at a point where fg_console has already been
+                * updated, but the console switch hasn't been completed.
+                */
+               acquire_console_sem();
+               set_current_state(TASK_INTERRUPTIBLE);
+               if (vt == fg_console) {
+                       release_console_sem();
                        break;
+               }
+               release_console_sem();
                retval = -EINTR;
                if (signal_pending(current))
                        break;
_

Patches currently in -mm which might be from [EMAIL PROTECTED] are

vt-fix-potential-race-in-vt_waitactive-handler.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to