1. 06 10月, 2013 15 次提交
    • T
      sysfs: merge regular and bin file handling · 3124eb16
      Tejun Heo 提交于
      With the previous changes, sysfs regular file code is ready to handle
      bin files too.  This patch makes bin files share the regular file
      path.
      
      * sysfs_create/remove_bin_file() are moved to fs/sysfs/file.c.
      
      * sysfs_init_inode() is updated to use the new sysfs_bin_operations
        instead of bin_fops for bin files.
      
      * fs/sysfs/bin.c and the related pieces are removed.
      
      This patch shouldn't introduce any behavior difference to bin file
      accesses.
      
      Overall, this unification reduces the amount of duplicate logic, makes
      behaviors more consistent and paves the road for building simpler and
      more versatile interface which will allow other subsystems to make use
      of sysfs for their pseudo filesystems.
      
      v2: Stale fs/sysfs/bin.c reference dropped from
          Documentation/DocBook/filesystems.tmpl.  Reported by kbuild test
          robot.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: kbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3124eb16
    • T
      sysfs: prepare open path for unified regular / bin file handling · 49fe6047
      Tejun Heo 提交于
      sysfs bin file handling will be merged into the regular file support.
      This patch prepares the open path.
      
      This patch updates sysfs_open_file() such that it can handle both
      regular and bin files.
      
      This is a preparation and the new bin file path isn't used yet.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49fe6047
    • T
      sysfs: copy bin mmap support from fs/sysfs/bin.c to fs/sysfs/file.c · 73d97146
      Tejun Heo 提交于
      sysfs bin file handling will be merged into the regular file support.
      This patch copies mmap support from bin so that fs/sysfs/file.c can
      handle mmapping bin files.
      
      The code is copied mostly verbatim with the following updates.
      
      * ->mmapped and ->vm_ops are added to sysfs_open_file and bin_buffer
        references are replaced with sysfs_open_file ones.
      
      * Symbols are prefixed with sysfs_.
      
      * sysfs_unmap_bin_file() grabs sysfs_open_dirent and traverses
        ->files.  Invocation of this function is added to
        sysfs_addrm_finish().
      
      * sysfs_bin_mmap() is added to sysfs_bin_operations.
      
      This is a preparation and the new mmap path isn't used yet.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73d97146
    • T
      sysfs: add sysfs_bin_read() · 2f0c6b75
      Tejun Heo 提交于
      sysfs bin file handling will be merged into the regular file support.
      This patch prepares the read path.
      
      Copy fs/sysfs/bin.c::read() to fs/sysfs/file.c and make it use
      sysfs_open_file instead of bin_buffer.  The function is identical copy
      except for the use of sysfs_open_file.
      
      The new function is added to sysfs_bin_operations.  This isn't used
      yet but will eventually replace fs/sysfs/bin.c.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f0c6b75
    • T
      sysfs: prepare path write for unified regular / bin file handling · f9b9a621
      Tejun Heo 提交于
      sysfs bin file handling will be merged into the regular file support.
      This patch prepares the write path.
      
      bin file write is almost identical to regular file write except that
      the write length is capped by the inode size and @off is passed to the
      write method.  This patch adds bin file handling to sysfs_write_file()
      so that it can handle both regular and bin files.
      
      A new file_operations struct sysfs_bin_operations is added, which
      currently only hosts sysfs_write_file() and generic_file_llseek().
      This isn't used yet but will eventually replace fs/sysfs/bin.c.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9b9a621
    • T
      sysfs: collapse fs/sysfs/bin.c::fill_read() into read() · 3ff65d3c
      Tejun Heo 提交于
      read() is simple enough and fill_read() being in a separate function
      doesn't add anything.  Let's collapse it into read().  This will make
      merging bin file handling with regular file.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3ff65d3c
    • T
      sysfs: skip bin_buffer->buffer while reading · 91270162
      Tejun Heo 提交于
      After b31ca3f5 ("sysfs: fix deadlock"), bin read() first writes
      data to bb->buffer and bounces it to a transient kernel buffer which
      is then copied out to userland.  The double bouncing doesn't add
      anything.  Let's just use the transient buffer directly.
      
      While at it, rename @temp to @buf for clarity.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91270162
    • T
      sysfs: use seq_file when reading regular files · 13c589d5
      Tejun Heo 提交于
      sysfs read path implements its own buffering scheme between userland
      and kernel callbacks, which essentially is a degenerate duplicate of
      seq_file.  This patch replaces the custom read buffering
      implementation in sysfs with seq_file.
      
      While the amount of code reduction is small, this reduces low level
      hairiness and enables future development of a new versatile API based
      on seq_file so that sysfs features can be shared with other
      subsystems.
      
      As write path was already converted to not use sysfs_open_file->page,
      this patch makes ->page and ->count unused and removes them.
      
      Userland behavior remains the same except for some extreme corner
      cases - e.g. sysfs will now regenerate the content each time a file is
      read after a non-contiguous seek whereas the original code would keep
      using the same content.  While this is a userland visible behavior
      change, it is extremely unlikely to be noticeable and brings sysfs
      behavior closer to that of procfs.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Kay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      13c589d5
    • T
      sysfs: use transient write buffer · 8ef445f0
      Tejun Heo 提交于
      There isn't much to be gained by keeping around kernel buffer while a
      file is open especially as the read path planned to be converted to
      use seq_file and won't use the buffer.  This patch makes
      sysfs_write_file() use per-write transient buffer instead of
      sysfs_open_file->page.
      
      This simplifies the write path, enables removing sysfs_open_file->page
      once read path is updated and will help merging bin file write path
      which already requires the use of a transient buffer due to a locking
      order issue.
      
      As the function comments of flush_write_buffer() and
      sysfs_write_buffer() are being updated anyway, reformat them so that
      they're more conventional.
      
      v2: Use min_t() instead of min() in sysfs_write_file() to avoid build
          warning on arm.  Reported by build test robot.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: kbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8ef445f0
    • T
      sysfs: add sysfs_open_file->sd and ->file · bcafe4ee
      Tejun Heo 提交于
      sysfs will be converted to use seq_file for read path, which will make
      it difficult to pass around multiple pointers directly.  This patch
      adds sysfs_open_file->sd and ->file so that we can reach all the
      necessary data structures from sysfs_open_file.
      
      flush_write_buffer() is updated to drop @dentry which was used to
      discover the sysfs_dirent as it's now available through
      sysfs_open_file->sd.
      
      This patch doesn't cause any behavior difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcafe4ee
    • T
      sysfs: rename sysfs_buffer to sysfs_open_file · 58282d8d
      Tejun Heo 提交于
      sysfs read path will be converted to use seq_file which will handle
      buffering making sysfs_buffer a misnomer.  Rename sysfs_buffer to
      sysfs_open_file, and sysfs_open_dirent->buffers to ->files.
      
      This path is pure rename.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58282d8d
    • T
      sysfs: add sysfs_open_file_mutex · c75ec764
      Tejun Heo 提交于
      Add a separate mutex to protect sysfs_open_dirent->buffers list.  This
      will allow performing sleepable operations while traversing
      sysfs_buffers, which will be renamed to sysfs_open_file.
      
      Note that currently sysfs_open_dirent->buffers list isn't being used
      for anything and this patch doesn't make any functional difference.
      It will be used to merge regular and bin file supports.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c75ec764
    • T
      sysfs: remove sysfs_buffer->ops · 375b611e
      Tejun Heo 提交于
      Currently, sysfs_ops is fetched during sysfs_open_file() and cached in
      sysfs_buffer->ops to be used while the file is open.  This patch
      removes the caching and makes each operation directly fetch sysfs_ops.
      
      This patch doesn't introduce any behavior difference and is to prepare
      for merging regular and bin file supports.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      375b611e
    • T
      sysfs: remove sysfs_buffer->needs_read_fill · aea585ef
      Tejun Heo 提交于
      ->needs_read_fill is used to implement the following behaviors.
      
      1. Ensure buffer filling on the first read.
      2. Force buffer filling after a write.
      3. Force buffer filling after a successful poll.
      
      However, #2 and #3 don't really work as sysfs doesn't reset file
      position.  While the read buffer would be refilled, the next read
      would continue from the position after the last read or write,
      requiring an explicit seek to the start for it to be useful, which
      makes ->needs_read_fill superflous as read buffer is always refilled
      if f_pos == 0.
      
      Update sysfs_read_file() to test buffer->page for #1 instead and
      remove ->needs_read_fill.  While this changes behavior in extreme
      corner cases - e.g. re-reading a sysfs file after seeking to non-zero
      position after a write or poll, it's highly unlikely to lead to actual
      breakage.  This change is to prepare for using seq_file in the read
      path.
      
      While at it, reformat a comment in fill_write_buffer().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Kay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aea585ef
    • T
      sysfs: remove unused sysfs_buffer->pos · 89e51dab
      Tejun Heo 提交于
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      89e51dab
  2. 04 10月, 2013 4 次提交
    • T
      sysfs: introduce [__]sysfs_remove() · 250f7c3f
      Tejun Heo 提交于
      Given a sysfs_dirent, there is no reason to have multiple versions of
      removal functions.  A function which removes the specified
      sysfs_dirent and its descendants is enough.
      
      This patch intorduces [__}sysfs_remove() which replaces all internal
      variations of removal functions.  This will be the only removal
      function in the planned new sysfs_dirent based interface.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      250f7c3f
    • T
      sysfs: make __sysfs_remove_dir() recursive · bcdde7e2
      Tejun Heo 提交于
      Currently, sysfs directory removal is inconsistent in that it would
      remove any files directly under it but wouldn't recurse into
      directories.  Thanks to group subdirectories, this doesn't even match
      with kobject boundaries.  sysfs is in the process of being separated
      out so that it can be used by multiple subsystems and we want to have
      a consistent behavior - either removal of a sysfs_dirent should remove
      every descendant entries or none instead of something inbetween.
      
      This patch implements proper recursive removal in
      __sysfs_remove_dir().  The function now walks its subtree in a
      post-order walk to remove all descendants.
      
      This is a behavior change but kobject / driver layer, which currently
      is the only consumer, has already been updated to handle duplicate
      removal attempts, so nothing should be broken after this change.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcdde7e2
    • T
      kobject: grab an extra reference on kobject->sd to allow duplicate deletes · 26ea12de
      Tejun Heo 提交于
      sysfs currently has a rather weird behavior regarding removals.  A
      directory removal would delete all files directly under it but
      wouldn't recurse into subdirectories, which, while a bit inconsistent,
      seems to make sense at the first glance as each directory is
      supposedly associated with a kobject and each kobject can take care of
      the directory deletion; however, this doesn't really hold as we have
      groups which can be directories without a kobject associated with it
      and require explicit deletions.
      
      We're in the process of separating out sysfs from kboject / driver
      core and want a consistent behavior.  A removal should delete either
      only the specified node or everything under it.  I think it is helpful
      to support recursive atomic removal and later patches will implement
      it.
      
      Such change means that a sysfs_dirent associated with kobject may be
      deleted before the kobject itself is removed if one of its ancestor
      gets removed before it.  As sysfs_remove_dir() puts the base ref, we
      may end up with dangling pointer on descendants.  This can be solved
      by holding an extra reference on the sd from kobject.
      
      Acquire an extra reference on the associated sysfs_dirent on directory
      creation and put it after removal.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26ea12de
    • T
      sysfs: remove sysfs_addrm_cxt->parent_sd · d69ac5a0
      Tejun Heo 提交于
      sysfs_addrm_start/finish() enclose sysfs_dirent additions and
      deletions and sysfs_addrm_cxt is used to record information necessary
      to finish the operations.  Currently, sysfs_addrm_start() takes
      @parent_sd, records it in sysfs_addrm_cxt, and assumes that all
      operations in the block are performed under that @parent_sd.
      
      This assumption has been fine until now but we want to make some
      operations behave recursively and, while having @parent_sd recorded in
      sysfs_addrm_cxt doesn't necessarily prevents that, it becomes
      confusing.
      
      This patch removes sysfs_addrm_cxt->parent_sd and makes
      sysfs_add_one() take an explicit @parent_sd parameter.  Note that
      sysfs_remove_one() doesn't need the extra argument as its parent is
      always known from the target @sd.
      
      While at it, add __acquires/releases() notations to
      sysfs_addrm_start/finish() respectively.
      
      This patch doesn't make any functional difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d69ac5a0
  3. 27 9月, 2013 7 次提交
    • T
      sysfs: @name comes before @ns · cfec0bc8
      Tejun Heo 提交于
      Some internal sysfs functions which take explicit namespace argument
      are weird in that they place the optional @ns in front of @name which
      is contrary to the established convention.  This is confusing and
      error-prone especially as @ns and @name may be interchanged without
      causing compilation warning.
      
      Swap the positions of @name and @ns in the following internal
      functions.
      
       sysfs_find_dirent()
       sysfs_rename()
       sysfs_hash_and_remove()
       sysfs_name_hash()
       sysfs_name_compare()
       create_dir()
      
      This patch doesn't introduce any functional changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cfec0bc8
    • T
      sysfs: clean up sysfs_get_dirent() · 388975cc
      Tejun Heo 提交于
      The pre-existing sysfs interfaces which take explicit namespace
      argument are weird in that they place the optional @ns in front of
      @name which is contrary to the established convention.  For example,
      we end up forcing vast majority of sysfs_get_dirent() users to do
      sysfs_get_dirent(parent, NULL, name), which is silly and error-prone
      especially as @ns and @name may be interchanged without causing
      compilation warning.
      
      This renames sysfs_get_dirent() to sysfs_get_dirent_ns() and swap the
      positions of @name and @ns, and sysfs_get_dirent() is now a wrapper
      around sysfs_get_dirent_ns().  This makes confusions a lot less
      likely.
      
      There are other interfaces which take @ns before @name.  They'll be
      updated by following patches.
      
      This patch doesn't introduce any functional changes.
      
      v2: EXPORT_SYMBOL_GPL() wasn't updated leading to undefined symbol
          error on module builds.  Reported by build test robot.  Fixed.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: Fengguang Wu <fengguang.wu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      388975cc
    • T
      sysfs: drop kobj_ns_type handling · cb26a311
      Tejun Heo 提交于
      The way namespace tags are implemented in sysfs is more complicated
      than necessary.  As each tag is a pointer value and required to be
      non-NULL under a namespace enabled parent, there's no need to record
      separately what type each tag is or where namespace is enabled.
      
      If multiple namespace types are needed, which currently aren't, we can
      simply compare the tag to a set of allowed tags in the superblock
      assuming that the tags, being pointers, won't have the same value
      across multiple types.  Also, whether to filter by namespace tag or
      not can be trivially determined by whether the node has any tagged
      children or not.
      
      This patch rips out kobj_ns_type handling from sysfs.  sysfs no longer
      cares whether specific type of namespace is enabled or not.  If a
      sysfs_dirent has a non-NULL tag, the parent is marked as needing
      namespace filtering and the value is tested against the allowed set of
      tags for the superblock (currently only one but increasing this number
      isn't difficult) and the sysfs_dirent is ignored if it doesn't match.
      
      This removes most kobject namespace knowledge from sysfs proper which
      will enable proper separation and layering of sysfs.  The namespace
      sanity checks in fs/sysfs/dir.c are replaced by the new sanity check
      in kobject_namespace().  As this is the only place ktype->namespace()
      is called for sysfs, this doesn't weaken the sanity check
      significantly.  I omitted converting the sanity check in
      sysfs_do_create_link_sd().  While the check can be shifted to upper
      layer, mistakes there are well contained and should be easily visible
      anyway.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb26a311
    • T
      sysfs: remove ktype->namespace() invocations in symlink code · 4b30ee58
      Tejun Heo 提交于
      There's no reason for sysfs to be calling ktype->namespace().  It is
      backwards, obfuscates what's going on and unnecessarily tangles two
      separate layers.
      
      There are two places where symlink code calls ktype->namespace().
      
      * sysfs_do_create_link_sd() calls it to find out the namespace tag of
        the target directory.  Unless symlinking races with cross-namespace
        renaming, this equals @target_sd->s_ns.
      
      * sysfs_rename_link() uses it to find out the new namespace to rename
        to and the new namespace can be different from the existing one.
        The function is renamed to sysfs_rename_link_ns() with an explicit
        @ns argument and the ktype->namespace() invocation is shifted to the
        device layer.
      
      While this patch replaces ktype->namespace() invocation with the
      recorded result in @target_sd, this shouldn't result in any behvior
      difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b30ee58
    • T
      sysfs: remove ktype->namespace() invocations in directory code · e34ff490
      Tejun Heo 提交于
      For some unrecognizable reason, namespace information is communicated
      to sysfs through ktype->namespace() callback when there's *nothing*
      which needs the use of a callback.  The whole sequence of operations
      is completely synchronous and sysfs operations simply end up calling
      back into the layer which just invoked it in order to find out the
      namespace information, which is completely backwards, obfuscates
      what's going on and unnecessarily tangles two separate layers.
      
      This patch doesn't remove ktype->namespace() but shifts its handling
      to kobject layer.  We probably want to get rid of the callback in the
      long term.
      
      This patch adds an explicit param to sysfs_{create|rename|move}_dir()
      and renames them to sysfs_{create|rename|move}_dir_ns(), respectively.
      ktype->namespace() invocations are moved to the calling sites of the
      above functions.  A new helper kboject_namespace() is introduced which
      directly tests kobj_ns_type_operations->type which should give the
      same result as testing sysfs_fs_type(parent_sd) and returns @kobj's
      namespace tag as necessary.  kobject_namespace() is extern as it will
      be used from another file in the following patches.
      
      This patch should be an equivalent conversion without any functional
      difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e34ff490
    • T
      sysfs: make attr namespace interface less convoluted · 58292cbe
      Tejun Heo 提交于
      sysfs ns (namespace) implementation became more convoluted than
      necessary while trying to hide ns information from visible interface.
      The relatively recent attr ns support is a good example.
      
      * attr ns tag is determined by sysfs_ops->namespace() callback while
        dir tag is determined by kobj_type->namespace().  The placement is
        arbitrary.
      
      * Instead of performing operations with explicit ns tag, the namespace
        callback is routed through sysfs_attr_ns(), sysfs_ops->namespace(),
        class_attr_namespace(), class_attr->namespace().  It's not simpler
        in any sense.  The only thing this convolution does is traversing
        the whole stack backwards.
      
      The namespace callbacks are unncessary because the operations involved
      are inherently synchronous.  The information can be provided in in
      straight-forward top-down direction and reversing that direction is
      unnecessary and against basic design principles.
      
      This backward interface is unnecessarily convoluted and hinders
      properly separating out sysfs from driver model / kobject for proper
      layering.  This patch updates attr ns support such that
      
      * sysfs_ops->namespace() and class_attr->namespace() are dropped.
      
      * sysfs_{create|remove}_file_ns(), which take explicit @ns param, are
        added and sysfs_{create|remove}_file() are now simple wrappers
        around the ns aware functions.
      
      * ns handling is dropped from sysfs_chmod_file().  Nobody uses it at
        this point.  sysfs_chmod_file_ns() can be added later if necessary.
      
      * Explicit @ns is propagated through class_{create|remove}_file_ns()
        and netdev_class_{create|remove}_file_ns().
      
      * driver/net/bonding which is currently the only user of attr
        namespace is updated to use netdev_class_{create|remove}_file_ns()
        with @bh->net as the ns tag instead of using the namespace callback.
      
      This patch should be an equivalent conversion without any functional
      difference.  It makes the code easier to follow, reduces lines of code
      a bit and helps proper separation and layering.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Kay Sievers <kay@vrfy.org>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58292cbe
    • T
      sysfs: drop semicolon from to_sysfs_dirent() definition · bcac3769
      Tejun Heo 提交于
      The expansion of to_sysfs_dirent() contains an unncessary trailing
      semicolon making it impossible to use in the middle of statements.
      Drop it.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcac3769
  4. 06 9月, 2013 1 次提交
  5. 29 8月, 2013 1 次提交
    • E
      sysfs: Restrict mounting sysfs · 7dc5dbc8
      Eric W. Biederman 提交于
      Don't allow mounting sysfs unless the caller has CAP_SYS_ADMIN rights
      over the net namespace.  The principle here is if you create or have
      capabilities over it you can mount it, otherwise you get to live with
      what other people have mounted.
      
      Instead of testing this with a straight forward ns_capable call,
      perform this check the long and torturous way with kobject helpers,
      this keeps direct knowledge of namespaces out of sysfs, and preserves
      the existing sysfs abstractions.
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      7dc5dbc8
  6. 27 8月, 2013 1 次提交
    • E
      userns: Better restrictions on when proc and sysfs can be mounted · e51db735
      Eric W. Biederman 提交于
      Rely on the fact that another flavor of the filesystem is already
      mounted and do not rely on state in the user namespace.
      
      Verify that the mounted filesystem is not covered in any significant
      way.  I would love to verify that the previously mounted filesystem
      has no mounts on top but there are at least the directories
      /proc/sys/fs/binfmt_misc and /sys/fs/cgroup/ that exist explicitly
      for other filesystems to mount on top of.
      
      Refactor the test into a function named fs_fully_visible and call that
      function from the mount routines of proc and sysfs.  This makes this
      test local to the filesystems involved and the results current of when
      the mounts take place, removing a weird threading of the user
      namespace, the mount namespace and the filesystems themselves.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      e51db735
  7. 23 8月, 2013 1 次提交
  8. 22 8月, 2013 10 次提交