1. 25 6月, 2016 1 次提交
  2. 16 3月, 2016 6 次提交
  3. 16 4月, 2015 1 次提交
  4. 12 4月, 2015 1 次提交
  5. 24 1月, 2014 1 次提交
  6. 17 9月, 2013 1 次提交
  7. 02 3月, 2013 1 次提交
  8. 15 11月, 2012 1 次提交
    • E
      userns: Support autofs4 interacing with multiple user namespaces · 45634cd8
      Eric W. Biederman 提交于
      Use kuid_t and kgid_t in struct autofs_info and struct autofs_wait_queue.
      
      When creating directories and symlinks default the uid and gid of
      the mount requester to the global root uid and gid.  autofs4_wait
      will update these fields when a mount is requested.
      
      When generating autofsv5 packets report the uid and gid of the mount
      requestor in user namespace of the process that opened the pipe,
      reporting unmapped uids and gids as overflowuid and overflowgid.
      
      In autofs_dev_ioctl_requester return the uid and gid of the last mount
      requester converted into the calling processes user namespace.  When the
      uid or gid don't map return overflowuid and overflowgid as appropriate,
      allowing failure to find a mount requester to be distinguished from
      failure to map a mount requester.
      
      The uid and gid mount options specifying the user and group of the
      root autofs inode are converted into kuid and kgid as they are parsed
      defaulting to the current uid and current gid of the process that
      mounts autofs.
      
      Mounting of autofs for the present remains confined to processes in
      the initial user namespace.
      
      Cc: Ian Kent <raven@themaw.net>
      Acked-by: NSerge Hallyn <serge.hallyn@canonical.com>
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      45634cd8
  9. 27 9月, 2012 1 次提交
  10. 28 4月, 2012 1 次提交
    • L
      Revert "autofs: work around unhappy compat problem on x86-64" · fcbf94b9
      Linus Torvalds 提交于
      This reverts commit a32744d4.
      
      While that commit was technically the right thing to do, and made the
      x86-64 compat mode work identically to native 32-bit mode (and thus
      fixing the problem with a 32-bit systemd install on a 64-bit kernel), it
      turns out that the automount binaries had workarounds for this compat
      problem.
      
      Now, the workarounds are disgusting: doing an "uname()" to find out the
      architecture of the kernel, and then comparing it for the 64-bit cases
      and fixing up the size of the read() in automount for those.  And they
      were confused: it's not actually a generic 64-bit issue at all, it's
      very much tied to just x86-64, which has different alignment for an
      'u64' in 64-bit mode than in 32-bit mode.
      
      But the end result is that fixing the compat layer actually breaks the
      case of a 32-bit automount on a x86-64 kernel.
      
      There are various approaches to fix this (including just doing a
      "strcmp()" on current->comm and comparing it to "automount"), but I
      think that I will do the one that teaches pipes about a special "packet
      mode", which will allow user space to not have to care too deeply about
      the padding at the end of the autofs packet.
      
      That change will make the compat workaround unnecessary, so let's revert
      it first, and get automount working again in compat mode.  The
      packetized pipes will then fix autofs for systemd.
      Reported-and-requested-by: NMichael Tokarev <mjt@tls.msk.ru>
      Cc: Ian Kent <raven@themaw.net>
      Cc: stable@kernel.org # for 3.3
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fcbf94b9
  11. 26 2月, 2012 1 次提交
    • I
      autofs: work around unhappy compat problem on x86-64 · a32744d4
      Ian Kent 提交于
      When the autofs protocol version 5 packet type was added in commit
      5c0a32fc ("autofs4: add new packet type for v5 communications"), it
      obvously tried quite hard to be word-size agnostic, and uses explicitly
      sized fields that are all correctly aligned.
      
      However, with the final "char name[NAME_MAX+1]" array at the end, the
      actual size of the structure ends up being not very well defined:
      because the struct isn't marked 'packed', doing a "sizeof()" on it will
      align the size of the struct up to the biggest alignment of the members
      it has.
      
      And despite all the members being the same, the alignment of them is
      different: a "__u64" has 4-byte alignment on x86-32, but native 8-byte
      alignment on x86-64.  And while 'NAME_MAX+1' ends up being a nice round
      number (256), the name[] array starts out a 4-byte aligned.
      
      End result: the "packed" size of the structure is 300 bytes: 4-byte, but
      not 8-byte aligned.
      
      As a result, despite all the fields being in the same place on all
      architectures, sizeof() will round up that size to 304 bytes on
      architectures that have 8-byte alignment for u64.
      
      Note that this is *not* a problem for 32-bit compat mode on POWER, since
      there __u64 is 8-byte aligned even in 32-bit mode.  But on x86, 32-bit
      and 64-bit alignment is different for 64-bit entities, and as a result
      the structure that has exactly the same layout has different sizes.
      
      So on x86-64, but no other architecture, we will just subtract 4 from
      the size of the structure when running in a compat task.  That way we
      will write the properly sized packet that user mode expects.
      
      Not pretty.  Sadly, this very subtle, and unnecessary, size difference
      has been encoded in user space that wants to read packets of *exactly*
      the right size, and will refuse to touch anything else.
      Reported-and-tested-by: NThomas Meyer <thomas@m3y3r.de>
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a32744d4
  12. 14 1月, 2012 1 次提交
  13. 11 1月, 2012 3 次提交
    • A
      autofs4: deal with autofs4_write/autofs4_write races · d668dc56
      Al Viro 提交于
      Just serialize the actual writing of packets into pipe on
      a new mutex, independent from everything else in the locking
      hierarchy.  As soon as something has started feeding a piece
      of packet into the pipe to daemon, we *want* everything else
      about to try the same to wait until we are done.
      Acked-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      d668dc56
    • A
      autofs4: catatonic_mode vs. notify_daemon race · 87533332
      Al Viro 提交于
      we need to hold ->wq_mutex while we are forming the packet to send,
      lest we have autofs4_catatonic_mode() setting wq->name.name to NULL
      just as autofs4_notify_daemon() decides to memcpy() from it...
      
      We do have check for catatonic mode immediately after that (under
      ->wq_mutex, as it ought to be) and packet won't be actually sent,
      but it'll be too late for us if we oops on that memcpy() from NULL...
      
      Fix is obvious - just extend the area covered by ->wq_mutex over
      that switch and check whether it's catatonic *before* doing anything
      else.
      Acked-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      87533332
    • A
      autofs4: autofs4_wait() vs. autofs4_catatonic_mode() race · 4041bcdc
      Al Viro 提交于
      We need to recheck ->catatonic after autofs4_wait() got ->wq_mutex
      for good, or we might end up with wq inserted into queue after
      autofs4_catatonic_mode() had done its thing.  It will stick there
      forever, since there won't be anything to clear its ->name.name.
      
      A bit of a complication: validate_request() drops and regains ->wq_mutex.
      It actually ends up the most convenient place to stick the check into...
      Acked-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      4041bcdc
  14. 09 8月, 2011 1 次提交
    • L
      autofs4: fix debug printk warning uncovered by cleanup · 2f84dd70
      Linus Torvalds 提交于
      The previous comit made the autofs4 debug printouts check types against
      the printout format, and uncovered this bug:
      
        fs/autofs4/waitq.c:106:2: warning: format ‘%08lx’ expects type ‘long unsigned int’, but argument 4 has type ‘autofs_wqt_t’
      
      which is due to the insane type for wait_queue_token.  That thing should
      be some fixed well-defined size (preferably just 'unsigned int' or
      'u32') but for unexplained reasons it is randomly either 'unsigned long'
      or 'unsigned int' depending on the architecture.
      
      For now, cast it to 'unsigned long' for printing, the way we do
      elsewhere.  Somebody else can try to explain the typedef mess.
      
      (There's a reason we don't support excessive use of typedefs in the
      kernel: it's usually just a good way of confusing yourself).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2f84dd70
  15. 25 3月, 2011 1 次提交
  16. 16 1月, 2011 1 次提交
  17. 07 1月, 2011 2 次提交
    • N
      fs: dcache remove dcache_lock · b5c84bf6
      Nick Piggin 提交于
      dcache_lock no longer protects anything. remove it.
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      b5c84bf6
    • N
      fs: Use rename lock and RCU for multi-step operations · 949854d0
      Nick Piggin 提交于
      The remaining usages for dcache_lock is to allow atomic, multi-step read-side
      operations over the directory tree by excluding modifications to the tree.
      Also, to walk in the leaf->root direction in the tree where we don't have
      a natural d_lock ordering.
      
      This could be accomplished by taking every d_lock, but this would mean a
      huge number of locks and actually gets very tricky.
      
      Solve this instead by using the rename seqlock for multi-step read-side
      operations, retry in case of a rename so we don't walk up the wrong parent.
      Concurrent dentry insertions are not serialised against.  Concurrent deletes
      are tricky when walking up the directory: our parent might have been deleted
      when dropping locks so also need to check and retry for that.
      
      We can also use the rename lock in cases where livelock is a worry (and it
      is introduced in subsequent patch).
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      949854d0
  18. 10 6月, 2009 1 次提交
    • I
      autofs4: remove hashed check in validate_wait() · 463aea1a
      Ian Kent 提交于
      The recent ->lookup() deadlock correction required the directory inode
      mutex to be dropped while waiting for expire completion.  We were
      concerned about side effects from this change and one has been identified.
      
      I saw several error messages.
      
      They cause autofs to become quite confused and don't really point to the
      actual problem.
      
      Things like:
      
      handle_packet_missing_direct:1376: can't find map entry for (43,1827932)
      
      which is usually totally fatal (although in this case it wouldn't be
      except that I treat is as such because it normally is).
      
      do_mount_direct: direct trigger not valid or already mounted
      /test/nested/g3c/s1/ss1
      
      which is recoverable, however if this problem is at play it can cause
      autofs to become quite confused as to the dependencies in the mount tree
      because mount triggers end up mounted multiple times.  It's hard to
      accurately check for this over mounting case and automount shouldn't need
      to if the kernel module is doing its job.
      
      There was one other message, similar in consequence of this last one but I
      can't locate a log example just now.
      
      When checking if a mount has already completed prior to adding a new mount
      request to the wait queue we check if the dentry is hashed and, if so, if
      it is a mount point.  But, if a mount successfully completed while we
      slept on the wait queue mutex the dentry must exist for the mount to have
      completed so the test is not really needed.
      
      Mounts can also be done on top of a global root dentry, so for the above
      case, where a mount request completes and the wait queue entry has already
      been removed, the hashed test returning false can cause an incorrect
      callback to the daemon.  Also, d_mountpoint() is not sufficient to check
      if a mount has completed for the multi-mount case when we don't have a
      real mount at the base of the tree.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      463aea1a
  19. 07 1月, 2009 1 次提交
    • I
      autofs4: make autofs type usage explicit · a92daf6b
      Ian Kent 提交于
      - the type assigned at mount when no type is given is changed
        from 0 to AUTOFS_TYPE_INDIRECT. This was done because 0 and
        AUTOFS_TYPE_INDIRECT were being treated implicitly as the same
        type.
      
      - previously, an offset mount had it's type set to
        AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET but the mount control
        re-implementation needs to be able distinguish all three types.
        So this was changed to make the type setting explicit.
      
      - a type AUTOFS_TYPE_ANY was added for use by the re-implementation
        when checking if a given path is a mountpoint. It's not really a
        type as we use this to ask if a given path is a mountpoint in the
        autofs_dev_ioctl_ismountpoint() function.
      
      - functions to set and test the autofs mount types have been added to
        improve readability and make the type usage explicit.
      
      - the mount type is used from user space for the mount control
        re-implementtion so, for consistency, all the definitions have
        been moved to the user space include file include/linux/auto_fs4.h.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NJeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a92daf6b
  20. 14 11月, 2008 1 次提交
  21. 17 10月, 2008 2 次提交
  22. 25 7月, 2008 8 次提交
    • I
      autofs4: indirect dentry must almost always be positive · c72305b5
      Ian Kent 提交于
      We have been seeing mount requests comming to the automount daemon for
      keys of the form "<map key>/<non key directory>" which are lookups for
      invalid map keys.  But we can check for this in the kernel module and
      return a fail immediately, without having to send a request to the daemon.
      
      It is possible to recognise these requests are invalid based on whether
      the request dentry is negative and its relation to the autofs file system
      root.
      
      For example, given the indirect multi-mount map entry:
      
      idm1  \
          /mm1  <server>:/<path1>
          /mm2  <server>:/<path2>
      
      For a request to mount idm1, IS_ROOT((idm1)->d_parent) will be always be
      true and the dentry may be negative.  But directories idm1/mm1 and
      idm1/mm2 will always be created as part of the mount request for idm1.  So
      any mount request within idm1 itself must have a positive dentry otherwise
      the map key is invalid.
      
      In version 4 these multi-mount entries are all mounted and umounted as a
      single request and in version 5 the directories idm1/mm1 and idm1/mm2 are
      created and an autofs fs mounted on them to act as a mount trigger so the
      above is also true.
      
      This also holds true for the autofs version 4 pseudo direct mount feature.
       When this feature is used without the "--ghost" option automount(8) will
      create internal submounts as we go down the map key paths which are
      essentially normal indirect mounts for which the above holds.  If the
      "--ghost" option is given the directories for map keys are created at
      daemon startup so valid map entries correspond to postive dentries in the
      autofs fs.
      
      autofs version 5 direct mount maps are similar except that the IS_ROOT
      check is not needed.  This has been addressed in a previous patch tittled
      "autofs4 - detect invalid direct mount requests".
      
      For example, given the direct multi-mount map entry:
      
      /test/dm1  \
          /mm1  <server>:/<path1>
          /mm2  <server>:/<path2>
      
      An autofs fs is mounted on /test/dm1 as a trigger mount and when a mount
      is triggered for /test/dm1, the multi-mount offset directories
      /test/dm1/mm1 and /test/dm1/mm2 are created and an autofs fs is mounted on
      them to act as mount triggers.  So valid direct mount requests must always
      have a positive dentry if they correspond to a valid map entry.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Acked-by: NJeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c72305b5
    • I
      autofs4: detect invalid direct mount requests · eb3b1767
      Ian Kent 提交于
      autofs v5 direct and offset mounts within an autofs filesystem are
      triggered by existing autofs triger mounts so the mount point dentry must
      be positive.  If the mount point dentry is negative then the trigger
      doesn't exist so we can return fail immediately.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Cc: Jeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      eb3b1767
    • I
      autofs4: fix waitq memory leak · 296f7bf7
      Ian Kent 提交于
      If an autofs mount becomes catatonic before autofs4_wait_release() is
      called the wait queue counter will not be decremented down to zero and the
      entry will never be freed.  There are also races decrementing the wait
      counter in the wait release function.  To deal with this the counter needs
      to be updated while holding the wait queue mutex and waiters need to be
      woken up unconditionally when the wait is removed from the queue to ensure
      we eventually free the wait.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      296f7bf7
    • I
      autofs4: check kernel communication pipe is valid for write · e64be33c
      Ian Kent 提交于
      It is possible for an autofs mount to become catatonic (and for the daemon
      communication pipe to become NULL) after a wait has been initiallized but
      before the request has been sent to the daemon.  We need to check for this
      before sending the request packet.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e64be33c
    • I
      autofs4: add missing kfree · f4c7da02
      Ian Kent 提交于
      It see that the patch tittled "autofs4 - fix pending mount race" is
      missing a change that I had recently made.
      
      It's missing a kfree for the case mutex_lock_interruptible() fails
      to aquire the wait queue mutex.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Cc: Jeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f4c7da02
    • I
      autofs4: fix pending mount race · a1362fe9
      Ian Kent 提交于
      Close a race between a pending mount that is about to finish and a new
      lookup for the same directory.
      
      Process P1 triggers a mount of directory foo.  It sets
      DCACHE_AUTOFS_PENDING in the ->lookup routine, creates a waitq entry for
      'foo', and calls out to the daemon to perform the mount.  The autofs
      daemon will then create the directory 'foo', using a new dentry that will
      be hashed in the dcache.
      
      Before the mount completes, another process, P2, tries to walk into the
      'foo' directory.  The vfs path walking code finds an entry for 'foo' and
      calls the revalidate method.  Revalidate finds that the entry is not
      PENDING (because PENDING was never set on the dentry created by the
      mkdir), but it does find the directory is empty.  Revalidate calls
      try_to_fill_dentry, which sets the PENDING flag and then calls into the
      autofs4 wait code to trigger or wait for a mount of 'foo'.  The wait code
      finds the entry for 'foo' and goes to sleep waiting for the completion of
      the mount.
      
      Yet another process, P3, tries to walk into the 'foo' directory.  This
      process again finds a dentry in the dcache for 'foo', and calls into the
      autofs revalidate code.
      
      The revalidate code finds that the PENDING flag is set, and so calls
      try_to_fill_dentry.
      
      a) try_to_fill_dentry sets the PENDING flag redundantly for this
         dentry, then calls into the autofs4 wait code.
      
      b) the autofs4 wait code takes the waitq mutex and searches for an
         entry for 'foo'
      
      Between a and b, P1 is woken up because the mount completed.  P1 takes the
      wait queue mutex, clears the PENDING flag from the dentry, and removes the
      waitqueue entry for 'foo' from the list.
      
      When it releases the waitq mutex, P3 (eventually) acquires it.  At this
      time, it looks for an existing waitq for 'foo', finds none, and so creates
      a new one and calls out to the daemon to mount the 'foo' directory.
      
      Now, the reason that three processes are required to trigger this race is
      that, because the PENDING flag is not set on the dentry created by mkdir,
      the window for the race would be way to slim for it to ever occur.
      Basically, between the testing of d_mountpoint(dentry) and the taking of
      the waitq mutex, the mount would have to complete and the daemon would
      have to be woken up, and that in turn would have to wake up P1.  This is
      simply impossible.  Add the third process, though, and it becomes slightly
      more likely.
      Signed-off-by: NJeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a1362fe9
    • I
      autofs4: fix waitq locking · 5a11d4d0
      Ian Kent 提交于
      The autofs4_catatonic_mode() function accesses the wait queue without any
      locking but can be called at any time.  This could lead to a possible
      double free of the name field of the wait and a double fput of the daemon
      communication pipe or an fput of a NULL file pointer.
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5a11d4d0
    • J
      autofs4: use struct qstr in waitq.c · 70b52a0a
      Jeff Moyer 提交于
      The autofs_wait_queue already contains all of the fields of the
      struct qstr, so change it into a qstr.
      
      This patch, from Jeff Moyer, has been modified a liitle by myself.
      Signed-off-by: NJeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      70b52a0a
  23. 01 5月, 2008 1 次提交
  24. 19 10月, 2007 1 次提交