⬢ DragonFlyBSD Kernel Audit
DF-4158 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/video/fb/vga.c
+++ b/sys/dev/video/fb/vga.c
@@ -1211,6 +1211,11 @@
 
     if (page < 0 || page >= 8)
 	return EINVAL;
+    /* Each font page is 0x4000 bytes = 512 glyphs of 32 bytes.  The glyph
+     * index and count come from our callers today, but validate them here
+     * so no future caller can walk bcopy_*io past the aperture. */
+    if (ch < 0 || count < 0 || (u_int)ch + (u_int)count > 512)
+	return EINVAL;
     segment = FONT_BUF + 0x4000*page;
     if (page > 3)
 	segment -= 0xe000;
@@ -1264,6 +1269,11 @@
 
     if (page < 0 || page >= 8)
 	return EINVAL;
+    /* Each font page is 0x4000 bytes = 512 glyphs of 32 bytes.  The glyph
+     * index and count come from our callers today, but validate them here
+     * so no future caller can walk bcopy_*io past the aperture. */
+    if (ch < 0 || count < 0 || (u_int)ch + (u_int)count > 512)
+	return EINVAL;
     segment = FONT_BUF + 0x4000*page;
     if (page > 3)
 	segment -= 0xe000;