1. 01 4月, 2009 1 次提交
  2. 25 3月, 2009 2 次提交
    • H
      sysfs: fix some bin_vm_ops errors · 095160ae
      Hugh Dickins 提交于
      Commit 86c9508eb1c0ce5aa07b5cf1d36b60c54efc3d7a
      "sysfs: don't block indefinitely for unmapped files" in linux-next
      crashes the PowerMac G5 when X starts up.  It's caught out by the way
      powerpc's pci_mmap of legacy_mem uses shmem_zero_setup(), substituting
      a new vma->vm_file whose private_data no longer points to the bin_buffer
      (substitution done because some versions of X crash if that mmap fails).
      
      The fix to this is straightforward: the original vm_file is fput() in
      that case, so this mmap won't block sysfs at all, so just don't switch
      over to bin_vm_ops if vm_file has changed.
      
      But more fixes made before realizing that was the problem:-
      
      It should not be an error if bin_page_mkwrite() finds no underlying
      page_mkwrite().
      
      Check that a file already mmap'ed has the same underlying vm_ops
      _before_ pointing vma->vm_ops at bin_vm_ops.
      
      If the file being mmap'ed is a shmem/tmpfs file, don't fail the mmap
      on CONFIG_NUMA=y, just because that has a set_policy and get_policy:
      provide bin_set_policy, bin_get_policy and bin_migrate.
      Signed-off-by: NHugh Dickins <hugh@veritas.com>
      Acked-by: NEric Biederman <ebiederm@aristanetworks.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      095160ae
    • E
      sysfs: don't block indefinitely for unmapped files. · e0edd3c6
      Eric W. Biederman 提交于
      Modify sysfs bin files so that we can remove the bin file while they are
      still mapped.  When the kobject is removed we unmap the bin file and
      arrange for future accesses to the mapping to receive SIGBUS.
      
      Implementing this prevents a nasty DOS when pci devices are hot plugged
      and unplugged.  Where if any of their resources were mmaped the kernel
      could not free up their pci resources or release their pci data
      structures.
      
      [akpm@linux-foundation.org: remove unused var]
      Signed-off-by: NEric W. Biederman <ebiederm@aristanetworks.com>
      Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
      Acked-by: NTejun Heo <tj@kernel.org>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e0edd3c6
  3. 21 1月, 2009 1 次提交
  4. 17 10月, 2008 1 次提交
    • N
      sysfs: fix deadlock · b31ca3f5
      Nick Piggin 提交于
      On Thu, Sep 11, 2008 at 10:27:10AM +0200, Ingo Molnar wrote:
      
      > and it's working fine on most boxes. One testbox found this new locking
      > scenario:
      >
      > PM: Adding info for No Bus:vcsa7
      > EDAC DEBUG: MC0: i82860_check()
      >
      > =======================================================
      > [ INFO: possible circular locking dependency detected ]
      > 2.6.27-rc6-tip #1
      > -------------------------------------------------------
      > X/4873 is trying to acquire lock:
      >  (&bb->mutex){--..}, at: [<c020ba20>] mmap+0x40/0xa0
      >
      > but task is already holding lock:
      >  (&mm->mmap_sem){----}, at: [<c0125a1e>] sys_mmap2+0x8e/0xc0
      >
      > which lock already depends on the new lock.
      >
      >
      > the existing dependency chain (in reverse order) is:
      >
      > -> #1 (&mm->mmap_sem){----}:
      >        [<c017dc96>] validate_chain+0xa96/0xf50
      >        [<c017ef2b>] __lock_acquire+0x2cb/0x5b0
      >        [<c017f299>] lock_acquire+0x89/0xc0
      >        [<c01aa8fb>] might_fault+0x6b/0x90
      >        [<c040b618>] copy_to_user+0x38/0x60
      >        [<c020bcfb>] read+0xfb/0x170
      >        [<c01c09a5>] vfs_read+0x95/0x110
      >        [<c01c1443>] sys_pread64+0x63/0x80
      >        [<c012146f>] sysenter_do_call+0x12/0x43
      >        [<ffffffff>] 0xffffffff
      >
      > -> #0 (&bb->mutex){--..}:
      >        [<c017d8b7>] validate_chain+0x6b7/0xf50
      >        [<c017ef2b>] __lock_acquire+0x2cb/0x5b0
      >        [<c017f299>] lock_acquire+0x89/0xc0
      >        [<c0d6f2ab>] __mutex_lock_common+0xab/0x3c0
      >        [<c0d6f698>] mutex_lock_nested+0x38/0x50
      >        [<c020ba20>] mmap+0x40/0xa0
      >        [<c01b111e>] mmap_region+0x14e/0x450
      >        [<c01b170f>] do_mmap_pgoff+0x2ef/0x310
      >        [<c0125a3d>] sys_mmap2+0xad/0xc0
      >        [<c012146f>] sysenter_do_call+0x12/0x43
      >        [<ffffffff>] 0xffffffff
      >
      > other info that might help us debug this:
      >
      > 1 lock held by X/4873:
      >  #0:  (&mm->mmap_sem){----}, at: [<c0125a1e>] sys_mmap2+0x8e/0xc0
      >
      > stack backtrace:
      > Pid: 4873, comm: X Not tainted 2.6.27-rc6-tip #1
      >  [<c017cd09>] print_circular_bug_tail+0x79/0xc0
      >  [<c017d8b7>] validate_chain+0x6b7/0xf50
      >  [<c017a5b5>] ? trace_hardirqs_off_caller+0x15/0xb0
      >  [<c017ef2b>] __lock_acquire+0x2cb/0x5b0
      >  [<c017f299>] lock_acquire+0x89/0xc0
      >  [<c020ba20>] ? mmap+0x40/0xa0
      >  [<c0d6f2ab>] __mutex_lock_common+0xab/0x3c0
      >  [<c020ba20>] ? mmap+0x40/0xa0
      >  [<c0d6f698>] mutex_lock_nested+0x38/0x50
      >  [<c020ba20>] ? mmap+0x40/0xa0
      >  [<c020ba20>] mmap+0x40/0xa0
      >  [<c01b111e>] mmap_region+0x14e/0x450
      >  [<c01afb88>] ? arch_get_unmapped_area_topdown+0xf8/0x160
      >  [<c01b170f>] do_mmap_pgoff+0x2ef/0x310
      >  [<c0125a3d>] sys_mmap2+0xad/0xc0
      >  [<c012146f>] sysenter_do_call+0x12/0x43
      >  [<c0120000>] ? __switch_to+0x130/0x220
      >  =======================
      > evbug.c: Event. Dev: input3, Type: 20, Code: 0, Value: 500
      > warning: `sudo' uses deprecated v2 capabilities in a way that may be insecure.
      >
      > i've attached the config.
      >
      > at first sight it looks like a genuine bug in fs/sysfs/bin.c?
      
      Yes, it is a real bug by the looks. bin.c takes bb->mutex under mmap_sem
      when it is mmapped, and then does its copy_*_user under bb->mutex too.
      
      Here is a basic fix for the sysfs lor.
      
      
      From: Nick Piggin <npiggin@suse.de>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b31ca3f5
  5. 13 10月, 2007 5 次提交
  6. 23 8月, 2007 1 次提交
  7. 12 7月, 2007 7 次提交
    • Z
      sysfs: add parameter "struct bin_attribute *" in .read/.write methods for sysfs binary attributes · 91a69029
      Zhang Rui 提交于
      Well, first of all, I don't want to change so many files either.
      
      What I do:
      Adding a new parameter "struct bin_attribute *" in the
      .read/.write methods for the sysfs binary attributes.
      
      In fact, only the four lines change in fs/sysfs/bin.c and
      include/linux/sysfs.h do the real work.
      But I have to update all the files that use binary attributes
      to make them compatible with the new .read and .write methods.
      I'm not sure if I missed any. :(
      
      Why I do this:
      For a sysfs attribute, we can get a pointer pointing to the
      struct attribute in the .show/.store method,
      while we can't do this for the binary attributes.
      I don't know why this is different, but this does make it not
      so handy to use the binary attributes as the regular ones.
      So I think this patch is reasonable. :)
      
      Who benefits from it:
      The patch that exposes ACPI tables in sysfs
      requires such an improvement.
      All the table binary attributes share the same .read method.
      Parameter "struct bin_attribute *" is used to get
      the table signature and instance number which are used to
      distinguish different ACPI table binary attributes.
      
      Without this parameter, we need to offer different .read methods
      for different ACPI table binary attributes.
      This is impossible as there are various ACPI tables on different
      platforms, and we don't know what they are until they are loaded.
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      91a69029
    • T
      sysfs: make kobj point to sysfs_dirent instead of dentry · 608e266a
      Tejun Heo 提交于
      As kobj sysfs dentries and inodes are gonna be made reclaimable,
      dentry can't be used as naming token for sysfs file/directory, replace
      kobj->dentry with kobj->sd.  The only external interface change is
      shadow directory handling.  All other changes are contained in kobj
      and sysfs.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      608e266a
    • T
      sysfs: kill unnecessary attribute->owner · 7b595756
      Tejun Heo 提交于
      sysfs is now completely out of driver/module lifetime game.  After
      deletion, a sysfs node doesn't access anything outside sysfs proper,
      so there's no reason to hold onto the attribute owners.  Note that
      often the wrong modules were accounted for as owners leading to
      accessing removed modules.
      
      This patch kills now unnecessary attribute->owner.  Note that with
      this change, userland holding a sysfs node does not prevent the
      backing module from being unloaded.
      
      For more info regarding lifetime rule cleanup, please read the
      following message.
      
        http://article.gmane.org/gmane.linux.kernel/510293
      
      (tweaked by Greg to not delete the field just yet, to make it easier to
      merge things properly.)
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7b595756
    • T
      sysfs: implement sysfs_dirent active reference and immediate disconnect · 0ab66088
      Tejun Heo 提交于
      sysfs: implement sysfs_dirent active reference and immediate disconnect
      
      Opening a sysfs node references its associated kobject, so userland
      can arbitrarily prolong lifetime of a kobject which complicates
      lifetime rules in drivers.  This patch implements active reference and
      makes the association between kobject and sysfs immediately breakable.
      
      Now each sysfs_dirent has two reference counts - s_count and s_active.
      s_count is a regular reference count which guarantees that the
      containing sysfs_dirent is accessible.  As long as s_count reference
      is held, all sysfs internal fields in sysfs_dirent are accessible
      including s_parent and s_name.
      
      The newly added s_active is active reference count.  This is acquired
      by invoking sysfs_get_active() and it's the caller's responsibility to
      ensure sysfs_dirent itself is accessible (should be holding s_count
      one way or the other).  Dereferencing sysfs_dirent to access objects
      out of sysfs proper requires active reference.  This includes access
      to the associated kobjects, attributes and ops.
      
      The active references can be drained and denied by calling
      sysfs_deactivate().  All active sysfs_dirents must be deactivated
      after deletion but before the default reference is dropped.  This
      enables immediate disconnect of sysfs nodes.  Once a sysfs_dirent is
      deleted, it won't access any entity external to sysfs proper.
      
      Because attr/bin_attr ops access both the node itself and its parent
      for kobject, they need to hold active references to both.
      sysfs_get/put_active_two() helpers are provided to help grabbing both
      references.  Parent's is acquired first and released last.
      
      Unlike other operations, mmapped area lingers on after mmap() is
      finished and the module implement implementing it and kobj need to
      stay referenced till all the mapped pages are gone.  This is
      accomplished by holding one set of active references to the bin_attr
      and its parent if there have been any mmap during lifetime of an
      openfile.  The references are dropped when the openfile is released.
      
      This change makes sysfs lifetime rules independent from both kobject's
      and module's.  It not only fixes several race conditions caused by
      sysfs not holding onto the proper module when referencing kobject, but
      also helps fixing and simplifying lifetime management in driver model
      and drivers by taking sysfs out of the equation.
      
      Please read the following message for more info.
      
        http://article.gmane.org/gmane.linux.kernel/510293Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0ab66088
    • T
      sysfs: implement bin_buffer · eb361653
      Tejun Heo 提交于
      Implement bin_buffer which contains a mutex and pointer to PAGE_SIZE
      buffer to properly synchronize accesses to per-openfile buffer and
      prepare for immediate-kobj-disconnect.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      eb361653
    • T
      sysfs: make sysfs_dirent->s_element a union · 3e519038
      Tejun Heo 提交于
      Make sd->s_element a union of sysfs_elem_{dir|symlink|attr|bin_attr}
      and rename it to s_elem.  This is to achieve...
      
      * some level of type checking : changing symlink to point to
        sysfs_dirent instead of kobject is much safer and less painful now.
      * easier / standardized dereferencing
      * allow sysfs_elem_* to contain more than one entry
      
      Where possible, pointer is obtained by directly deferencing from sd
      instead of going through other entities.  This reduces dependencies to
      dentry, inode and kobject.  to_attr() and to_bin_attr() are unused now
      and removed.
      
      This is in preparation of object reference simplification.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3e519038
    • T
      sysfs: fix error handling in binattr write() · 93e3cd82
      Tejun Heo 提交于
      Error handling in fs/sysfs/bin.c:write() was wrong because size_t
      count is used to receive return value from flush_write() which is
      negative on failure.
      
      This patch updates write() such that int variable is used instead.
      read() is updated the same way for consistency.
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      93e3cd82
  8. 03 5月, 2007 1 次提交
  9. 28 4月, 2007 1 次提交
  10. 08 2月, 2007 2 次提交
  11. 09 12月, 2006 1 次提交
  12. 26 9月, 2006 1 次提交
  13. 29 3月, 2006 1 次提交
  14. 21 6月, 2005 1 次提交
  15. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4