1. 22 5月, 2010 1 次提交
    • E
      sysfs: Implement sysfs tagged directory support. · 3ff195b0
      Eric W. Biederman 提交于
      The problem.  When implementing a network namespace I need to be able
      to have multiple network devices with the same name.  Currently this
      is a problem for /sys/class/net/*, /sys/devices/virtual/net/*, and
      potentially a few other directories of the form /sys/ ... /net/*.
      
      What this patch does is to add an additional tag field to the
      sysfs dirent structure.  For directories that should show different
      contents depending on the context such as /sys/class/net/, and
      /sys/devices/virtual/net/ this tag field is used to specify the
      context in which those directories should be visible.  Effectively
      this is the same as creating multiple distinct directories with
      the same name but internally to sysfs the result is nicer.
      
      I am calling the concept of a single directory that looks like multiple
      directories all at the same path in the filesystem tagged directories.
      
      For the networking namespace the set of directories whose contents I need
      to filter with tags can depend on the presence or absence of hotplug
      hardware or which modules are currently loaded.  Which means I need
      a simple race free way to setup those directories as tagged.
      
      To achieve a reace free design all tagged directories are created
      and managed by sysfs itself.
      
      Users of this interface:
      - define a type in the sysfs_tag_type enumeration.
      - call sysfs_register_ns_types with the type and it's operations
      - sysfs_exit_ns when an individual tag is no longer valid
      
      - Implement mount_ns() which returns the ns of the calling process
        so we can attach it to a sysfs superblock.
      - Implement ktype.namespace() which returns the ns of a syfs kobject.
      
      Everything else is left up to sysfs and the driver layer.
      
      For the network namespace mount_ns and namespace() are essentially
      one line functions, and look to remain that.
      
      Tags are currently represented a const void * pointers as that is
      both generic, prevides enough information for equality comparisons,
      and is trivial to create for current users, as it is just the
      existing namespace pointer.
      
      The work needed in sysfs is more extensive.  At each directory
      or symlink creating I need to check if the directory it is being
      created in is a tagged directory and if so generate the appropriate
      tag to place on the sysfs_dirent.  Likewise at each symlink or
      directory removal I need to check if the sysfs directory it is
      being removed from is a tagged directory and if so figure out
      which tag goes along with the name I am deleting.
      
      Currently only directories which hold kobjects, and
      symlinks are supported.  There is not enough information
      in the current file attribute interfaces to give us anything
      to discriminate on which makes it useless, and there are
      no potential users which makes it an uninteresting problem
      to solve.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NBenjamin Thery <benjamin.thery@bull.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3ff195b0
  2. 08 3月, 2010 4 次提交
  3. 05 1月, 2010 1 次提交
    • E
      sysfs: Add lockdep annotations for the sysfs active reference · 846f9974
      Eric W. Biederman 提交于
      Holding locks over device_del -> kobject_del -> sysfs_deactivate can
      cause deadlocks if those same locks are grabbed in sysfs show or store
      methods.
      
      The I model s_active count + completion as a sleeping read/write lock.
      I describe to lockdep sysfs_get_active as a read_trylock,
      sysfs_put_active as a read_unlock, and sysfs_deactivate as a
      write_lock and write_unlock pair.  This seems to capture the essence
      for purposes of finding deadlocks, and in my testing gives finds real
      issues and ignores non-issues.
      
      This brings us back to holding locks over kobject_del is a problem
      that ideally we should find a way of addressing, but at least lockdep
      can tell us about the problems instead of requiring developers to debug
      rare strange system deadlocks, that happen when sysfs files are removed
      while being written to.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      846f9974
  4. 12 12月, 2009 7 次提交
  5. 05 11月, 2009 1 次提交
  6. 15 10月, 2009 1 次提交
  7. 10 9月, 2009 1 次提交
    • D
      sysfs: Add labeling support for sysfs · ddd29ec6
      David P. Quigley 提交于
      This patch adds a setxattr handler to the file, directory, and symlink
      inode_operations structures for sysfs. The patch uses hooks introduced in the
      previous patch to handle the getting and setting of security information for
      the sysfs inodes. As was suggested by Eric Biederman the struct iattr in the
      sysfs_dirent structure has been replaced by a structure which contains the
      iattr, secdata and secdata length to allow the changes to persist in the event
      that the inode representing the sysfs_dirent is evicted. Because sysfs only
      stores this information when a change is made all the optional data is moved
      into one dynamically allocated field.
      
      This patch addresses an issue where SELinux was denying virtd access to the PCI
      configuration entries in sysfs. The lack of setxattr handlers for sysfs
      required that a single label be assigned to all entries in sysfs. Granting virtd
      access to every entry in sysfs is not an acceptable solution so fine grained
      labeling of sysfs is required such that individual entries can be labeled
      appropriately.
      
      [sds:  Fixed compile-time warnings, coding style, and setting of inode security init flags.]
      Signed-off-by: NDavid P. Quigley <dpquigl@tycho.nsa.gov>
      Signed-off-by: NStephen D. Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      ddd29ec6
  8. 29 7月, 2009 1 次提交
    • P
      sysfs: fix hardlink count on device_move · 0f58b445
      Peter Oberparleiter 提交于
      Update directory hardlink count when moving kobjects to a new parent.
      Fixes the following problem which occurs when several devices are
      moved to the same parent and then unregistered:
      
      > ls -laF /sys/devices/css0/defunct/
      > total 0
      > drwxr-xr-x 4294967295 root root    0 2009-07-14 17:02 ./
      > drwxr-xr-x        114 root root    0 2009-07-14 17:02 ../
      > drwxr-xr-x          2 root root    0 2009-07-14 17:01 power/
      > -rw-r--r--          1 root root 4096 2009-07-14 17:01 uevent
      Signed-off-by: NPeter Oberparleiter <oberpar@linux.vnet.ibm.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0f58b445
  9. 28 3月, 2009 1 次提交
  10. 25 3月, 2009 2 次提交
    • 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
    • A
      sysfs: sysfs_add_one WARNs with full path to duplicate filename · 425cb029
      Alex Chiang 提交于
      sysfs: sysfs_add_one WARNs with full path to duplicate filename
      
      As a debugging aid, it can be useful to know the full path to a
      duplicate file being created in sysfs.
      
      We now will display warnings such as:
      
      	sysfs: cannot create duplicate filename '/foo'
      
      when attempting to create multiple files named 'foo' in the sysfs
      root, or:
      
      	sysfs: cannot create duplicate filename '/bus/pci/slots/5/foo'
      
      when attempting to create multiple files named 'foo' under a
      given directory in sysfs.
      
      The path displayed is always a relative path to sysfs_root. The
      leading '/' in the path name refers to the sysfs_root mount
      point, and should not be confused with the "real" '/'.
      
      Thanks to Alex Williamson for essentially writing sysfs_pathname.
      
      Cc: Alex Williamson <alex.williamson@hp.com>
      Signed-off-by: NAlex Chiang <achiang@hp.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      425cb029
  11. 23 10月, 2008 1 次提交
  12. 17 10月, 2008 3 次提交
  13. 27 7月, 2008 1 次提交
  14. 22 7月, 2008 1 次提交
  15. 15 5月, 2008 1 次提交
  16. 20 4月, 2008 1 次提交
  17. 25 1月, 2008 1 次提交
  18. 17 1月, 2008 2 次提交
  19. 31 10月, 2007 1 次提交
  20. 17 10月, 2007 2 次提交
  21. 13 10月, 2007 6 次提交