1. 15 3月, 2011 4 次提交
    • A
      Allow O_PATH for symlinks · bcda7652
      Al Viro 提交于
      At that point we can't do almost nothing with them.  They can be opened
      with O_PATH, we can manipulate such descriptors with dup(), etc. and
      we can see them in /proc/*/{fd,fdinfo}/*.
      
      We can't (and won't be able to) follow /proc/*/fd/* symlinks for those;
      there's simply not enough information for pathname resolution to go on
      from such point - to resolve a symlink we need to know which directory
      does it live in.
      
      We will be able to do useful things with them after the next commit, though -
      readlinkat() and fchownat() will be possible to use with dfd being an
      O_PATH-opened symlink and empty relative pathname.  Combined with
      open_by_handle() it'll give us a way to do realink-by-handle and
      lchown-by-handle without messing with more redundant syscalls.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      bcda7652
    • A
      New kind of open files - "location only". · 1abf0c71
      Al Viro 提交于
      New flag for open(2) - O_PATH.  Semantics:
      	* pathname is resolved, but the file itself is _NOT_ opened
      as far as filesystem is concerned.
      	* almost all operations on the resulting descriptors shall
      fail with -EBADF.  Exceptions are:
      	1) operations on descriptors themselves (i.e.
      		close(), dup(), dup2(), dup3(), fcntl(fd, F_DUPFD),
      		fcntl(fd, F_DUPFD_CLOEXEC, ...), fcntl(fd, F_GETFD),
      		fcntl(fd, F_SETFD, ...))
      	2) fcntl(fd, F_GETFL), for a common non-destructive way to
      		check if descriptor is open
      	3) "dfd" arguments of ...at(2) syscalls, i.e. the starting
      		points of pathname resolution
      	* closing such descriptor does *NOT* affect dnotify or
      posix locks.
      	* permissions are checked as usual along the way to file;
      no permission checks are applied to the file itself.  Of course,
      giving such thing to syscall will result in permission checks (at
      the moment it means checking that starting point of ....at() is
      a directory and caller has exec permissions on it).
      
      fget() and fget_light() return NULL on such descriptors; use of
      fget_raw() and fget_raw_light() is needed to get them.  That protects
      existing code from dealing with those things.
      
      There are two things still missing (they come in the next commits):
      one is handling of symlinks (right now we refuse to open them that
      way; see the next commit for semantics related to those) and another
      is descriptor passing via SCM_RIGHTS datagrams.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      1abf0c71
    • A
      fs: Don't allow to create hardlink for deleted file · aae8a97d
      Aneesh Kumar K.V 提交于
      Add inode->i_nlink == 0 check in VFS. Some of the file systems
      do this internally. A followup patch will remove those instance.
      This is needed to ensure that with link by handle we don't allow
      to create hardlink of an unlinked file. The check also prevent a race
      between unlink and link
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      aae8a97d
    • A
      New AT_... flag: AT_EMPTY_PATH · f52e0c11
      Al Viro 提交于
      For name_to_handle_at(2) we'll want both ...at()-style syscall that
      would be usable for non-directory descriptors (with empty relative
      pathname).  Introduce new flag (AT_EMPTY_PATH) to deal with that and
      corresponding LOOKUP_EMPTY; teach user_path_at() and path_init() to
      deal with the latter.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      f52e0c11
  2. 14 3月, 2011 31 次提交
  3. 09 3月, 2011 1 次提交
  4. 05 3月, 2011 1 次提交
    • A
      minimal fix for do_filp_open() race · 1858efd4
      Al Viro 提交于
      failure exits on the no-O_CREAT side of do_filp_open() merge with
      those of O_CREAT one; unfortunately, if do_path_lookup() returns
      -ESTALE, we'll get out_filp:, notice that we are about to return
      -ESTALE without having trying to create the sucker with LOOKUP_REVAL
      and jump right into the O_CREAT side of code.  And proceed to try
      and create a file.  Usually that'll fail with -ESTALE again, but
      we can race and get that attempt of pathname resolution to succeed.
      
      open() without O_CREAT really shouldn't end up creating files, races
      or not.  The real fix is to rearchitect the whole do_filp_open(),
      but for now splitting the failure exits will do.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      1858efd4
  5. 17 2月, 2011 1 次提交
    • L
      vfs: fix BUG_ON() in fs/namei.c:1461 · 3abb17e8
      Linus Torvalds 提交于
      When Al moved the nameidata_dentry_drop_rcu_maybe() call into the
      do_follow_link function in commit 844a3917 ("nothing in
      do_follow_link() is going to see RCU"), he mistakenly left the
      
      	BUG_ON(inode != path->dentry->d_inode);
      
      behind.  Which would otherwise be ok, but that BUG_ON() really needs to
      be _after_ dropping RCU, since the dentry isn't necessarily stable
      otherwise.
      
      So complete the code movement in that commit, and move the BUG_ON() into
      do_follow_link() too.  This means that we need to pass in 'inode' as an
      argument (just for this one use), but that's a small thing.  And
      eventually we may be confident enough in our path lookup that we can
      just remove the BUG_ON() and the unnecessary inode argument.
      Reported-and-tested-by: NEric Dumazet <eric.dumazet@gmail.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3abb17e8
  6. 15 2月, 2011 2 次提交