]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
fix bad_inode_ops memory corruption (CVE-2006-5753)
authorEric Sandeen <sandeen@redhat.com>
Tue, 20 Feb 2007 23:57:05 +0000 (00:57 +0100)
committerAdrian Bunk <bunk@stusta.de>
Tue, 20 Feb 2007 23:57:05 +0000 (00:57 +0100)
commite48d2dd437e8f5c1fd4ae7ef8c77142e58491151
tree8860ecda4331e4f2ab4d22dee632014f08c8bf14
parent82ea2673f38fd5987aa43351f81110e7c7acd32b
fix bad_inode_ops memory corruption (CVE-2006-5753)

CVE-2006-5753 is for a case where an inode can be marked bad, switching
the ops to bad_inode_ops, which are all connected as:

static int return_EIO(void)
{
        return -EIO;
}

#define EIO_ERROR ((void *) (return_EIO))

static struct inode_operations bad_inode_ops =
{
        .create         = bad_inode_create
...etc...

The problem here is that the void cast causes return types to not be
promoted, and for ops such as listxattr which expect more than 32 bits of
return value, the 32-bit -EIO is interpreted as a large positive 64-bit
number, i.e. 0x00000000fffffffa instead of 0xfffffffa.

This goes particularly badly when the return value is taken as a number of
bytes to copy into, say, a user's buffer for example...

I originally had coded up the fix by creating a return_EIO_<TYPE> macro
for each return type, like this:

static int return_EIO_int(void)
{
    return -EIO;
}
#define EIO_ERROR_INT ((void *) (return_EIO_int))

static struct inode_operations bad_inode_ops =
{
    .create         = EIO_ERROR_INT,
...etc...

but Al felt that it was probably better to create an EIO-returner for each
actual op signature.  Since so few ops share a signature, I just went ahead
& created an EIO function for each individual file & inode op that returns
a value.

Adrian Bunk:
backported to 2.6.16

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
fs/bad_inode.c