1. 10 Jan, 2012 1 commit
    • Xi Wang's avatar
      ext4: fix undefined behavior in ext4_fill_flex_info() · d50f2ab6
      Xi Wang authored
      Commit 503358ae ("ext4: avoid divide by
      zero when trying to mount a corrupted file system") fixes CVE-2009-4307
      by performing a sanity check on s_log_groups_per_flex, since it can be
      set to a bogus value by an attacker.
      
      	sbi->s_log_groups_per_flex = sbi->s_es->s_log_groups_per_flex;
      	groups_per_flex = 1 << sbi->s_log_groups_per_flex;
      
      	if (groups_per_flex < 2) { ... }
      
      This patch fixes two potential issues in the previous commit.
      
      1) The sanity check might only work on architectures like PowerPC.
      On x86, 5 bits are used for the shifting amount.  That means, given a
      large s_log_groups_per_flex value like 36, groups_per_flex = 1 << 36
      is essentially 1 << 4 = 16, rather than 0.  This will bypass the check,
      leaving s_log_groups_per_flex and groups_per_flex inconsistent.
      
      2) The sanity check relies on undefined behavior, i.e., oversized shift.
      A standard-confirming C compiler could rewrite the check in unexpected
      ways.  Consider the following equivalent form, assuming groups_per_flex
      is unsigned for simplicity.
      
      	groups_per_flex = 1 << sbi->s_log_groups_per_flex;
      	if (groups_per_flex == 0 || groups_per_flex == 1) {
      
      We compile the code snippet using Clang 3.0 and GCC 4.6.  Clang will
      completely optimize away the check groups_per_flex == 0, leaving the
      patched code as vulnerable as the original.  GCC keeps the check, but
      there is no guarantee that future versions will do the same.
      Signed-off-by: default avatarXi Wang <xi.wang@gmail.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      d50f2ab6
  2. 05 Jan, 2012 5 commits
  3. 04 Jan, 2012 13 commits
  4. 29 Dec, 2011 4 commits
  5. 28 Dec, 2011 3 commits
  6. 21 Dec, 2011 1 commit
    • Theodore Ts'o's avatar
      ext4: remove unneeded file_remove_suid() from ext4_ioctl() · 22cdfca5
      Theodore Ts'o authored
      In the code to support EXT4_IOC_MOVE_EXT, ext4_ioctl calls
      file_remove_suid() after the call to ext4_move_extents() if any
      extents has been moved.  There are at least three things wrong with
      this.  First, file_remove_suid() should be called with i_mutex down,
      which is not here.  Second, it should be called before the donor file
      has been modified, to avoid a potential race condition.  Third, and
      most importantly, it's pointless, because ext4_file_extents() already
      checks if the donor file has the setuid or setgid bit set, and will
      return an error in that case.  So the first two objections don't
      really matter, since file_remove_suid() will never need to modify the
      inode in any case.
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      22cdfca5
  7. 19 Dec, 2011 1 commit
    • Robin Dong's avatar
      ext4: optimize ext4_find_delalloc_range() in nodelalloc mode · 8c48f7e8
      Robin Dong authored
      We found performance regression when using bigalloc with "nodelalloc"
      (1MB cluster size):
      
      1. mke2fs -C 1048576 -O ^has_journal,bigalloc /dev/sda
      2. mount -o nodelalloc /dev/sda /test/
      3. time dd if=/dev/zero of=/test/io bs=1048576 count=1024
      
      The "dd" will cost about 2 seconds to finish, but if we mke2fs without
      "bigalloc", "dd" will only cost less than 1 second.
      
      The reason is: when using ext4 with "nodelalloc", it will call
      ext4_find_delalloc_cluster() nearly everytime it call
      ext4_ext_map_blocks(), and ext4_find_delalloc_range() will also scan
      all pages in cluster because no buffer is "delayed".  A cluster has
      256 pages (1MB cluster), so it will scan 256 * 256k pags when creating
      a 1G file. That severely hurts the performance.
      
      Therefore, we return immediately from ext4_find_delalloc_range() in
      nodelalloc mode, since by definition there can't be any delalloc
      pages.
      Signed-off-by: default avatarRobin Dong <sanbai@taobao.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      8c48f7e8
  8. 18 Dec, 2011 4 commits
  9. 17 Dec, 2011 1 commit
  10. 16 Dec, 2011 7 commits