1. 09 9月, 2017 1 次提交
    • I
      autofs: fix AT_NO_AUTOMOUNT not being honored · 42f46148
      Ian Kent 提交于
      The fstatat(2) and statx() calls can pass the flag AT_NO_AUTOMOUNT which
      is meant to clear the LOOKUP_AUTOMOUNT flag and prevent triggering of an
      automount by the call.  But this flag is unconditionally cleared for all
      stat family system calls except statx().
      
      stat family system calls have always triggered mount requests for the
      negative dentry case in follow_automount() which is intended but prevents
      the fstatat(2) and statx() AT_NO_AUTOMOUNT case from being handled.
      
      In order to handle the AT_NO_AUTOMOUNT for both system calls the negative
      dentry case in follow_automount() needs to be changed to return ENOENT
      when the LOOKUP_AUTOMOUNT flag is clear (and the other required flags are
      clear).
      
      AFAICT this change doesn't have any noticable side effects and may, in
      some use cases (although I didn't see it in testing) prevent unnecessary
      callbacks to the automount daemon.
      
      It's also possible that a stat family call has been made with a path that
      is in the process of being mounted by some other process.  But stat family
      calls should return the automount state of the path as it is "now" so it
      shouldn't wait for mount completion.
      
      This is the same semantic as the positive dentry case already handled.
      
      Link: http://lkml.kernel.org/r/150216641255.11652.4204561328197919771.stgit@pluto.themaw.net
      Fixes: deccf497 ("Make stat/lstat/fstatat pass AT_NO_AUTOMOUNT to vfs_statx()")
      Signed-off-by: NIan Kent <raven@themaw.net>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Colin Walters <walters@redhat.com>
      Cc: Ondrej Holy <oholy@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      42f46148
  2. 08 7月, 2017 1 次提交
    • A
      dentry name snapshots · 49d31c2f
      Al Viro 提交于
      take_dentry_name_snapshot() takes a safe snapshot of dentry name;
      if the name is a short one, it gets copied into caller-supplied
      structure, otherwise an extra reference to external name is grabbed
      (those are never modified).  In either case the pointer to stable
      string is stored into the same structure.
      
      dentry must be held by the caller of take_dentry_name_snapshot(),
      but may be freely dropped afterwards - the snapshot will stay
      until destroyed by release_dentry_name_snapshot().
      
      Intended use:
      	struct name_snapshot s;
      
      	take_dentry_name_snapshot(&s, dentry);
      	...
      	access s.name
      	...
      	release_dentry_name_snapshot(&s);
      
      Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name
      to pass down with event.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      49d31c2f
  3. 06 7月, 2017 1 次提交
  4. 01 7月, 2017 1 次提交
    • K
      randstruct: Mark various structs for randomization · 3859a271
      Kees Cook 提交于
      This marks many critical kernel structures for randomization. These are
      structures that have been targeted in the past in security exploits, or
      contain functions pointers, pointers to function pointer tables, lists,
      workqueues, ref-counters, credentials, permissions, or are otherwise
      sensitive. This initial list was extracted from Brad Spengler/PaX Team's
      code in the last public patch of grsecurity/PaX based on my understanding
      of the code. Changes or omissions from the original code are mine and
      don't reflect the original grsecurity/PaX code.
      
      Left out of this list is task_struct, which requires special handling
      and will be covered in a subsequent patch.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      3859a271
  5. 30 6月, 2017 1 次提交
  6. 16 5月, 2017 1 次提交
  7. 09 5月, 2017 1 次提交
  8. 22 4月, 2017 2 次提交
  9. 16 4月, 2017 1 次提交
  10. 30 3月, 2017 1 次提交
  11. 07 2月, 2017 1 次提交
  12. 01 2月, 2017 2 次提交
    • E
      fs: Better permission checking for submounts · 93faccbb
      Eric W. Biederman 提交于
      To support unprivileged users mounting filesystems two permission
      checks have to be performed: a test to see if the user allowed to
      create a mount in the mount namespace, and a test to see if
      the user is allowed to access the specified filesystem.
      
      The automount case is special in that mounting the original filesystem
      grants permission to mount the sub-filesystems, to any user who
      happens to stumble across the their mountpoint and satisfies the
      ordinary filesystem permission checks.
      
      Attempting to handle the automount case by using override_creds
      almost works.  It preserves the idea that permission to mount
      the original filesystem is permission to mount the sub-filesystem.
      Unfortunately using override_creds messes up the filesystems
      ordinary permission checks.
      
      Solve this by being explicit that a mount is a submount by introducing
      vfs_submount, and using it where appropriate.
      
      vfs_submount uses a new mount internal mount flags MS_SUBMOUNT, to let
      sget and friends know that a mount is a submount so they can take appropriate
      action.
      
      sget and sget_userns are modified to not perform any permission checks
      on submounts.
      
      follow_automount is modified to stop using override_creds as that
      has proven problemantic.
      
      do_mount is modified to always remove the new MS_SUBMOUNT flag so
      that we know userspace will never by able to specify it.
      
      autofs4 is modified to stop using current_real_cred that was put in
      there to handle the previous version of submount permission checking.
      
      cifs is modified to pass the mountpoint all of the way down to vfs_submount.
      
      debugfs is modified to pass the mountpoint all of the way down to
      trace_automount by adding a new parameter.  To make this change easier
      a new typedef debugfs_automount_t is introduced to capture the type of
      the debugfs automount function.
      
      Cc: stable@vger.kernel.org
      Fixes: 069d5ac9 ("autofs:  Fix automounts by using current_real_cred()->uid")
      Fixes: aeaa4a79 ("fs: Call d_automount with the filesystems creds")
      Reviewed-by: NTrond Myklebust <trond.myklebust@primarydata.com>
      Reviewed-by: NSeth Forshee <seth.forshee@canonical.com>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      93faccbb
    • S
      vfs: open() with O_CREAT should not create inodes with unknown ids · 1328c727
      Seth Forshee 提交于
      may_create() rejects creation of inodes with ids which lack a
      mapping into s_user_ns. However for O_CREAT may_o_create() is
      is used instead. Add a similar check there.
      
      Fixes: 036d5236 ("vfs: Don't create inodes with a uid or gid unknown to the vfs")
      Signed-off-by: NSeth Forshee <seth.forshee@canonical.com>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      1328c727
  13. 10 1月, 2017 2 次提交
  14. 09 1月, 2017 2 次提交
  15. 25 12月, 2016 1 次提交
  16. 16 12月, 2016 1 次提交
  17. 09 12月, 2016 4 次提交
  18. 06 12月, 2016 7 次提交
  19. 03 12月, 2016 1 次提交
  20. 14 10月, 2016 1 次提交
    • M
      vfs: add vfs_get_link() helper · d60874cd
      Miklos Szeredi 提交于
      This helper is for filesystems that want to read the symlink and are better
      off with the get_link() interface (returning a char *) rather than the
      readlink() interface (copy into a userspace buffer).
      
      Also call the LSM hook for readlink (not get_link) since this is for
      symlink reading not following.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      d60874cd
  21. 27 9月, 2016 2 次提交
  22. 16 9月, 2016 1 次提交
    • M
      vfs: update ovl inode before relatime check · 598e3c8f
      Miklos Szeredi 提交于
      On overlayfs relatime_need_update() needs inode times to be correct on
      overlay inode.  But i_mtime and i_ctime are updated by filesystem code on
      underlying inode only, so they will be out-of-date on the overlay inode.
      
      This patch copies the times from the underlying inode if needed.  This
      can't be done if called from RCU lookup (link following) but link m/ctime
      are not updated by fs, so this is all right.
      
      This patch doesn't change functionality for anything but overlayfs.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      598e3c8f
  23. 07 8月, 2016 1 次提交
  24. 30 7月, 2016 1 次提交
    • L
      Revert "vfs: add lookup_hash() helper" · 20d00ee8
      Linus Torvalds 提交于
      This reverts commit 3c9fe8cd.
      
      As Miklos points out in commit c1b2cc1a, the "lookup_hash()" helper
      is now unused, and in fact, with the hash salting changes, since the
      hash of a dentry name now depends on the directory dentry it is in, the
      helper function isn't even really likely to be useful.
      
      So rather than keep it around in case somebody else might end up finding
      a use for it, let's just remove the helper and not trick people into
      thinking it might be a useful thing.
      
      For example, I had obviously completely missed how the helper didn't
      follow the normal dentry hashing patterns, and how the hash salting
      patch broke overlayfs.  Things would quietly build and look sane, but
      not work.
      Suggested-by: NMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      20d00ee8
  25. 25 7月, 2016 1 次提交
  26. 24 7月, 2016 1 次提交
    • E
      fs: Call d_automount with the filesystems creds · aeaa4a79
      Eric W. Biederman 提交于
      Seth Forshee reported a mount regression in nfs autmounts
      with "fs: Add user namespace member to struct super_block".
      
      It turns out that the assumption that current->cred is something
      reasonable during mount while necessary to improve support of
      unprivileged mounts is wrong in the automount path.
      
      To fix the existing filesystems override current->cred with the
      init_cred before calling d_automount and restore current->cred after
      d_automount completes.
      
      To support unprivileged mounts would require a more nuanced cred
      selection, so fail on unprivileged mounts for the time being.  As none
      of the filesystems that currently set FS_USERNS_MOUNT implement
      d_automount this check is only good for preventing future problems.
      
      Fixes: 6e4eab57 ("fs: Add user namespace member to struct super_block")
      Tested-by: NSeth Forshee <seth.forshee@canonical.com>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      aeaa4a79