1. 22 5月, 2010 1 次提交
    • A
      fix a couple of ecryptfs leaks · decabd66
      Al Viro 提交于
      First of all, get_sb_nodev() grabs anon dev minor and we
      never free it in ecryptfs ->kill_sb().  Moreover, on one
      of the failure exits in ecryptfs_get_sb() we leak things -
      it happens before we set ->s_root and ->put_super() won't
      be called in that case.  Solution: kill ->put_super(), do
      all that stuff in ->kill_sb().  And use kill_anon_sb() instead
      of generic_shutdown_super() to deal with anon dev leak.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      decabd66
  2. 22 4月, 2010 1 次提交
  3. 20 4月, 2010 1 次提交
    • J
      ecryptfs: fix use with tmpfs by removing d_drop from ecryptfs_destroy_inode · 133b8f9d
      Jeff Mahoney 提交于
      Since tmpfs has no persistent storage, it pins all its dentries in memory
      so they have d_count=1 when other file systems would have d_count=0.
      ->lookup is only used to create new dentries. If the caller doesn't
      instantiate it, it's freed immediately at dput(). ->readdir reads
      directly from the dcache and depends on the dentries being hashed.
      
      When an ecryptfs mount is mounted, it associates the lower file and dentry
      with the ecryptfs files as they're accessed. When it's umounted and
      destroys all the in-memory ecryptfs inodes, it fput's the lower_files and
      d_drop's the lower_dentries. Commit 4981e081 added this and a d_delete in
      2008 and several months later commit caeeeecf removed the d_delete. I
      believe the d_drop() needs to be removed as well.
      
      The d_drop effectively hides any file that has been accessed via ecryptfs
      from the underlying tmpfs since it depends on it being hashed for it to
      be accessible. I've removed the d_drop on my development node and see no
      ill effects with basic testing on both tmpfs and persistent storage.
      
      As a side effect, after ecryptfs d_drops the dentries on tmpfs, tmpfs
      BUGs on umount. This is due to the dentries being unhashed.
      tmpfs->kill_sb is kill_litter_super which calls d_genocide to drop
      the reference pinning the dentry. It skips unhashed and negative dentries,
      but shrink_dcache_for_umount_subtree doesn't. Since those dentries
      still have an elevated d_count, we get a BUG().
      
      This patch removes the d_drop call and fixes both issues.
      
      This issue was reported at:
      https://bugzilla.novell.com/show_bug.cgi?id=567887Reported-by: NÁrpád Bíró <biroa@demasz.hu>
      Signed-off-by: NJeff Mahoney <jeffm@suse.com>
      Cc: Dustin Kirkland <kirkland@canonical.com>
      Cc: stable@kernel.org
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      133b8f9d
  4. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  5. 23 9月, 2009 1 次提交
    • R
      ecryptfs: Remove unneeded locking that triggers lockdep false positives · 05dafedb
      Roland Dreier 提交于
      In ecryptfs_destroy_inode(), inode_info->lower_file_mutex is locked,
      and just after the mutex is unlocked, the code does:
      
       	kmem_cache_free(ecryptfs_inode_info_cache, inode_info);
      
      This means that if another context could possibly try to take the same
      mutex as ecryptfs_destroy_inode(), then it could end up getting the
      mutex just before the data structure containing the mutex is freed.
      So any such use would be an obvious use-after-free bug (catchable with
      slab poisoning or mutex debugging), and therefore the locking in
      ecryptfs_destroy_inode() is not needed and can be dropped.
      
      Similarly, in ecryptfs_destroy_crypt_stat(), crypt_stat->keysig_list_mutex
      is locked, and then the mutex is unlocked just before the code does:
      
       	memset(crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat));
      
      Therefore taking this mutex is similarly not necessary.
      
      Removing this locking fixes false-positive lockdep reports such as the
      following (and they are false-positives for exactly the same reason
      that the locking is not needed):
      
      =================================
      [ INFO: inconsistent lock state ]
      2.6.31-2-generic #14~rbd3
      ---------------------------------
      inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-W} usage.
      kswapd0/323 [HC0[0]:SC0[0]:HE1:SE1] takes:
       (&inode_info->lower_file_mutex){+.+.?.}, at: [<ffffffff81210d34>] ecryptfs_destroy_inode+0x34/0x100
      {RECLAIM_FS-ON-W} state was registered at:
        [<ffffffff8108c02c>] mark_held_locks+0x6c/0xa0
        [<ffffffff8108c10f>] lockdep_trace_alloc+0xaf/0xe0
        [<ffffffff81125a51>] kmem_cache_alloc+0x41/0x1a0
        [<ffffffff8113117a>] get_empty_filp+0x7a/0x1a0
        [<ffffffff8112dd46>] dentry_open+0x36/0xc0
        [<ffffffff8121a36c>] ecryptfs_privileged_open+0x5c/0x2e0
        [<ffffffff81210283>] ecryptfs_init_persistent_file+0xa3/0xe0
        [<ffffffff8120e838>] ecryptfs_lookup_and_interpose_lower+0x278/0x380
        [<ffffffff8120f97a>] ecryptfs_lookup+0x12a/0x250
        [<ffffffff8113930a>] real_lookup+0xea/0x160
        [<ffffffff8113afc8>] do_lookup+0xb8/0xf0
        [<ffffffff8113b518>] __link_path_walk+0x518/0x870
        [<ffffffff8113bd9c>] path_walk+0x5c/0xc0
        [<ffffffff8113be5b>] do_path_lookup+0x5b/0xa0
        [<ffffffff8113bfe7>] user_path_at+0x57/0xa0
        [<ffffffff811340dc>] vfs_fstatat+0x3c/0x80
        [<ffffffff8113424b>] vfs_stat+0x1b/0x20
        [<ffffffff81134274>] sys_newstat+0x24/0x50
        [<ffffffff81013132>] system_call_fastpath+0x16/0x1b
        [<ffffffffffffffff>] 0xffffffffffffffff
      irq event stamp: 7811
      hardirqs last  enabled at (7811): [<ffffffff810c037f>] call_rcu+0x5f/0x90
      hardirqs last disabled at (7810): [<ffffffff810c0353>] call_rcu+0x33/0x90
      softirqs last  enabled at (3764): [<ffffffff810631da>] __do_softirq+0x14a/0x220
      softirqs last disabled at (3751): [<ffffffff8101440c>] call_softirq+0x1c/0x30
      
      other info that might help us debug this:
      2 locks held by kswapd0/323:
       #0:  (shrinker_rwsem){++++..}, at: [<ffffffff810f67ed>] shrink_slab+0x3d/0x190
       #1:  (&type->s_umount_key#35){.+.+..}, at: [<ffffffff811429a1>] prune_dcache+0xd1/0x1b0
      
      stack backtrace:
      Pid: 323, comm: kswapd0 Tainted: G         C 2.6.31-2-generic #14~rbd3
      Call Trace:
       [<ffffffff8108ad6c>] print_usage_bug+0x18c/0x1a0
       [<ffffffff8108aff0>] ? check_usage_forwards+0x0/0xc0
       [<ffffffff8108bac2>] mark_lock_irq+0xf2/0x280
       [<ffffffff8108bd87>] mark_lock+0x137/0x1d0
       [<ffffffff81164710>] ? fsnotify_clear_marks_by_inode+0x30/0xf0
       [<ffffffff8108bee6>] mark_irqflags+0xc6/0x1a0
       [<ffffffff8108d337>] __lock_acquire+0x287/0x430
       [<ffffffff8108d585>] lock_acquire+0xa5/0x150
       [<ffffffff81210d34>] ? ecryptfs_destroy_inode+0x34/0x100
       [<ffffffff8108d2e7>] ? __lock_acquire+0x237/0x430
       [<ffffffff815526ad>] __mutex_lock_common+0x4d/0x3d0
       [<ffffffff81210d34>] ? ecryptfs_destroy_inode+0x34/0x100
       [<ffffffff81164710>] ? fsnotify_clear_marks_by_inode+0x30/0xf0
       [<ffffffff81210d34>] ? ecryptfs_destroy_inode+0x34/0x100
       [<ffffffff8129a91e>] ? _raw_spin_unlock+0x5e/0xb0
       [<ffffffff81552b36>] mutex_lock_nested+0x46/0x60
       [<ffffffff81210d34>] ecryptfs_destroy_inode+0x34/0x100
       [<ffffffff81145d27>] destroy_inode+0x87/0xd0
       [<ffffffff81146b4c>] generic_delete_inode+0x12c/0x1a0
       [<ffffffff81145832>] iput+0x62/0x70
       [<ffffffff811423c8>] dentry_iput+0x98/0x110
       [<ffffffff81142550>] d_kill+0x50/0x80
       [<ffffffff81142623>] prune_one_dentry+0xa3/0xc0
       [<ffffffff811428b1>] __shrink_dcache_sb+0x271/0x290
       [<ffffffff811429d9>] prune_dcache+0x109/0x1b0
       [<ffffffff81142abf>] shrink_dcache_memory+0x3f/0x50
       [<ffffffff810f68dd>] shrink_slab+0x12d/0x190
       [<ffffffff810f9377>] balance_pgdat+0x4d7/0x640
       [<ffffffff8104c4c0>] ? finish_task_switch+0x40/0x150
       [<ffffffff810f63c0>] ? isolate_pages_global+0x0/0x60
       [<ffffffff810f95f7>] kswapd+0x117/0x170
       [<ffffffff810777a0>] ? autoremove_wake_function+0x0/0x40
       [<ffffffff810f94e0>] ? kswapd+0x0/0x170
       [<ffffffff810773be>] kthread+0x9e/0xb0
       [<ffffffff8101430a>] child_rip+0xa/0x20
       [<ffffffff81013c90>] ? restore_args+0x0/0x30
       [<ffffffff81077320>] ? kthread+0x0/0xb0
       [<ffffffff81014300>] ? child_rip+0x0/0x20
      Signed-off-by: NRoland Dreier <roland@digitalvampire.org>
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      05dafedb
  6. 12 6月, 2009 1 次提交
    • C
      push BKL down into ->put_super · 6cfd0148
      Christoph Hellwig 提交于
      Move BKL into ->put_super from the only caller.  A couple of
      filesystems had trivial enough ->put_super (only kfree and NULLing of
      s_fs_info + stuff in there) to not get any locking: coda, cramfs, efs,
      hugetlbfs, omfs, qnx4, shmem, all others got the full treatment.  Most
      of them probably don't need it, but I'd rather sort that out individually.
      Preferably after all the other BKL pushdowns in that area.
      
      [AV: original used to move lock_super() down as well; these changes are
      removed since we don't do lock_super() at all in generic_shutdown_super()
      now]
      [AV: fuse, btrfs and xfs are known to need no damn BKL, exempt]
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      6cfd0148
  7. 22 4月, 2009 2 次提交
  8. 07 2月, 2008 2 次提交
  9. 09 1月, 2008 1 次提交
    • M
      eCryptfs: fix dentry handling on create error, unlink, and inode destroy · caeeeecf
      Michael Halcrow 提交于
      This patch corrects some erroneous dentry handling in eCryptfs.
      
      If there is a problem creating the lower file, then there is nothing that
      the persistent lower file can do to really help us.  This patch makes a
      vfs_create() failure in the lower filesystem always lead to an
      unconditional do_create failure in eCryptfs.
      
      Under certain sequences of operations, the eCryptfs dentry can remain in
      the dcache after an unlink.  This patch calls d_drop() on the eCryptfs
      dentry to correct this.
      
      eCryptfs has no business calling d_delete() directly on a lower
      filesystem's dentry.  This patch removes the call to d_delete() on the
      lower persistent file's dentry in ecryptfs_destroy_inode().
      
      (Thanks to David Kleikamp, Eric Sandeen, and Jeff Moyer for helping
      identify and resolve this issue)
      Signed-off-by: NMichael Halcrow <mhalcrow@us.ibm.com>
      Cc: Dave Kleikamp <shaggy@austin.ibm.com>
      Cc: Eric Sandeen <sandeen@redhat.com>
      Cc: Jeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      caeeeecf
  10. 17 10月, 2007 3 次提交
  11. 13 2月, 2007 1 次提交
  12. 08 12月, 2006 1 次提交
  13. 01 11月, 2006 1 次提交
  14. 04 10月, 2006 1 次提交