1. 17 6月, 2018 2 次提交
  2. 04 4月, 2018 5 次提交
    • J
      nfsd: fix incorrect umasks · 880a3a53
      J. Bruce Fields 提交于
      We're neglecting to clear the umask after it's set, which can cause a
      later unrelated rpc to (incorrectly) use the same umask if it happens to
      be processed by the same thread.
      
      There's a more subtle problem here too:
      
      An NFSv4 compound request is decoded all in one pass before any
      operations are executed.
      
      Currently we're setting current->fs->umask at the time we decode the
      compound.  In theory a single compound could contain multiple creates
      each setting a umask.  In that case we'd end up using whichever umask
      was passed in the *last* operation as the umask for all the creates,
      whether that was correct or not.
      
      So, we should just be saving the umask at decode time and waiting to set
      it until we actually process the corresponding operation.
      
      In practice it's unlikely any client would do multiple creates in a
      single compound.  And even if it did they'd likely be from the same
      process (hence carry the same umask).  So this is a little academic, but
      we should get it right anyway.
      
      Fixes: 47057abd (nfsd: add support for the umask attribute)
      Cc: stable@vger.kernel.org
      Reported-by: NLucash Stach <l.stach@pengutronix.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      880a3a53
    • C
      nfsd: Trace NFSv4 COMPOUND execution · fff4080b
      Chuck Lever 提交于
      This helps record the identity and timing of the ops in each NFSv4
      COMPOUND, replacing dprintk calls that did much the same thing.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      fff4080b
    • C
      nfsd: Add I/O trace points in the NFSv4 read proc · 87c5942e
      Chuck Lever 提交于
      NFSv4 read compound processing invokes nfsd_splice_read and
      nfs_readv directly, so the trace points currently in nfsd_read are
      not invoked for NFSv4 reads.
      
      Move the NFSD READ trace points to common helpers so that NFSv4
      reads are captured.
      
      Also, record any local I/O error that occurs, the total count of
      bytes that were actually returned, and whether splice or vectored
      read was used.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      87c5942e
    • C
      nfsd: Add I/O trace points in the NFSv4 write path · d890be15
      Chuck Lever 提交于
      NFSv4 write compound processing invokes nfsd_vfs_write directly. The
      trace points currently in nfsd_write are not effective for NFSv4
      writes.
      
      Move the trace points into the shared nfsd_vfs_write() helper.
      
      After the I/O, we also want to record any local I/O error that
      might have occurred, and the total count of bytes that were actually
      moved (rather than the requested number).
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      d890be15
    • C
      nfsd: Add "nfsd_" to trace point names · f394b62b
      Chuck Lever 提交于
      Follow naming convention used in client and in sunrpc layers.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      f394b62b
  3. 20 3月, 2018 1 次提交
  4. 09 2月, 2018 1 次提交
    • J
      nfsd: return RESOURCE not GARBAGE_ARGS on too many ops · 0078117c
      J. Bruce Fields 提交于
      A client that sends more than a hundred ops in a single compound
      currently gets an rpc-level GARBAGE_ARGS error.
      
      It would be more helpful to return NFS4ERR_RESOURCE, since that gives
      the client a better idea how to recover (for example by splitting up the
      compound into smaller compounds).
      
      This is all a bit academic since we've never actually seen a reason for
      clients to send such long compounds, but we may as well fix it.
      
      While we're there, just use NFSD4_MAX_OPS_PER_COMPOUND == 16, the
      constant we already use in the 4.1 case, instead of hard-coding 100.
      Chances anyone actually uses even 16 ops per compound are small enough
      that I think there's a neglible risk or any regression.
      
      This fixes pynfs test COMP6.
      Reported-by: N"Lu, Xinyu" <luxy.fnst@cn.fujitsu.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      0078117c
  5. 22 12月, 2017 1 次提交
  6. 08 11月, 2017 1 次提交
    • A
      nfds: avoid gettimeofday for nfssvc_boot time · 256a89fa
      Arnd Bergmann 提交于
      do_gettimeofday() is deprecated and we should generally use time64_t
      based functions instead.
      
      In case of nfsd, all three users of nfssvc_boot only use the initial
      time as a unique token, and are not affected by it overflowing, so they
      are not affected by the y2038 overflow.
      
      This converts the structure to timespec64 anyway and adds comments
      to all uses, to document that we have thought about it and avoid
      having to look at it again.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      256a89fa
  7. 06 10月, 2017 1 次提交
    • E
      nfsd4: define nfsd4_secinfo_no_name_release() · ec572b9e
      Eryu Guan 提交于
      Commit 34b1744c ("nfsd4: define ->op_release for compound ops")
      defined a couple ->op_release functions and run them if necessary.
      
      But there's a problem with that is that it reused
      nfsd4_secinfo_release() as the op_release of OP_SECINFO_NO_NAME, and
      caused a leak on struct nfsd4_secinfo_no_name in
      nfsd4_encode_secinfo_no_name(), because there's no .si_exp field in
      struct nfsd4_secinfo_no_name.
      
      I found this because I was unable to umount an ext4 partition after
      exporting it via NFS & run fsstress on the nfs mount. A simplified
      reproducer would be:
      
       # mount a local-fs device at /mnt/test, and export it via NFS with
       # fsid=0 export option (this is required)
       mount /dev/sda5 /mnt/test
       echo "/mnt/test *(rw,no_root_squash,fsid=0)" >> /etc/exports
       service nfs restart
      
       # locally mount the nfs export with all default, note that I have
       # nfsv4.1 configured as the default nfs version, because of the
       # fsid export option, v4 mount would fail and fall back to v3
       mount localhost:/mnt/test /mnt/nfs
      
       # try to umount the underlying device, but got EBUSY
       umount /mnt/nfs
       service nfs stop
       umount /mnt/test <=== EBUSY here
      
      Fixed it by defining a separate nfsd4_secinfo_no_name_release()
      function as the op_release method of OP_SECINFO_NO_NAME that
      releases the correct nfsd4_secinfo_no_name structure.
      
      Fixes: 34b1744c ("nfsd4: define ->op_release for compound ops")
      Signed-off-by: NEryu Guan <eguan@redhat.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      ec572b9e
  8. 05 10月, 2017 1 次提交
  9. 25 8月, 2017 3 次提交
  10. 02 8月, 2017 1 次提交
  11. 14 7月, 2017 12 次提交
  12. 24 5月, 2017 1 次提交
    • J
      nfsd4: fix null dereference on replay · 9a307403
      J. Bruce Fields 提交于
      if we receive a compound such that:
      
      	- the sessionid, slot, and sequence number in the SEQUENCE op
      	  match a cached succesful reply with N ops, and
      	- the Nth operation of the compound is a PUTFH, PUTPUBFH,
      	  PUTROOTFH, or RESTOREFH,
      
      then nfsd4_sequence will return 0 and set cstate->status to
      nfserr_replay_cache.  The current filehandle will not be set.  This will
      cause us to call check_nfsd_access with first argument NULL.
      
      To nfsd4_compound it looks like we just succesfully executed an
      operation that set a filehandle, but the current filehandle is not set.
      
      Fix this by moving the nfserr_replay_cache earlier.  There was never any
      reason to have it after the encode_op label, since the only case where
      he hit that is when opdesc->op_func sets it.
      
      Note that there are two ways we could hit this case:
      
      	- a client is resending a previously sent compound that ended
      	  with one of the four PUTFH-like operations, or
      	- a client is sending a *new* compound that (incorrectly) shares
      	  sessionid, slot, and sequence number with a previously sent
      	  compound, and the length of the previously sent compound
      	  happens to match the position of a PUTFH-like operation in the
      	  new compound.
      
      The second is obviously incorrect client behavior.  The first is also
      very strange--the only purpose of a PUTFH-like operation is to set the
      current filehandle to be used by the following operation, so there's no
      point in having it as the last in a compound.
      
      So it's likely this requires a buggy or malicious client to reproduce.
      Reported-by: NScott Mayhew <smayhew@redhat.com>
      Cc: stable@kernel.vger.org
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      9a307403
  13. 15 5月, 2017 10 次提交