The Linux/BSD DF kernel bug

Ove Kaaven ovek at
Wed Mar 19 23:54:47 CDT 2008

Francois Gouget skrev:
>    The problem revolves around the x86 direction flag (DF), which 
>    governs whether block memory operations operate forward through 
>    memory or backwards. GCC [...] 4.3.0, assumes that the direction flag 
>    has been cleared [...] at the entry of each function, as is specified 
>    by the ABI [...] Prior to 4.3, GCC would emit a cld (clear direction 
>    flag) opcode before doing inline string or memory operations.
> So any compiler that not clear the direction flag at the start of each 
> function can cause kernel crashes when running on a buggy Linux or BSD 
> kernel.

No, it doesn't say that. The kernel is unaffected. The problem is only 
with user-mode signal handlers; if DF is set when a signal occurs, the 
signal handler may get confused.

> Does anyone know if MSVC does a cld in the right places?

Maybe. But it hardly matters. Only GCC-generated code is affected. The 
problem might then show up in Wine signal/exception handling. Things 
like, say, copying the CONTEXT structures around, for example.

In Wine, you can probably easily manually clear the flag on Wine signal 
handler entry (init_handler), if you're worried.

More information about the wine-devel mailing list