OSDN Git Service

2.4: fix memory corruption from misinterpreted bad_inode_ops return values
authordann frazier <dannf@dannf.org>
Thu, 24 Jan 2008 06:12:12 +0000 (23:12 -0700)
committerWilly Tarreau <w@1wt.eu>
Sun, 3 Feb 2008 15:37:46 +0000 (16:37 +0100)
commitf654703d45148071037e8b904e7a674c6d78466a
treea1db5ec66c796f151f2cd2ed47e511b884a835c1
parentf1e981303d0f4ccbf3dcd64af41bbf85c62a7122
2.4: fix memory corruption from misinterpreted bad_inode_ops return values

This is a 2.4 backport of a linux-2.6 change by Eric Sandeen
(commit be6aab0e9fa6d3c6d75aa1e38ac972d8b4ee82b8)

CVE-2006-5753 was assigned for this issue.

I've built and boot-tested this, but I'm not sure how to exercise
these codepaths.

Commit log from 2.6 follows.

  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.

Signed-off-by: dann frazier <dannf@hp.com>
fs/bad_inode.c