31 Mar, 2011

1 commit


25 Mar, 2011

1 commit


24 Mar, 2011

3 commits

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
    deal with races in /proc/*/{syscall,stack,personality}
    proc: enable writing to /proc/pid/mem
    proc: make check_mem_permission() return an mm_struct on success
    proc: hold cred_guard_mutex in check_mem_permission()
    proc: disable mem_write after exec
    mm: implement access_remote_vm
    mm: factor out main logic of access_process_vm
    mm: use mm_struct to resolve gate vma's in __get_user_pages
    mm: arch: rename in_gate_area_no_task to in_gate_area_no_mm
    mm: arch: make in_gate_area take an mm_struct instead of a task_struct
    mm: arch: make get_gate_vma take an mm_struct instead of a task_struct
    x86: mark associated mm when running a task in 32 bit compatibility mode
    x86: add context tag to mark mm when running a task in 32-bit compatibility mode
    auxv: require the target to be tracable (or yourself)
    close race in /proc/*/environ
    report errors in /proc/*/*map* sanely
    pagemap: close races with suid execve
    make sessionid permissions in /proc/*/task/* match those in /proc/*
    fix leaks in path_lookupat()

    Fix up trivial conflicts in fs/proc/base.c

    Linus Torvalds
     
  • And give it a kernel-doc comment.

    [akpm@linux-foundation.org: btrfs changed in linux-next]
    Signed-off-by: Serge E. Hallyn
    Cc: "Eric W. Biederman"
    Cc: Daniel Lezcano
    Acked-by: David Howells
    Cc: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     
  • Cheat for now and say all files belong to init_user_ns. Next step will be
    to let superblocks belong to a user_ns, and derive inode_userns(inode)
    from inode->i_sb->s_user_ns. Finally we'll introduce more flexible
    arrangements.

    Changelog:
    Feb 15: make is_owner_or_cap take const struct inode
    Feb 23: make is_owner_or_cap bool

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Serge E. Hallyn
    Acked-by: "Eric W. Biederman"
    Acked-by: Daniel Lezcano
    Acked-by: David Howells
    Cc: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     

23 Mar, 2011

1 commit


18 Mar, 2011

2 commits


16 Mar, 2011

8 commits


15 Mar, 2011

4 commits

  • 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: Al Viro

    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: Al Viro

    Al Viro
     
  • 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: Aneesh Kumar K.V
    Signed-off-by: Al Viro

    Aneesh Kumar K.V
     
  • 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: Al Viro

    Al Viro
     

14 Mar, 2011

20 commits

  • new function: file_open_root(dentry, mnt, name, flags) opens the file
    vfs_path_lookup would arrive to.

    Note that name can be empty; in that case the usual requirement that
    dentry should be a directory is lifted.

    open-coded equivalents switched to it, may_open() got down exactly
    one caller and became static.

    Signed-off-by: Al Viro

    Al Viro
     
  • New lookup flag: LOOKUP_ROOT. nd->root is set (and held) by caller,
    path_init() starts walking from that place and all pathname resolution
    machinery never drops nd->root if that flag is set. That turns
    vfs_path_lookup() into a special case of do_path_lookup() *and*
    gets us down to 3 callers of link_path_walk(), making it finally
    feasible to rip the handling of trailing symlink out of link_path_walk().
    That will not only simply the living hell out of it, but make life
    much simpler for unionfs merge. Trailing symlink handling will
    become iterative, which is a good thing for stack footprint in
    a lot of situations as well.

    Signed-off-by: Al Viro

    Al Viro
     
  • That thing has devolved into rats nest of gotos; sane use of unlikely()
    gets rid of that horror and gives much more readable structure:
    * make a fast attempt to find a dentry; false negatives are OK.
    In RCU mode if everything went fine, we are done, otherwise just drop
    out of RCU. If we'd done (RCU) ->d_revalidate() and it had not refused
    outright (i.e. didn't give us -ECHILD), remember its result.
    * now we are not in RCU mode and hopefully have a dentry. If we
    do not, lock parent, do full d_lookup() and if that has not found anything,
    allocate and call ->lookup(). If we'd done that ->lookup(), remember that
    dentry is good and we don't need to revalidate it.
    * now we have a dentry. If it has ->d_revalidate() and we can't
    skip it, call it.
    * hopefully dentry is good; if not, either fail (in case of error)
    or try to invalidate it. If d_invalidate() has succeeded, drop it and
    retry everything as if original attempt had not found a dentry.
    * now we can finish it up - deal with mountpoint crossing and
    automount.

    Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • There used to be time when ->d_revalidate() couldn't return an error.
    So intents code had lookup_instantiate_filp() stash ERR_PTR(error)
    in nd->intent.open.filp and had it checked after lookup_hash(), to
    catch the otherwise silent failures. That had been introduced by
    commit 4af4c52f34606bdaab6930a845550c6fb02078a4. These days
    ->d_revalidate() can and does propagate errors back to callers
    explicitly, so this check isn't needed anymore.

    Signed-off-by: Al Viro

    Al Viro
     
  • ... and clean up a bit more

    Signed-off-by: Al Viro

    Al Viro
     
  • We have a bunch of diverging codepaths in do_last(); some of
    them converge, but the case of having to create a new file
    duplicates large part of common tail of the rest and exits
    separately. Massage them so that they could be merged.

    Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • Lift it to lookup_one_len() and link_path_walk() resp. into the
    same place where we calculated default hash function of the same
    name.

    Signed-off-by: Al Viro

    Al Viro
     
  • only one caller left

    Signed-off-by: Al Viro

    Al Viro
     
  • Instead of path_lookupat() doing trailing symlink resolution,
    use the same scheme as on the O_CREAT side. Walk with
    LOOKUP_PARENT, then (in do_last()) look the final component
    up, then either open it or return error or, if it's a symlink,
    give the symlink back to path_openat() to be resolved there.

    The really messy complication here is RCU. We don't want to drop
    out of RCU mode before the final lookup, since we don't want to
    bounce parent directory ->d_count without a good reason.

    Result is _not_ pretty; later in the series we'll clean it up.
    For now we are roughly back where we'd been before the revert
    done by Nick's series - top-level logics of path_openat() is
    cleaned up, do_last() does actual opening, symlink resolution is
    done uniformly.

    Signed-off-by: Al Viro

    Al Viro
     
  • Don't stash the struct file * used as starting point of walk in nameidata;
    pass file ** to path_init() instead.

    Signed-off-by: Al Viro

    Al Viro
     
  • New helper: terminate_walk(). An error has happened during pathname
    resolution and we either drop nd->path or terminate RCU, depending
    the mode we had been in. After that, nd is essentially empty.
    Switch link_path_walk() to using that for cleanup.

    Now the top-level logics in link_path_walk() is back to sanity. RCU
    dependencies are in the lower-level functions.

    Signed-off-by: Al Viro

    Al Viro
     
  • Now we have do_follow_link() guaranteed to leave without dangling RCU
    and the next step will get LOOKUP_RCU logics completely out of
    link_path_walk().

    Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • getting LOOKUP_RCU checks out of link_path_walk()...

    Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • new helper: path_openat(). Does what do_filp_open() does, except
    that it tries only the walk mode (RCU/normal/force revalidation)
    it had been told to.

    Both create and non-create branches are using path_lookupat() now.
    Fixed the double audit_inode() in non-create branch.

    Signed-off-by: Al Viro

    Al Viro