8 ms·
Liberation fonts causing Windows 7 SP1 to BSOD
- tobiasu 14y agoWhy does Windows render(?) glyphs in the kernel? What's the technical justification for doing something this complex and error-prone in kernel space? Btw, this attachment seems to contain the real meat (STACK TEXT): https://bugs.freedesktop.org/attachment.cgi?id=77055 https://bugs.freedesktop.org/attachment.cgi?id=77055
- pavlov 14y agoThe original design of Windows NT had the graphics stack in user space. It remained this way in the first two releases, 3.1 and 3.5, but the performance was not competitive with desktop contemporaries like OS/2 and Win95 that had graphics in the kernel. So Windows NT 4.0 reverted to that design. I guess part of the reason for the poor performance was that video card drivers of the era were tightly coupled with the OS, effectively replacing GDI functions with their own implementations. The NT 3.x design made it difficult to support these existing graphics accelerators.
- derefr 14y agoIf I were going to write a microkernel OS today, and was going to rely entirely on the GPU for rendering, could I get away with putting the graphics stack entirely in user-space, or would it still be relatively slower?
- iso8859-1 14y agoUsually the user-space overhead is real tiny, I can't imagine it would be needed to place it in the kernel. Linux has the high-level graphics stack in user-space and it works just fine.
- qb45 14y agoIn Linux systems good chunk of graphics stack already resides in userspace. The kernel provides only modesetting, GPU memory management, access multiplexing and isolation. Applications render by calling OpenGL library, which obviously executes in calling processes. OpenGL library asks the kernel to allocate required memory buffers, prepares code for the GPU and submits it to the kernel for execution. Kernel collects jobs submitted by processes, executes them on the GPU and notifies processes on completion. When application wants to display something on the screen, it shares its buffer with the X server (or equivalent) and instructs it to redraw its window from this buffer. The display server uses some special syscall to obtain access to screen output buffer.
- klodolph 14y agoRemember the news that L4D2 on Linux outperformed the Windows version? As I understand it, the L4D2 code base uses Direct 3D, and on Linux it uses a D3D emulator with OpenGL as the backend, and yet after going through these user-space hoops it still gets a better framerate. The best theory I've heard is that context switching is cheaper on Linux.
- YokoZar 14y ago"D3D emulator with OpenGL as the backend" sounds an awful lot like Wine. There've been reports of Wine apps running faster than their Windows equivalent too, although usually some wine bug or another gets in the way of performance.
- simcop2387 14y agoThis wouldn't surprise me. Based on the console output, Counterstrike Source does the same thing. Lots of output about Direct3D that look exactly like messages from wine. I suspect they did this to speed up porting.
- qb45 14y agoMaybe they use winelib - a library built by WINE project which provides Windows API implementation extracted from WINE.
- qb45 14y agoI've found quite readable and relatively high level description of memory management and command submission in Linux drivers for Intel GPUs. http://blog.ffwll.ch/2013/01/i915gem-crashcourse-overview.html http://blog.ffwll.ch/2013/01/i915gem-crashcourse-overview.ht... This (plus some low-level register poking) is the stuff you would need to implement in your GPU daemon. Actual generation of drawing commands, compilation of shaders etc is performed by applications. The overhead should be in the order of few context switches to the GPU server for each frame rendered by any application (in Linux it's few syscalls instead of context switches). Probably not terrible.
- tanzam75 14y agoGraphics drivers were moved into user mode in Windows Vista. If you've ever seen the screen blink, and a balloon pop up saying that the graphics driver was restarted -- that would've been a bluescreen in XP. I wonder why they didn't move the rest of GDI out of the kernel at the same time? A composing window manager was also introduced in Windows Vista, which really cuts down on the number of window repaints. Surely they can afford to take the performance hit now?
- yuhong 14y agoThey still had to support XPDM drivers, for one thing. Fortunately they no longer have to with Win8.
- jrabone 14y agoSome of the Win32 GDI functions have been kernel-mode since NT4 for performance reasons (closer to the graphics driver). As for the font problem, the on-going saga of KB2753842 may be to blame: http://support.microsoft.com/kb/2753842 http://support.microsoft.com/kb/2753842 It looks like MS have had a few attempts at tightening up the potential for security exploits caused by executing what can effectively be untrusted code (the glyph program) in kernel space. This is why fonts are considered system components - they are code, not data, executing on a VM. If you like MS conspiracy theories of course, you can pretend that it's a deliberate ploy to break LibreOffice, but personally I think that's tin-foil hat territory. Most likely there's a bug in the GDI code triggered by an unusual glyph in the font (perhaps in turn generated by a bug in whatever font design software was used). Complexity + poor choice of performance optimisation = fail. At least the kernel bug check is working as designed - if only all OSes were so robust in the face of memory corruption.
- chris_wot 14y agoHi, I filed the bug. I definitely don't think that Microsoft deliberately went out of their way to cause issues for LibreOffice. I am surprised that they basically allow untrusted input like a font to be passed to a kernel function, which can then cause the kernel to panic. I don't think I've seen any kernel deal directly with fonts. I understand the reasoning they added the GDI to kernel space, but IMHO it seems to me that they should seriously reconsider their reasoning. At the very least, they need to relook at their glyph parsing/building algorithm and perhaps look into better fuzz testing around these routines. Just my 2c :-)
- wbl 14y agoWe have a crash caused by memory writes in the kernel. What part of this doesn't suggest kernel mode exploitation via a cleverly-crafted font that can be embedded into a web page or PDF? Font bugs should result in errors, not BSODs. Untrusted code on a VM is easy to secure: make the VM do nothing more then draw some glyphs, and check every access!
- yuhong 14y agoAssuming the rest of the code is perfect. Remember Duqu?
- chjj 14y agoThis is the kind of stuff that makes Windows seem like alien territory to me. The last time I looked at code using the win32 api, I noticed that the spawn() call accepts a bitmask which can determine whether a window is drawn for the process or not. The window system is so tightly coupled with the kernel that it's in the system calls? I guess Windows really earns its name.
- hp50g 14y agoThis is win32 and does not represent the NT kernel in any way. There is a load of stuff they had to port from win16 which was shit and have been stuck with it ever since that effectively compromises NT's architecture. GDI in kernel space was a pragmatic choice considering the other competitors on the workstation market were basically HP, Sun and SGI and they all had nearly graphics acceleration. NT itself is flipping marvellous :)
- EvanAnderson 14y agoI like to tell people "Deep inside all the Windows NT distributions there's a great OS dying to get out...". REACTOS gives me hope that, someday, there'll be a distribution of an NT-based operating system w/o Win32. (Interix on top of NT w/o Win32 would have been close to what I'd have been interested in seeing...)
- Surio 14y ago:) +1 for REACTOS. I am one of those that is looking forward to that one becoming mainstream... They have a GSOC running this year too. I hope they get enough traction to get it in some shape. Here's to that project's success.
- hp50g 14y agoTBH win32 was pretty good and well thought out. How it was plugged into NT and how it evolved wasn't.
- pjmlp 14y agoThe "Inside Windows " book series are a nice way to get an overview how the Windows kernel is implemented.
- chris_wot 14y agoLooks like an issue for Mathematica users also: http://mathematica.stackexchange.com/questions/15456/version-9-blue-screen-or-self-test-error-on-windows-7-64-bit http://mathematica.stackexchange.com/questions/15456/version... Mathematica even had to release an update for it: http://support.wolfram.com/kb/11160 http://support.wolfram.com/kb/11160
- sblom 14y agoI don't know that they _had_ to release an update, but as a Mathematica user who was seeing WordPad (yes, WordPad) bluescreen my computer, I was really happy that Wolfram fixed it for me so I didn't have to wait for Windows to.
- yuhong 14y agoHope they also reported the BSoDing fonts to MSRC too.
- sp332 14y agoCan a malicious (or unfortunate) webpage bluescreen your computer, just by serving this font as a web-font to render a page?
- chris_wot 14y agoI've considered this. I don't believe that Microsoft loads ttf fonts directly from webpages. I also don't believe that IE uses the Win32 API for font rendering, but uses it's own engine. Someone may want to correct me on these points!
- shawn-butler 14y agoIE9+ uses DirectWrite and Direct2D API for font rendering. [0] That is why they added a "Hardware Acceleration" setting. I would guess this bug could have the same effect in IE. I have no idea what it does when you turn off hardware acceleration though. [0] http://msdn.microsoft.com/en-us/library/hh237264(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/hh237264(v=vs.85).as...
- yuhong 14y agoThat is not true. IE do load EOT and later WOFF fonts from webpages and pass them to the OS engine. Even the other web browsers still uses the OS engine, they just sanitize the font using OTS before doing so. Hence if reproducible yes this should be sent to MSRC.
- yuhong 14y agochris_wot: Just did so, check your mailbox.
- darkchasma 14y agoThis is poetic.
- smosher 14y agoIs that commentary on Windows or on the Liberation fonts? (I'm cool either way.)
- chris_wot 14y agoI should note that I had the darndest time trying to install the Winows debugging tools on my laptop - not least because I believe that Windows caches all the fonts and was bug checking every time I did so. Eventually, I discovered someone else had repackaged them here: http://www.codemachine.com/resources.html http://www.codemachine.com/resources.html Thanks, whoever that person is!
- hp50g 14y agoGoogle windows SDK. Download, install. Sorted. What's hard about that?
- chris_wot 14y agoYour assumptions make you look foolish. I did indeed Google for the installer, I then attempted to install it. Here's where the difficulties were: Firstly, it's massive. Recall that I said that every 45 minties or so my laptop would BSOD. Secondly, when I tried to install it the install failed with obscure Windows installer errors.
- hp50g 14y agoI've installed it hundreds of times with no problems. Its also not huge - it only downloads the parts you need which includes just the debuggers if you want. What obscure msi errors? Just to add, when windows crashes it leaves a minidump on disk. Usual practice is to get this on another host and debug there. If you're out or away from such a facility, that's what system restore is for.
- deleted 14y ago[deleted]
- chris_wot 14y agoThanks for the lecture. System restore, for a variety of reasons, wasn't going to help me here. I was able to troubleshoot and restore my system to normal without system restore. Not to mention had I installed LibreOffice again, the issue would have reappeared - system restore would not have helped.
- ferongr 14y agoFWIW I just updated LibreOffice to 4.0.1.2 from 4.0.0 and cannot reproduce the issue with the steps in the bugzilla link so there may be some additional requirement for the bug to surface. Possibly a GPU from a specific manufacturer?
- driverdan 14y agoI don't understand how this could be a bug with the fonts. Fonts should never be able to BSOD a system.
- ChuckMcM 14y agoFonts are rendered by the kernel (architecture bug explained above), fonts have "code" in the form of hints which directs the rendering. Bad data in the fonts and/or hinting leads to the rendering algorithm overwriting memory/stack. Since we're in kernel mode it doesn't generate a fault and instead corrupts the kernel. Blam! BSOD. No doubt there are zero day exploits in there as well.
- yuhong 14y agoDuqu is one example of such an exploit.
- qb45 14y agoActually, even without hints or any other "code" parsing nontrivial formats provides opportunities for bugs causing buffer overflows or other memory corruptions. This simply shouldn't be done in the kernel, period. However, twenty years ago (when this code likely has been written) security in the PC world was pretty much nonexistent and nobody cared about such issues.
- yuhong 14y agoAFAIK MS's own web browser did not support embedded fonts until IE4 in 1997.
- jmvoodoo 14y agoSeems like this is a possible vector for font based kernel exploits. Didn't Gauss have some mystery font? Edit: It was Gauss, not Flame, that has the font.
- Samuel_Michon 14y ago“It's not a bug, it’s an undocumented feature!”
- chris_wot 14y agoReboots to Linux?