1. 01 5月, 2008 7 次提交
    • J
      autofs4: fix execution order race in mount request code · 03379044
      Jeff Moyer 提交于
      Jeff Moyer has identified a race in due to an execution order dependency
      in the autofs4 function root.c:try_to_fill_dentry().
      
      Jeff's description of this race is:
      
      "P1 does a lookup of /mount/submount/foo.  Since the VFS can't find an entry
      for "foo" under /mount/submount, it calls into the autofs4 kernel module to
      allocate a new dentry, D1.  The kernel creates a new waitq for this lookup and
      calls the daemon to perform the mount.
      
      The daemon performs a mkdir of the "foo" directory under /mount/submount,
      which ends up creating a *new* dentry, D2.
      
      Then, P2 does a lookup of /mount/submount/foo.  The VFS path walking logic
      finds a dentry in the dcache, D2, and calls the revalidate function with this.
       In the autofs4 revalidate code, we then trigger a mount, since the dentry is
      an empty directory that isn't a mountpoint, and so set DCACHE_AUTOFS_PENDING
      and call into the wait code to trigger the mount.
      
      The wait code finds our existing waitq entry (since it is keyed off of the
      directory name) and adds itself to the list of waiters.
      
      After the daemon finishes the mount, it calls back into the kernel to release
      the waiters.  When this happens, P1 is woken up and goes about clearing the
      DCACHE_AUTOFS_PENDING flag, but it does this in D1!  So, given that P1 in our
      case is a program that will immediately try to access a file under
      /mount/submount/foo, we end up finding the dentry D2 which still has the
      pending flag set, and we set out to wait for a mount *again*!
      
      So, one way to address this is to re-do the lookup at the end of
      try_to_fill_dentry, and to clear the pending flag on the hashed dentry.  This
      seems a sane approach to me."
      
      And Jeff's patch does this.
      Signed-off-by: NJeff Moyer <jmoyer@redhat.com>
      Signed-off-by-by: NIan Kent <raven@themaw.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      03379044
    • I
      autofs4: check for invalid dentry in getpath · cab0936a
      Ian Kent 提交于
      Catch invalid dentry when calculating its path.
      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>
      cab0936a
    • I
      autofs4: fix sparse warning in waitq.c:autofs4_expire_indirect() · afec570c
      Ian Kent 提交于
      Re-order some code in expire.c:autofs4_expire_indirect() to avoid compile
      warning, reported by Harvey Harrison:
      
       CHECK   fs/autofs4/expire.c
      fs/autofs4/expire.c:383:2: warning: context imbalance in
      'autofs4_expire_indirect' - unexpected unlock
      Signed-off-by: NIan Kent <raven@themaw.net>
      Reviewed-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      afec570c
    • M
      vfs: fix permission checking in sys_utimensat · 02c6be61
      Miklos Szeredi 提交于
      If utimensat() is called with both times set to UTIME_NOW or one of them to
      UTIME_NOW and the other to UTIME_OMIT, then it will update the file time
      without any permission checking.
      
      I don't think this can be used for anything other than a local DoS, but could
      be quite bewildering at that (e.g.  "Why was that large source tree rebuilt
      when I didn't modify anything???")
      
      This affects all kernels from 2.6.22, when the utimensat() syscall was
      introduced.
      
      Fix by doing the same permission checking as for the "times == NULL" case.
      
      Thanks to Michael Kerrisk, whose utimensat-non-conformances-and-fixes.patch in
      -mm also fixes this (and breaks other stuff), only he didn't realize the
      security implications of this bug.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Cc: Ulrich Drepper <drepper@redhat.com>
      Cc: Michael Kerrisk <mtk-manpages@gmx.net>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      02c6be61
    • A
      Fix dnotify/close race · 214b7049
      Al Viro 提交于
      We have a race between fcntl() and close() that can lead to
      dnotify_struct inserted into inode's list *after* the last descriptor
      had been gone from current->files.
      
      Since that's the only point where dnotify_struct gets evicted, we are
      screwed - it will stick around indefinitely.  Even after struct file in
      question is gone and freed.  Worse, we can trigger send_sigio() on it at
      any later point, which allows to send an arbitrary signal to arbitrary
      process if we manage to apply enough memory pressure to get the page
      that used to host that struct file and fill it with the right pattern...
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      214b7049
    • R
    • B
      sysfs: Disallow truncation of files in sysfs · 40a2159a
      Ben Hutchings 提交于
      sysfs allows attribute files to be truncated, e.g. using ftruncate(), with the
      expected effect on their inode.   For most attributes, this doesn't change the
      "real" size of the file i.e. how much can be read from it.  However, the
      parameter validation for reading and writing binary attribute files is based
      on the inode size and not the size specified in the file's bin_attribute, so it
      can be broken by this. For example, if we try using dd to write to such a file:
      
      # pwd
      /sys/bus/pci/devices/0000:08:00.0
      # ls -l config
      -rw-r--r--  1 root root 4096 Feb  1 17:35 config
      # dd if=/dev/zero of=config bs=4 count=1
      1+0 records in
      1+0 records out
      # ls -l config
      -rw-r--r--  1 root root 0 Feb  1 17:50 config
      # dd if=/dev/zero of=config bs=4 count=1 seek=128
      dd: writing `config': No space left on device
      1+0 records in
      0+0 records out
      
      Also, after truncation to 0, parameter validation for read and write is
      disabled.  Most bin_attribute read and write methods also validate the size and
      offset, but for some this will allow out-of-range access.  This may be a
      security issue, though access to such files is often limited to root.  In any
      case, the validation should remain for safety's sake!)
      
      This was previously reported in Bugzilla as bug 9867.
      
      sysfs should ignore size changes or else refuse them (by returning -EINVAL).
      This patch makes it ignore them.
      Signed-off-by: NBen Hutchings <bhutchings@solarflare.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      40a2159a
  2. 30 4月, 2008 33 次提交