1. 15 5月, 2013 1 次提交
  2. 27 4月, 2013 1 次提交
    • J
      nfsd: fix EXDEV checking in rename · aa387d6c
      J. Bruce Fields 提交于
      We again check for the EXDEV a little later on, so the first check is
      redundant.  This check is also slightly racier, since a badly timed
      eviction from the export cache could leave us with the two fh_export
      pointers pointing to two different cache entries which each refer to the
      same underlying export.
      
      It's better to compare vfsmounts as the later check does, but that
      leaves a minor security hole in the case where the two exports refer to
      two different directories especially if (for example) they have
      different root-squashing options.
      
      So, compare ex_path.dentry too.
      Reported-by: NJoe Habermann <joe.habermann@gmail.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      aa387d6c
  3. 23 3月, 2013 1 次提交
  4. 23 2月, 2013 1 次提交
  5. 13 2月, 2013 1 次提交
    • E
      nfsd: Properly compare and initialize kuids and kgids · 6fab8779
      Eric W. Biederman 提交于
      Use uid_eq(uid, GLOBAL_ROOT_UID) instead of !uid.
      Use gid_eq(gid, GLOBAL_ROOT_GID) instead of !gid.
      Use uid_eq(uid, INVALID_UID) instead of uid == -1
      Use gid_eq(uid, INVALID_GID) instead of gid == -1
      Use uid = GLOBAL_ROOT_UID instead of uid = 0;
      Use gid = GLOBAL_ROOT_GID instead of gid = 0;
      Use !uid_eq(uid1, uid2) instead of uid1 != uid2.
      Use !gid_eq(gid1, gid2) instead of gid1 != gid2.
      Use uid_eq(uid1, uid2) instead of uid1 == uid2.
      
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      6fab8779
  6. 22 12月, 2012 1 次提交
  7. 18 12月, 2012 2 次提交
  8. 11 12月, 2012 1 次提交
    • N
      nfsd: avoid permission checks on EXCLUSIVE_CREATE replay · 7007c90f
      Neil Brown 提交于
      With NFSv4, if we create a file then open it we explicit avoid checking
      the permissions on the file during the open because the fact that we
      created it ensures we should be allow to open it (the create and the
      open should appear to be a single operation).
      
      However if the reply to an EXCLUSIVE create gets lots and the client
      resends the create, the current code will perform the permission check -
      because it doesn't realise that it did the open already..
      
      This patch should fix this.
      
      Note that I haven't actually seen this cause a problem.  I was just
      looking at the code trying to figure out a different EXCLUSIVE open
      related issue, and this looked wrong.
      
      (Fix confirmed with pynfs 4.0 test OPEN4--bfields)
      
      Cc: stable@kernel.org
      Signed-off-by: NNeilBrown <neilb@suse.de>
      [bfields: use OWNER_OVERRIDE and update for 4.1]
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      7007c90f
  9. 08 11月, 2012 2 次提交
  10. 18 9月, 2012 1 次提交
    • E
      userns: Pass a userns parameter into posix_acl_to_xattr and posix_acl_from_xattr · 5f3a4a28
      Eric W. Biederman 提交于
       - Pass the user namespace the uid and gid values in the xattr are stored
         in into posix_acl_from_xattr.
      
       - Pass the user namespace kuid and kgid values should be converted into
         when storing uid and gid values in an xattr in posix_acl_to_xattr.
      
      - Modify all callers of posix_acl_from_xattr and posix_acl_to_xattr to
        pass in &init_user_ns.
      
      In the short term this change is not strictly needed but it makes the
      code clearer.  In the longer term this change is necessary to be able to
      mount filesystems outside of the initial user namespace that natively
      store posix acls in the linux xattr format.
      
      Cc: Theodore Tso <tytso@mit.edu>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      5f3a4a28
  11. 11 9月, 2012 1 次提交
  12. 31 7月, 2012 1 次提交
  13. 23 7月, 2012 1 次提交
  14. 14 7月, 2012 1 次提交
  15. 11 7月, 2012 1 次提交
    • J
      nfsd: allow owner_override only for regular files · d91d0b56
      J. Bruce Fields 提交于
      We normally allow the owner of a file to override permissions checks on
      IO operations, since:
      	- the client will take responsibility for doing an access check
      	  on open;
      	- the permission checks offer no protection against malicious
      	  clients--if they can authenticate as the file's owner then
      	  they can always just change its permissions;
      	- checking permission on each IO operation breaks the usual
      	  posix rule that permission is checked only on open.
      
      However, we've never allowed the owner to override permissions on
      readdir operations, even though the above logic would also apply to
      directories.  I've never heard of this causing a problem, probably
      because a) simultaneously opening and creating a directory (with
      restricted mode) isn't possible, and b) opening a directory, then
      chmod'ing it, is rare.
      
      Our disallowal of owner-override on directories appears to be an
      accident, though--the readdir itself succeeds, and then we fail just
      because lookup_one_len() calls in our filldir methods fail.
      
      I'm not sure what the easiest fix for that would be.  For now, just make
      this behavior obvious by denying the override right at the start.
      
      This also fixes some odd v4 behavior: with the rdattr_error attribute
      requested, it would perform the readdir but return an ACCES error with
      each entry.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      d91d0b56
  16. 26 4月, 2012 1 次提交
  17. 12 4月, 2012 1 次提交
    • J
      nfsd: don't fail unchecked creates of non-special files · 9dc4e6c4
      J. Bruce Fields 提交于
      Allow a v3 unchecked open of a non-regular file succeed as if it were a
      lookup; typically a client in such a case will want to fall back on a
      local open, so succeeding and giving it the filehandle is more useful
      than failing with nfserr_exist, which makes it appear that nothing at
      all exists by that name.
      
      Similarly for v4, on an open-create, return the same errors we would on
      an attempt to open a non-regular file, instead of returning
      nfserr_exist.
      
      This fixes a problem found doing a v4 open of a symlink with
      O_RDONLY|O_CREAT, which resulted in the current client returning EEXIST.
      
      Thanks also to Trond for analysis.
      
      Cc: stable@kernel.org
      Reported-by: NOrion Poplawski <orion@cora.nwra.com>
      Tested-by: NOrion Poplawski <orion@cora.nwra.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      9dc4e6c4
  18. 21 3月, 2012 1 次提交
  19. 19 3月, 2012 2 次提交
  20. 06 1月, 2012 1 次提交
    • C
      NFSD: Change name of extended attribute containing junction · 9b4146e8
      Chuck Lever 提交于
      As of fedfs-utils-0.8.0, user space stores all NFS junction
      information in a single extended attribute: "trusted.junction.nfs".
      
      Both FedFS and NFS basic junctions are stored in this one attribute,
      and the intention is that all future forms of NFS junction metadata
      will be stored in this attribute.  Other protocols may use a different
      extended attribute.
      
      Thus NFSD needs to look only for that one extended attribute.  The
      "trusted.junction.type" xattr is deprecated.  fedfs-utils-0.8.0 will
      continue to attach a "trusted.junction.type" xattr to junctions, but
      future fedfs-utils releases may no longer do that.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      9b4146e8
  21. 04 1月, 2012 2 次提交
  22. 18 10月, 2011 1 次提交
  23. 14 9月, 2011 1 次提交
  24. 28 8月, 2011 1 次提交
    • J
      nfsd4: permit read opens of executable-only files · a043226b
      J. Bruce Fields 提交于
      A client that wants to execute a file must be able to read it.  Read
      opens over nfs are therefore implicitly allowed for executable files
      even when those files are not readable.
      
      NFSv2/v3 get this right by using a passed-in NFSD_MAY_OWNER_OVERRIDE on
      read requests, but NFSv4 has gotten this wrong ever since
      dc730e17 "nfsd4: fix owner-override on
      open", when we realized that the file owner shouldn't override
      permissions on non-reclaim NFSv4 opens.
      
      So we can't use NFSD_MAY_OWNER_OVERRIDE to tell nfsd_permission to allow
      reads of executable files.
      
      So, do the same thing we do whenever we encounter another weird NFS
      permission nit: define yet another NFSD_MAY_* flag.
      
      The industry's future standardization on 128-bit processors will be
      motivated primarily by the need for integers with enough bits for all
      the NFSD_MAY_* flags.
      Reported-by: NLeonardo Borda <leonardoborda@gmail.com>
      Cc: stable@kernel.org
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      a043226b
  25. 27 8月, 2011 2 次提交
  26. 20 6月, 2011 1 次提交
  27. 07 6月, 2011 1 次提交
  28. 30 4月, 2011 2 次提交
  29. 20 4月, 2011 1 次提交
    • S
      Open with O_CREAT flag set fails to open existing files on non writable directories · 1574dff8
      Sachin Prabhu 提交于
      An open on a NFS4 share using the O_CREAT flag on an existing file for
      which we have permissions to open but contained in a directory with no
      write permissions will fail with EACCES.
      
      A tcpdump shows that the client had set the open mode to UNCHECKED which
      indicates that the file should be created if it doesn't exist and
      encountering an existing flag is not an error. Since in this case the
      file exists and can be opened by the user, the NFS server is wrong in
      attempting to check create permissions on the parent directory.
      
      The patch adds a conditional statement to check for create permissions
      only if the file doesn't exist.
      Signed-off-by: NSachin S. Prabhu <sprabhu@redhat.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      1574dff8
  30. 11 4月, 2011 2 次提交
  31. 18 3月, 2011 1 次提交
  32. 08 3月, 2011 1 次提交
    • J
      NFSD, VFS: Remove dead code in nfsd_rename() · 46d4cef9
      Jesper Juhl 提交于
      Currently we have the following code in fs/nfsd/vfs.c::nfsd_rename() :
      
      	...
      	host_err = nfsd_break_lease(odentry->d_inode);
      	if (host_err)
      		goto out_drop_write;
      	if (ndentry->d_inode) {
      		host_err = nfsd_break_lease(ndentry->d_inode);
      		if (host_err)
      			goto out_drop_write;
      	}
      	if (host_err)
      		goto out_drop_write;
      	...
      
      'host_err' is guaranteed to be 0 by the time we test 'ndentry->d_inode'.
      If 'host_err' becomes != 0 inside the 'if' statement, then we goto
      'out_drop_write'. So, after the 'if' statement there is no way that
      'host_err' can be anything but 0, so the test afterwards is just dead
      code.
      This patch removes the dead code.
      Signed-off-by: NJesper Juhl <jj@chaosbits.net>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      46d4cef9
  33. 14 2月, 2011 1 次提交