Skip to contentSkip to conversation

Kernel crash triggered by con2fb

PATCH In review Petr Vandrovec 2 participants 2 messages Apr 24, 2003

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

PATCH 1/1 Kernel crash triggered by con2fb

Hi James,
it is not nice that anybody can crash my kernel by
doing con2fb with unallocated VT.
Thanks,
Petr Vandrovec [email protected]

drivers/video/console/fbcon.c +5 -1
diff -urN linux-2.5.68-c1216.dist/drivers/video/console/fbcon.c linux-2.5.68-c1216.fb/drivers/video/console/fbcon.c
@@ -294,13 +294,17 @@
  *	Maps a virtual console @unit to a frame buffer device
  *	@newidx.
  */
-void set_con2fb_map(int unit, int newidx)
+int set_con2fb_map(int unit, int newidx)
 {
 	struct vc_data *vc = vc_cons[unit].d;
 
+	if (!vc) {
+		return -ENODEV;
+	}
 	con2fb_map[unit] = newidx;
 	fbcon_is_default = (vc->vc_sw == &fb_con) ? 1 : 0;
 	take_over_console(&fb_con, unit, unit, fbcon_is_default);
+	return 0;
 }
 
 /*
drivers/video/console/fbcon.h +1 -1
diff -urN linux-2.5.68-c1216.dist/drivers/video/console/fbcon.h linux-2.5.68-c1216.fb/drivers/video/console/fbcon.h
@@ -38,7 +38,7 @@
 
 /* drivers/video/console/fbcon.c */
 extern char con2fb_map[MAX_NR_CONSOLES];
-extern void set_con2fb_map(int unit, int newidx);
+extern int set_con2fb_map(int unit, int newidx);
 
     /*
      *  Attribute Decoding
drivers/video/fbmem.c +1 -1
diff -urN linux-2.5.68-c1216.dist/drivers/video/fbmem.c linux-2.5.68-c1216.fb/drivers/video/fbmem.c
@@ -1035,7 +1035,7 @@
 		if (!registered_fb[con2fb.framebuffer])
 		    return -EINVAL;
 		if (con2fb.console != 0)
-			set_con2fb_map(con2fb.console-1, con2fb.framebuffer);
+			return set_con2fb_map(con2fb.console-1, con2fb.framebuffer);
 		else
 			fb_console_init();		
 		return 0;
#1 lore raw
Quoted 4 lines

Hi James,
it is not nice that anybody can crash my kernel by
doing con2fb with unallocated VT.

Thanks. Applied.