[PATCH] vcsa attribute bits -> ioctl(VT_GETHIFONTMASK)

When reading /dev/vcsa while a font with more than 256 characters is
loaded, one of the attribute bits records the 9th bit of the character.
But depending on the console driver (vgacon or fbcon for instance), that's
bit 3 or bit 0. And there is no way for userland to know that, thus no way
for userland to safely grab the screen content. So here is a (tested)
patch:

Add a VT_GETHIFONTMASK ioctl for knowing which bit is the 9th bit for VC
text (vc_hi_font_mask field of the vc_data structure).

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Samuel Thibault and committed by Linus Torvalds 533475d3 b8cf3689

+4
+2
drivers/char/vt_ioctl.c
··· 1011 return -EPERM; 1012 vt_dont_switch = 0; 1013 return 0; 1014 default: 1015 return -ENOIOCTLCMD; 1016 }
··· 1011 return -EPERM; 1012 vt_dont_switch = 0; 1013 return 0; 1014 + case VT_GETHIFONTMASK: 1015 + return put_user(vc->vc_hi_font_mask, (unsigned short __user *)arg); 1016 default: 1017 return -ENOIOCTLCMD; 1018 }
+1
include/linux/compat_ioctl.h
··· 216 COMPATIBLE_IOCTL(VT_RESIZEX) 217 COMPATIBLE_IOCTL(VT_LOCKSWITCH) 218 COMPATIBLE_IOCTL(VT_UNLOCKSWITCH) 219 /* Little p (/dev/rtc, /dev/envctrl, etc.) */ 220 COMPATIBLE_IOCTL(RTC_AIE_ON) 221 COMPATIBLE_IOCTL(RTC_AIE_OFF)
··· 216 COMPATIBLE_IOCTL(VT_RESIZEX) 217 COMPATIBLE_IOCTL(VT_LOCKSWITCH) 218 COMPATIBLE_IOCTL(VT_UNLOCKSWITCH) 219 + COMPATIBLE_IOCTL(VT_GETHIFONTMASK) 220 /* Little p (/dev/rtc, /dev/envctrl, etc.) */ 221 COMPATIBLE_IOCTL(RTC_AIE_ON) 222 COMPATIBLE_IOCTL(RTC_AIE_OFF)
+1
include/linux/vt.h
··· 60 #define VT_RESIZEX 0x560A /* set kernel's idea of screensize + more */ 61 #define VT_LOCKSWITCH 0x560B /* disallow vt switching */ 62 #define VT_UNLOCKSWITCH 0x560C /* allow vt switching */ 63 64 #endif /* _LINUX_VT_H */
··· 60 #define VT_RESIZEX 0x560A /* set kernel's idea of screensize + more */ 61 #define VT_LOCKSWITCH 0x560B /* disallow vt switching */ 62 #define VT_UNLOCKSWITCH 0x560C /* allow vt switching */ 63 + #define VT_GETHIFONTMASK 0x560D /* return hi font mask */ 64 65 #endif /* _LINUX_VT_H */