1. 30 May, 2014 7 commits
    • J. Bruce Fields's avatar
      nfsd4: remove redundant encode buffer size checking · ea8d7720
      J. Bruce Fields authored
      Now that all op encoders can handle running out of space, we no longer
      need to check the remaining size for every operation; only nonidempotent
      operations need that check, and that can be done by
      nfsd4_check_resp_size.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      ea8d7720
    • J. Bruce Fields's avatar
      nfsd4: nfsd4_check_resp_size needn't recalculate length · 67492c99
      J. Bruce Fields authored
      We're keeping the length updated as we go now, so there's no need for
      the extra calculation here.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      67492c99
    • J. Bruce Fields's avatar
      nfsd4: reserve space before inlining 0-copy pages · 4e21ac4b
      J. Bruce Fields authored
      Once we've included page-cache pages in the encoding it's difficult to
      remove them and restart encoding.  (xdr_truncate_encode doesn't handle
      that case.)  So, make sure we'll have adequate space to finish the
      operation first.
      
      For now COMPOUND_SLACK_SPACE checks should prevent this case happening,
      but we want to remove those checks.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      4e21ac4b
    • J. Bruce Fields's avatar
      nfsd4: teach encoders to handle reserve_space failures · d0a381dd
      J. Bruce Fields authored
      We've tried to prevent running out of space with COMPOUND_SLACK_SPACE
      and special checking in those operations (getattr) whose result can vary
      enormously.
      
      However:
      	- COMPOUND_SLACK_SPACE may be difficult to maintain as we add
      	  more protocol.
      	- BUG_ON or page faulting on failure seems overly fragile.
      	- Especially in the 4.1 case, we prefer not to fail compounds
      	  just because the returned result came *close* to session
      	  limits.  (Though perfect enforcement here may be difficult.)
      	- I'd prefer encoding to be uniform for all encoders instead of
      	  having special exceptions for encoders containing, for
      	  example, attributes.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      d0a381dd
    • J. Bruce Fields's avatar
      nfsd4: "backfill" using write_bytes_to_xdr_buf · 082d4bd7
      J. Bruce Fields authored
      Normally xdr encoding proceeds in a single pass from start of a buffer
      to end, but sometimes we have to write a few bytes to an earlier
      position.
      
      Use write_bytes_to_xdr_buf for these cases rather than saving a pointer
      to write to.  We plan to rewrite xdr_reserve_space to handle encoding
      across page boundaries using a scratch buffer, and don't want to risk
      writing to a pointer that was contained in a scratch buffer.
      
      Also it will no longer be safe to calculate lengths by subtracting two
      pointers, so use xdr_buf offsets instead.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      082d4bd7
    • J. Bruce Fields's avatar
      nfsd4: use xdr_truncate_encode · 1fcea5b2
      J. Bruce Fields authored
      Now that lengths are reliable, we can use xdr_truncate instead of
      open-coding it everywhere.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      1fcea5b2
    • J. Bruce Fields's avatar
      rpc: xdr_truncate_encode · 3e19ce76
      J. Bruce Fields authored
      This will be used in the server side in a few cases:
      	- when certain operations (read, readdir, readlink) fail after
      	  encoding a partial response.
      	- when we run out of space after encoding a partial response.
      	- in readlink, where we initially reserve PAGE_SIZE bytes for
      	  data, then truncate to the actual size.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      3e19ce76
  2. 28 May, 2014 5 commits
  3. 27 May, 2014 2 commits
  4. 23 May, 2014 9 commits
  5. 22 May, 2014 7 commits
  6. 21 May, 2014 4 commits
    • J. Bruce Fields's avatar
      nfsd4: fix delegation cleanup on error · cbf7a75b
      J. Bruce Fields authored
      We're not cleaning up everything we need to on error.  In particular,
      we're not removing our lease.  Among other problems this can cause the
      struct nfs4_file used as fl_owner to be referenced after it has been
      destroyed.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      cbf7a75b
    • Kinglong Mee's avatar
      NFSD: Don't clear SUID/SGID after root writing data · 368fe39b
      Kinglong Mee authored
      We're clearing the SUID/SGID bits on write by hand in nfsd_vfs_write,
      even though the subsequent vfs_writev() call will end up doing this for
      us (through file system write methods eventually calling
      file_remove_suid(), e.g., from __generic_file_aio_write).
      
      So, remove the redundant nfsd code.
      
      The only change in behavior is when the write is by root, in which case
      we previously cleared SUID/SGID, but will now leave it alone.  The new
      behavior is the behavior of every filesystem we've checked.
      
      It seems better to be consistent with local filesystem behavior.  And
      the security advantage seems limited as root could always restore these
      bits by hand if it wanted.
      
      SUID/SGID is not cleared after writing data with (root, local ext4),
         File: ‘test’
         Size: 0               Blocks: 0          IO Block: 4096   regular
      empty file
      Device: 803h/2051d      Inode: 1200137     Links: 1
      Access: (4777/-rwsrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
      Context: unconfined_u:object_r:admin_home_t:s0
      Access: 2014-04-18 21:36:31.016029014 +0800
      Modify: 2014-04-18 21:36:31.016029014 +0800
      Change: 2014-04-18 21:36:31.026030285 +0800
        Birth: -
         File: ‘test’
         Size: 5               Blocks: 8          IO Block: 4096   regular file
      Device: 803h/2051d      Inode: 1200137     Links: 1
      Access: (4777/-rwsrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
      Context: unconfined_u:object_r:admin_home_t:s0
      Access: 2014-04-18 21:36:31.016029014 +0800
      Modify: 2014-04-18 21:36:31.040032065 +0800
      Change: 2014-04-18 21:36:31.040032065 +0800
        Birth: -
      
      With no_root_squash, (root, remote ext4), SUID/SGID are cleared,
         File: ‘test’
         Size: 0               Blocks: 0          IO Block: 262144 regular
      empty file
      Device: 24h/36d Inode: 786439      Links: 1
      Access: (4777/-rwsrwxrwx)  Uid: ( 1000/    test)   Gid: ( 1000/    test)
      Context: system_u:object_r:nfs_t:s0
      Access: 2014-04-18 21:45:32.155805097 +0800
      Modify: 2014-04-18 21:45:32.155805097 +0800
      Change: 2014-04-18 21:45:32.168806749 +0800
        Birth: -
         File: ‘test’
         Size: 5               Blocks: 8          IO Block: 262144 regular file
      Device: 24h/36d Inode: 786439      Links: 1
      Access: (0777/-rwxrwxrwx)  Uid: ( 1000/    test)   Gid: ( 1000/    test)
      Context: system_u:object_r:nfs_t:s0
      Access: 2014-04-18 21:45:32.155805097 +0800
      Modify: 2014-04-18 21:45:32.184808783 +0800
      Change: 2014-04-18 21:45:32.184808783 +0800
        Birth: -
      Signed-off-by: default avatarKinglong Mee <kinglongmee@gmail.com>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      368fe39b
    • J. Bruce Fields's avatar
      nfsd4: warn on finding lockowner without stateid's · 27b11428
      J. Bruce Fields authored
      The current code assumes a one-to-one lockowner<->lock stateid
      correspondance.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      27b11428
    • J. Bruce Fields's avatar
      nfsd4: remove lockowner when removing lock stateid · a1b8ff4c
      J. Bruce Fields authored
      The nfsv4 state code has always assumed a one-to-one correspondance
      between lock stateid's and lockowners even if it appears not to in some
      places.
      
      We may actually change that, but for now when FREE_STATEID releases a
      lock stateid it also needs to release the parent lockowner.
      
      Symptoms were a subsequent LOCK crashing in find_lockowner_str when it
      calls same_lockowner_ino on a lockowner that unexpectedly has an empty
      so_stateids list.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      a1b8ff4c
  7. 15 May, 2014 1 commit
  8. 08 May, 2014 5 commits