CVE-2008-1367: High severity gnu compiler collection vulnerability
Description of problem:
Jake Edge has reported the following gcc kernel related potential security issue on LWN:
<cite>
A change to GCC for a recent release coupled with a kernel bug has created a messy situation, with possible security implications. GCC changed some assumptions about x86 processor flags, in accordance with the ABI standard, that can lead to memory corruption for programs built with GCC 4.3.0. No one has come up with a way to exploit the flaw, at least yet, but it clearly is a problem that needs to be addressed.
The problem revolves around the x86 direction flag (DF), which governs whether block memory operations operate forward through memory or backwards. The main use for the flag is to support overlapping memory copies, where working backwards through memory may be required so that the data being copied does not get overwritten as the copy progresses. Debian hacker Aurélien Jarno reported the problem to linux-kernel on March 5th, which was found when building Steel Bank Common Lisp (SBCL) using the new compiler.
GCC's most recent release, 4.3.0, assumes that the direction flag has been cleared (i.e. memory operations go in a forward direction) at the entry of each function, as is specified by the ABI (which is, somewhat amusingly, found at sco.com [PDF]). Unfortunately, this clashes with Linux signal handlers, which get called, incorrectly, with the flag in whatever state it was in when the signal occurred. This has the effect of leaking one bit of state from the user space process that was running when the signal occurred to the signal handler, which could be in another process.
That, in itself, is a bug, seemingly with fairly minimal impact. Prior to 4.3, GCC would emit a cld (clear direction flag) opcode before doing inline string or memory operations, so those operations would start from a known state. In 4.3, GCC relies on the ABI mandate that the direction flag is cleared before entry to a function, which means that the kernel needs to arrange that before calling a signal handler. It currently doesn't, but a small patch fixes that.
The window of vulnerability is small, but was observed in SBCL. The sequence of events that would lead to memory corruption are as follows:
a user space program does an operation (memmove() for example) that sets DF a signal occurs for some process the kernel calls the signal handler the signal handler does a memmove() in what it thinks is a forward direction the memory is copied in the reverse direction, leading to corruption
</cite>
Link to the post:
http://lwn.net/Articles/272048/#Comments
Link to upstream fix:
http://git.kernel.org/?p=linux/kernel/git/x86/linux-2.6-x86.git;a=commitdiff;h=52c841e1012b8e73cc04b53f92fb933db580fb42
Other sources
gcc 4.3.x does not generate a cld instruction while compiling functions used for string manipulation such as memcpy and memmove on x86 and i386, which can prevent the direction flag (DF) from being reset in violation of ABI conventions and cause data to be copied in the wrong direction during signal handling in the Linux kernel, which might allow context-dependent attackers to trigger memory corruption. NOTE: this issue was originally reported for CPU consumption in SBCL.
— MITRE
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2008-1367?
The severity of CVE-2008-1367 is considered to be significant due to potential security implications arising from the interactions between GCC and kernel bugs.
How do I fix CVE-2008-1367?
To fix CVE-2008-1367, update the GCC version to a more recent release that has addressed the vulnerabilities introduced in version 4.3.
What software is affected by CVE-2008-1367?
CVE-2008-1367 affects GNU Compiler Collection (GCC) version 4.3.
What are the potential impacts of CVE-2008-1367?
The potential impacts of CVE-2008-1367 include security vulnerabilities that may be exploited due to improper handling of specific assumptions in the x86 architecture.
Who reported CVE-2008-1367?
CVE-2008-1367 was reported by Jake Edge on LWN, highlighting possible security issues related to a change in GCC.