[PATCH] 2.5: console close race fix

From: Robert Love (rml@tech9.net)
Date: Fri Jan 25 2002 - 18:21:09 EST


Linus,

There is a race between con_flush_chars and con_close. I first
discovered it with the preemptive kernel patch, but it is a general SMP
race. The idea for the fix is originally by Andrew Morton.

This fix is in 2.4. Please, apply.

        Robert Love

diff -urN linux-2.5.3-pre5/drivers/char/console.c linux/drivers/char/console.c
--- linux-2.5.3-pre5/drivers/char/console.c Thu Jan 24 17:02:57 2002
+++ linux/drivers/char/console.c Fri Jan 25 18:12:36 2002
@@ -2349,14 +2349,18 @@
 
 static void con_flush_chars(struct tty_struct *tty)
 {
- struct vt_struct *vt = (struct vt_struct *)tty->driver_data;
+ struct vt_struct *vt;
 
         if (in_interrupt()) /* from flush_to_ldisc */
                 return;
 
         pm_access(pm_con);
+
+ /* if we race with con_close(), vt may be null */
         acquire_console_sem();
- set_cursor(vt->vc_num);
+ vt = (struct vt_struct *)tty->driver_data;
+ if (vt)
+ set_cursor(vt->vc_num);
         release_console_sem();
 }
 

 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jan 31 2002 - 21:00:37 EST