1. 27 Nov, 2018 1 commit
    • Pan Bian's avatar
      ext2: fix potential use after free · ecebf55d
      Pan Bian authored
      
      
      The function ext2_xattr_set calls brelse(bh) to drop the reference count
      of bh. After that, bh may be freed. However, following brelse(bh),
      it reads bh->b_data via macro HDR(bh). This may result in a
      use-after-free bug. This patch moves brelse(bh) after reading field.
      
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      ecebf55d
  2. 15 Nov, 2018 1 commit
  3. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard...
      b2441318
  4. 22 Jun, 2017 2 commits
  5. 28 Sep, 2016 1 commit
  6. 06 Jul, 2016 1 commit
    • Carlos Maiolino's avatar
      ext2: fix filesystem deadlock while reading corrupted xattr block · ff0031d8
      Carlos Maiolino authored
      
      
      This bug can be reproducible with fsfuzzer, although, I couldn't reproduce it
      100% of my tries, it is quite easily reproducible.
      
      During the deletion of an inode, ext2_xattr_delete_inode() does not check if the
      block pointed by EXT2_I(inode)->i_file_acl is a valid data block, this might
      lead to a deadlock, when i_file_acl == 1, and the filesystem block size is 1024.
      
      In that situation, ext2_xattr_delete_inode, will load the superblock's buffer
      head (instead of a valid i_file_acl block), and then lock that buffer head,
      which, ext2_sync_super will also try to lock, making the filesystem deadlock in
      the following stack trace:
      
      root     17180  0.0  0.0 113660   660 pts/0    D+   07:08   0:00 rmdir
      /media/test/dir1
      
      [<ffffffff8125da9f>] __sync_dirty_buffer+0xaf/0x100
      [<ffffffff8125db03>] sync_dirty_buffer+0x13/0x20
      [<ffffffffa03f0d57>] ext2_sync_super+0xb7/0xc0 [ext2]
      [<ffffffffa03f10b9>] ext2_error+0x119/0x130 [ext2]
      [<ffffffffa03e9d93>] ext2_free_blocks+0x83/0x350 [ext2]
      [<ffffffffa03f3d03>] ext2_xattr_delete_inode+0x173/0x190 [ext2]
      [<ffffffffa03ee9e9>] ext2_evict_inode+0xc9/0x130 [ext2]
      [<ffffffff8123fd23>] evict+0xb3/0x180
      [<ffffffff81240008>] iput+0x1b8/0x240
      [<ffffffff8123c4ac>] d_delete+0x11c/0x150
      [<ffffffff8122fa7e>] vfs_rmdir+0xfe/0x120
      [<ffffffff812340ee>] do_rmdir+0x17e/0x1f0
      [<ffffffff81234dd6>] SyS_rmdir+0x16/0x20
      [<ffffffff81838cf2>] entry_SYSCALL_64_fastpath+0x1a/0xa4
      [<ffffffffffffffff>] 0xffffffffffffffff
      
      Fix this by using the same approach ext4 uses to test data blocks validity,
      implementing ext2_data_block_valid.
      
      An another possibility when the superblock is very corrupted, is that i_file_acl
      is 1, block_count is 1 and first_data_block is 0. For such situations, we might
      have i_file_acl pointing to a 'valid' block, but still step over the superblock.
      The approach I used was to also test if the superblock is not in the range
      described by ext2_data_block_valid() arguments
      
      Signed-off-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      ff0031d8
  7. 23 Feb, 2016 2 commits
    • Andreas Gruenbacher's avatar
      mbcache: add reusable flag to cache entries · 6048c64b
      Andreas Gruenbacher authored
      
      
      To reduce amount of damage caused by single bad block, we limit number
      of inodes sharing an xattr block to 1024. Thus there can be more xattr
      blocks with the same contents when there are lots of files with the same
      extended attributes. These xattr blocks naturally result in hash
      collisions and can form long hash chains and we unnecessarily check each
      such block only to find out we cannot use it because it is already
      shared by too many inodes.
      
      Add a reusable flag to cache entries which is cleared when a cache entry
      has reached its maximum refcount.  Cache entries which are not marked
      reusable are skipped by mb_cache_entry_find_{first,next}. This
      significantly speeds up mbcache when there are many same xattr blocks.
      For example for xattr-bench with 5 values and each process handling
      20000 files, the run for 64 processes is 25x faster with this patch.
      Even for 8 processes the speedup is almost 3x. We have also verified
      that for situations where there is only one xattr block of each kind,
      the patch doesn't have a measurable cost.
      
      [JK: Remove handling of setting the same value since it is not needed
      anymore, check for races in e_reusable setting, improve changelog,
      add measurements]
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      6048c64b
    • Jan Kara's avatar
      mbcache2: rename to mbcache · 7a2508e1
      Jan Kara authored
      
      
      Since old mbcache code is gone, let's rename new code to mbcache since
      number 2 is now meaningless. This is just a mechanical replacement.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      7a2508e1
  8. 22 Feb, 2016 1 commit
    • Jan Kara's avatar
      ext2: convert to mbcache2 · be0726d3
      Jan Kara authored
      
      
      The conversion is generally straightforward. We convert filesystem from
      a global cache to per-fs one. Similarly to ext4 the tricky part is that
      xattr block corresponding to found mbcache entry can get freed before we
      get buffer lock for that block. So we have to check whether the entry is
      still valid after getting the buffer lock.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      be0726d3
  9. 06 Jan, 2016 1 commit
  10. 14 Dec, 2015 1 commit
  11. 14 Nov, 2015 1 commit
  12. 15 Apr, 2015 1 commit
  13. 26 Jan, 2014 1 commit
  14. 21 Jan, 2013 2 commits
  15. 11 Apr, 2012 1 commit
    • Jan Kara's avatar
      ext2: Remove s_dirt handling · b838ec22
      Jan Kara authored
      
      
      Places which modify superblock feature / state fields mark the superblock
      buffer dirty so it is written out by flusher thread. Thus there's no need to
      set s_dirt there.
      
      The only other fields changing in the superblock are the numbers of free
      blocks, free inodes and s_wtime. There's no real need to write (or even
      compute) these periodically. Free blocks / inodes counters are recomputed on
      every mount from group counters anyway and value of s_wtime is only
      informational and imprecise anyway. So it should be enough to write these
      opportunistically on mount, remount, umount, and sync_fs times.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      b838ec22
  16. 09 Jan, 2012 1 commit
  17. 22 Jul, 2011 1 commit
  18. 31 Mar, 2011 1 commit
  19. 10 Jan, 2011 2 commits
  20. 26 Oct, 2010 1 commit
  21. 09 Aug, 2010 4 commits
  22. 21 May, 2010 2 commits
  23. 04 Mar, 2010 1 commit
    • Christoph Hellwig's avatar
      dquot: cleanup space allocation / freeing routines · 5dd4056d
      Christoph Hellwig authored
      
      
      Get rid of the alloc_space, free_space, reserve_space, claim_space and
      release_rsv dquot operations - they are always called from the filesystem
      and if a filesystem really needs their own (which none currently does)
      it can just call into it's own routine directly.
      
      Move shared logic into the common __dquot_alloc_space,
      dquot_claim_space_nodirty and __dquot_free_space low-level methods,
      and rationalize the wrappers around it to move as much as possible
      code into the common block for CONFIG_QUOTA vs not.  Also rename
      all these helpers to be named dquot_* instead of vfs_dq_*.
      
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      5dd4056d
  24. 16 Dec, 2009 1 commit
    • Christoph Hellwig's avatar
      sanitize xattr handler prototypes · 431547b3
      Christoph Hellwig authored
      
      
      Add a flags argument to struct xattr_handler and pass it to all xattr
      handler methods.  This allows using the same methods for multiple
      handlers, e.g. for the ACL methods which perform exactly the same action
      for the access and default ACLs, just using a different underlying
      attribute.  With a little more groundwork it'll also allow sharing the
      methods for the regular user/trusted/secure handlers in extN, ocfs2 and
      jffs2 like it's already done for xfs in this patch.
      
      Also change the inode argument to the handlers to a dentry to allow
      using the handlers mechnism for filesystems that require it later,
      e.g. cifs.
      
      [with GFS2 bits updated by Steven Whitehouse <swhiteho@redhat.com>]
      
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarJames Morris <jmorris@namei.org>
      Acked-by: default avatarJoel Becker <joel.becker@oracle.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      431547b3
  25. 26 Mar, 2009 1 commit
  26. 28 Apr, 2008 2 commits
  27. 16 Apr, 2008 1 commit
  28. 17 Oct, 2007 1 commit
    • Martin J. Bligh's avatar
      ext2 reservations · a686cd89
      Martin J. Bligh authored
      Val's cross-port of the ext3 reservations code into ext2.
      
      [mbligh@mbligh.org: Small type error for printk
      [akpm@linux-foundation.org: fix types, sync with ext3]
      [mbligh@mbligh.org: Bring ext2 reservations code in line with latest ext3]
      [akpm@linux-foundation.org: kill noisy printk]
      [akpm@linux-foundation.org: remember to dirty the gdp's block]
      [akpm@linux-foundation.org: cross-port the missed 5dea5176]
      [akpm@linux-foundation.org: cross-port e6022603]
      [akpm@linux-foundation.org: Port the omitted 08fb306f]
      [akpm@linux-foundation.org: Backport the missed 20acaa18
      
      ]
      [akpm@linux-foundation.org: fixes]
      [cmm@us.ibm.com: fix reservation extension]
      [bunk@stusta.de: make ext2_get_blocks() static]
      [hugh@veritas.com: fix hang]
      [hugh@veritas.com: ext2_new_blocks should reset the reservation window size]
      [hugh@veritas.com: ext2 balloc: fix off-by-one against rsv_end]
      [hugh@veritas.com: grp_goal 0 is a genuine goal (unlike -1), so ext2_try_to_allocate_with_rsv should treat it as such]
      [hugh@veritas.com: rbtree usage cleanup]
      [pbadari@us.ibm.com: Fix for ext2 reservation]
      [bunk@kernel.org: remove fs/ext2/balloc.c:reserve_blocks()]
      [hugh@veritas.com: ext2 balloc: use io_error label]
      Cc: "Martin J. Bligh" <mbligh@mbligh.org>
      Cc: Valerie Henson <val_henson@linux.intel.com>
      Cc: Mingming Cao <cmm@us.ibm.com>
      Cc: Mel Gorman <mel@csn.ul.ie>
      Cc: Hugh Dickins <hugh@veritas.com>
      Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
      Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
      Signed-off-by: default avatarBadari Pulavarty <pbadari@us.ibm.com>
      Signed-off-by: default avatarAdrian Bunk <bunk@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a686cd89
  29. 07 Dec, 2006 1 commit
  30. 27 Sep, 2006 1 commit
  31. 17 Feb, 2006 1 commit
    • Peter Staubach's avatar
      [PATCH] fix deadlock in ext2 · b2f49033
      Peter Staubach authored
      
      
      Fix a deadlock possible in the ext2 file system implementation.  This
      deadlock occurs when a file is removed from an ext2 file system which was
      mounted with the "sync" mount option.
      
      The problem is that ext2_xattr_delete_inode() was invoking the routine,
      sync_dirty_buffer(), using a buffer head which was previously locked via
      lock_buffer().  The first thing that sync_dirty_buffer() does is to lock
      the buffer head that it was passed.  It does this via lock_buffer().  Oops.
      
      The solution is to unlock the buffer head in ext2_xattr_delete_inode()
      before invoking sync_dirty_buffer().  This makes the code in
      ext2_xattr_delete_inode() obey the same locking rules as all other callers
      of sync_dirty_buffer() in the ext2 file system implementation.
      
      Signed-off-by: default avatarPeter Staubach <staubach@redhat.com>
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      b2f49033