1. 03 5月, 2012 1 次提交
  2. 11 4月, 2012 2 次提交
    • D
      sysfs: handle 'parent deleted before child added' · 3a198886
      Dan Williams 提交于
      In scsi at least two cases of the parent device being deleted before the
      child is added have been observed.
      
      1/ scsi is performing async scans and the device is removed prior to the
         async can thread running (can happen with an in-opportune / unlikely
         unplug during initial scan).
      
      2/ libsas discovery event running after the parent port has been torn
         down (this is a bug in libsas).
      
      Result in crash signatures like:
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
       IP: [<ffffffff8115e100>] sysfs_create_dir+0x32/0xb6
       ...
       Process scsi_scan_8 (pid: 5417, threadinfo ffff88080bd16000, task ffff880801b8a0b0)
       Stack:
        00000000fffffffe ffff880813470628 ffff88080bd17cd0 ffff88080614b7e8
        ffff88080b45c108 00000000fffffffe ffff88080bd17d20 ffffffff8125e4a8
        ffff88080bd17cf0 ffffffff81075149 ffff88080bd17d30 ffff88080614b7e8
       Call Trace:
        [<ffffffff8125e4a8>] kobject_add_internal+0x120/0x1e3
        [<ffffffff81075149>] ? trace_hardirqs_on+0xd/0xf
        [<ffffffff8125e641>] kobject_add_varg+0x41/0x50
        [<ffffffff8125e70b>] kobject_add+0x64/0x66
        [<ffffffff8131122b>] device_add+0x12d/0x63a
      
      In this scenario the parent is still valid (because we have a
      reference), but it has been device_del()'d which means its kobj->sd
      pointer is NULL'd via:
      
       device_del()->kobject_del()->sysfs_remove_dir()
      
      ...and then sysfs_create_dir() (without this fix) goes ahead and
      de-references parent_sd via sysfs_ns_type():
      
       return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT;
      
      This scenario is being fixed in scsi/libsas, but if other subsystems
      present the same ordering the system need not immediately crash.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: James Bottomley <JBottomley@parallels.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3a198886
    • B
      sysfs: Prevent crash on unset sysfs group attributes · 5631f2c1
      Bruno Prémont 提交于
      Do not let the kernel crash when a device is registered with
      sysfs while group attributes are not set (aka NULL).
      
      Warn about the offender with some information about the offending
      device.
      
      This would warn instead of trying NULL pointer deref like:
       BUG: unable to handle kernel NULL pointer dereference at (null)
       IP: [<ffffffff81152673>] internal_create_group+0x83/0x1a0
       PGD 0
       Oops: 0000 [#1] SMP
       CPU 0
       Modules linked in:
      
       Pid: 1, comm: swapper/0 Not tainted 3.4.0-rc1-x86_64 #3 HP ProLiant DL360 G4
       RIP: 0010:[<ffffffff81152673>]  [<ffffffff81152673>] internal_create_group+0x83/0x1a0
       RSP: 0018:ffff88019485fd70  EFLAGS: 00010202
       RAX: 0000000000000001 RBX: 0000000000000000 RCX: 0000000000000001
       RDX: ffff880192e99908 RSI: ffff880192e99630 RDI: ffffffff81a26c60
       RBP: ffff88019485fdc0 R08: 0000000000000000 R09: 0000000000000000
       R10: ffff880192e99908 R11: 0000000000000000 R12: ffffffff81a16a00
       R13: ffff880192e99908 R14: ffffffff81a16900 R15: 0000000000000000
       FS:  0000000000000000(0000) GS:ffff88019bc00000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
       CR2: 0000000000000000 CR3: 0000000001a0c000 CR4: 00000000000007f0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       Process swapper/0 (pid: 1, threadinfo ffff88019485e000, task ffff880194878000)
       Stack:
        ffff88019485fdd0 ffff880192da9d60 0000000000000000 ffff880192e99908
        ffff880192e995d8 0000000000000001 ffffffff81a16a00 ffff880192da9d60
        0000000000000000 0000000000000000 ffff88019485fdd0 ffffffff811527be
       Call Trace:
        [<ffffffff811527be>] sysfs_create_group+0xe/0x10
        [<ffffffff81376ca6>] device_add_groups+0x46/0x80
        [<ffffffff81377d3d>] device_add+0x46d/0x6a0
        ...
      Signed-off-by: NBruno Prémont <bonbons@linux-vserver.org>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5631f2c1
  3. 10 4月, 2012 1 次提交
  4. 21 3月, 2012 1 次提交
  5. 09 3月, 2012 1 次提交
  6. 25 2月, 2012 1 次提交
    • M
      sysfs: Fix memory leak in sysfs_sd_setsecdata(). · 93518dd2
      Masami Ichikawa 提交于
      This patch fixies follwing two memory leak patterns that reported by kmemleak.
      sysfs_sd_setsecdata() is called during sys_lsetxattr() operation.
      It checks sd->s_iattr is NULL or not. Then if it is NULL, it calls
      sysfs_init_inode_attrs() to allocate memory.
      That code is this.
      
      iattrs = sd->s_iattr;
      if (!iattrs)
                      iattrs = sysfs_init_inode_attrs(sd);
      
      The iattrs recieves sysfs_init_inode_attrs()'s result,  but sd->s_iattr
      doesn't know the address. so it needs to set correct address to
      sd->s_iattr to free memory in other function.
      
      unreferenced object 0xffff880250b73e60 (size 32):
        comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
        hex dump (first 32 bytes):
          73 79 73 74 65 6d 5f 75 3a 6f 62 6a 65 63 74 5f  system_u:object_
          72 3a 73 79 73 66 73 5f 74 3a 73 30 00 00 00 00  r:sysfs_t:s0....
        backtrace:
          [<ffffffff814cb1d0>] kmemleak_alloc+0x73/0x98
          [<ffffffff811270ab>] __kmalloc+0x100/0x12c
          [<ffffffff8120775a>] context_struct_to_string+0x106/0x210
          [<ffffffff81207cc1>] security_sid_to_context_core+0x10b/0x129
          [<ffffffff812090ef>] security_sid_to_context+0x10/0x12
          [<ffffffff811fb0da>] selinux_inode_getsecurity+0x7d/0xa8
          [<ffffffff811fb127>] selinux_inode_getsecctx+0x22/0x2e
          [<ffffffff811f4d62>] security_inode_getsecctx+0x16/0x18
          [<ffffffff81191dad>] sysfs_setxattr+0x96/0x117
          [<ffffffff811542f0>] __vfs_setxattr_noperm+0x73/0xd9
          [<ffffffff811543d9>] vfs_setxattr+0x83/0xa1
          [<ffffffff811544c6>] setxattr+0xcf/0x101
          [<ffffffff81154745>] sys_lsetxattr+0x6a/0x8f
          [<ffffffff814efda9>] system_call_fastpath+0x16/0x1b
          [<ffffffffffffffff>] 0xffffffffffffffff
      unreferenced object 0xffff88024163c5a0 (size 96):
        comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
        hex dump (first 32 bytes):
          00 00 00 00 ed 41 00 00 00 00 00 00 00 00 00 00  .....A..........
          00 00 00 00 00 00 00 00 0c 64 42 4f 00 00 00 00  .........dBO....
        backtrace:
          [<ffffffff814cb1d0>] kmemleak_alloc+0x73/0x98
          [<ffffffff81127402>] kmem_cache_alloc_trace+0xc4/0xee
          [<ffffffff81191cbe>] sysfs_init_inode_attrs+0x2a/0x83
          [<ffffffff81191dd6>] sysfs_setxattr+0xbf/0x117
          [<ffffffff811542f0>] __vfs_setxattr_noperm+0x73/0xd9
          [<ffffffff811543d9>] vfs_setxattr+0x83/0xa1
          [<ffffffff811544c6>] setxattr+0xcf/0x101
          [<ffffffff81154745>] sys_lsetxattr+0x6a/0x8f
          [<ffffffff814efda9>] system_call_fastpath+0x16/0x1b
          [<ffffffffffffffff>] 0xffffffffffffffff
      `
      Signed-off-by: NMasami Ichikawa <masami256@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93518dd2
  7. 01 2月, 2012 1 次提交
  8. 25 1月, 2012 6 次提交
  9. 04 1月, 2012 3 次提交
  10. 02 11月, 2011 2 次提交
  11. 25 10月, 2011 1 次提交
  12. 20 10月, 2011 3 次提交
  13. 27 9月, 2011 1 次提交
  14. 23 8月, 2011 4 次提交
  15. 20 7月, 2011 3 次提交
  16. 13 6月, 2011 1 次提交
    • A
      Delay struct net freeing while there's a sysfs instance refering to it · a685e089
      Al Viro 提交于
      	* new refcount in struct net, controlling actual freeing of the memory
      	* new method in kobj_ns_type_operations (->drop_ns())
      	* ->current_ns() semantics change - it's supposed to be followed by
      corresponding ->drop_ns().  For struct net in case of CONFIG_NET_NS it bumps
      the new refcount; net_drop_ns() decrements it and calls net_free() if the
      last reference has been dropped.  Method renamed to ->grab_current_ns().
      	* old net_free() callers call net_drop_ns() instead.
      	* sysfs_exit_ns() is gone, along with a large part of callchain
      leading to it; now that the references stored in ->ns[...] stay valid we
      do not need to hunt them down and replace them with NULL.  That fixes
      problems in sysfs_lookup() and sysfs_readdir(), along with getting rid
      of sb->s_instances abuse.
      
      	Note that struct net *shutdown* logics has not changed - net_cleanup()
      is called exactly when it used to be called.  The only thing postponed by
      having a sysfs instance refering to that struct net is actual freeing of
      memory occupied by struct net.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      a685e089
  17. 14 5月, 2011 1 次提交
  18. 11 5月, 2011 1 次提交
  19. 21 1月, 2011 1 次提交
    • D
      kconfig: rename CONFIG_EMBEDDED to CONFIG_EXPERT · 6a108a14
      David Rientjes 提交于
      The meaning of CONFIG_EMBEDDED has long since been obsoleted; the option
      is used to configure any non-standard kernel with a much larger scope than
      only small devices.
      
      This patch renames the option to CONFIG_EXPERT in init/Kconfig and fixes
      references to the option throughout the kernel.  A new CONFIG_EMBEDDED
      option is added that automatically selects CONFIG_EXPERT when enabled and
      can be used in the future to isolate options that should only be
      considered for embedded systems (RISC architectures, SLOB, etc).
      
      Calling the option "EXPERT" more accurately represents its intention: only
      expert users who understand the impact of the configuration changes they
      are making should enable it.
      Reviewed-by: NIngo Molnar <mingo@elte.hu>
      Acked-by: NDavid Woodhouse <david.woodhouse@intel.com>
      Signed-off-by: NDavid Rientjes <rientjes@google.com>
      Cc: Greg KH <gregkh@suse.de>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Robin Holt <holt@sgi.com>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6a108a14
  20. 11 1月, 2011 1 次提交
  21. 07 1月, 2011 4 次提交
    • N
      fs: provide rcu-walk aware permission i_ops · b74c79e9
      Nick Piggin 提交于
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      b74c79e9
    • N
      fs: rcu-walk aware d_revalidate method · 34286d66
      Nick Piggin 提交于
      Require filesystems be aware of .d_revalidate being called in rcu-walk
      mode (nd->flags & LOOKUP_RCU). For now do a simple push down, returning
      -ECHILD from all implementations.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      34286d66
    • N
      fs: dcache reduce branches in lookup path · fb045adb
      Nick Piggin 提交于
      Reduce some branches and memory accesses in dcache lookup by adding dentry
      flags to indicate common d_ops are set, rather than having to check them.
      This saves a pointer memory access (dentry->d_op) in common path lookup
      situations, and saves another pointer load and branch in cases where we
      have d_op but not the particular operation.
      
      Patched with:
      
      git grep -E '[.>]([[:space:]])*d_op([[:space:]])*=' | xargs sed -e 's/\([^\t ]*\)->d_op = \(.*\);/d_set_d_op(\1, \2);/' -e 's/\([^\t ]*\)\.d_op = \(.*\);/d_set_d_op(\&\1, \2);/' -i
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      fb045adb
    • N
      fs: change d_delete semantics · fe15ce44
      Nick Piggin 提交于
      Change d_delete from a dentry deletion notification to a dentry caching
      advise, more like ->drop_inode. Require it to be constant and idempotent,
      and not take d_lock. This is how all existing filesystems use the callback
      anyway.
      
      This makes fine grained dentry locking of dput and dentry lru scanning
      much simpler.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      fe15ce44