1. 08 11月, 2017 5 次提交
    • E
      fs, nfsd: convert nfs4_file.fi_ref from atomic_t to refcount_t · 818a34eb
      Elena Reshetova 提交于
      atomic_t variables are currently used to implement reference
      counters with the following properties:
       - counter is initialized to 1 using atomic_set()
       - a resource is freed upon counter reaching zero
       - once counter reaches zero, its further
         increments aren't allowed
       - counter schema uses basic atomic operations
         (set, inc, inc_not_zero, dec_and_test, etc.)
      
      Such atomic variables should be converted to a newly provided
      refcount_t type and API that prevents accidental counter overflows
      and underflows. This is important since overflows and underflows
      can lead to use-after-free situation and be exploitable.
      
      The variable nfs4_file.fi_ref is used as pure reference counter.
      Convert it to refcount_t and fix up the operations.
      Suggested-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NDavid Windsor <dwindsor@gmail.com>
      Reviewed-by: NHans Liljestrand <ishkamiel@gmail.com>
      Signed-off-by: NElena Reshetova <elena.reshetova@intel.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      818a34eb
    • E
      fs, nfsd: convert nfs4_cntl_odstate.co_odcount from atomic_t to refcount_t · cff7cb2e
      Elena Reshetova 提交于
      atomic_t variables are currently used to implement reference
      counters with the following properties:
       - counter is initialized to 1 using atomic_set()
       - a resource is freed upon counter reaching zero
       - once counter reaches zero, its further
         increments aren't allowed
       - counter schema uses basic atomic operations
         (set, inc, inc_not_zero, dec_and_test, etc.)
      
      Such atomic variables should be converted to a newly provided
      refcount_t type and API that prevents accidental counter overflows
      and underflows. This is important since overflows and underflows
      can lead to use-after-free situation and be exploitable.
      
      The variable nfs4_cntl_odstate.co_odcount is used as pure reference counter.
      Convert it to refcount_t and fix up the operations.
      Suggested-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NDavid Windsor <dwindsor@gmail.com>
      Reviewed-by: NHans Liljestrand <ishkamiel@gmail.com>
      Signed-off-by: NElena Reshetova <elena.reshetova@intel.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      cff7cb2e
    • E
      fs, nfsd: convert nfs4_stid.sc_count from atomic_t to refcount_t · a15dfcd5
      Elena Reshetova 提交于
      atomic_t variables are currently used to implement reference
      counters with the following properties:
       - counter is initialized to 1 using atomic_set()
       - a resource is freed upon counter reaching zero
       - once counter reaches zero, its further
         increments aren't allowed
       - counter schema uses basic atomic operations
         (set, inc, inc_not_zero, dec_and_test, etc.)
      
      Such atomic variables should be converted to a newly provided
      refcount_t type and API that prevents accidental counter overflows
      and underflows. This is important since overflows and underflows
      can lead to use-after-free situation and be exploitable.
      
      The variable nfs4_stid.sc_count is used as pure reference counter.
      Convert it to refcount_t and fix up the operations.
      Suggested-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NDavid Windsor <dwindsor@gmail.com>
      Reviewed-by: NHans Liljestrand <ishkamiel@gmail.com>
      Signed-off-by: NElena Reshetova <elena.reshetova@intel.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      a15dfcd5
    • J
      nfsd4: catch some false session retries · 53da6a53
      J. Bruce Fields 提交于
      The spec allows us to return NFS4ERR_SEQ_FALSE_RETRY if we notice that
      the client is making a call that matches a previous (slot, seqid) pair
      but that *isn't* actually a replay, because some detail of the call
      doesn't actually match the previous one.
      
      Catching every such case is difficult, but we may as well catch a few
      easy ones.  This also handles the case described in the previous patch,
      in a different way.
      
      The spec does however require us to catch the case where the difference
      is in the rpc credentials.  This prevents somebody from snooping another
      user's replies by fabricating retries.
      
      (But the practical value of the attack is limited by the fact that the
      replies with the most sensitive data are READ replies, which are not
      normally cached.)
      Tested-by: NOlga Kornievskaia <aglo@umich.edu>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      53da6a53
    • J
      nfsd4: fix cached replies to solo SEQUENCE compounds · 085def3a
      J. Bruce Fields 提交于
      Currently our handling of 4.1+ requests without "cachethis" set is
      confusing and not quite correct.
      
      Suppose a client sends a compound consisting of only a single SEQUENCE
      op, and it matches the seqid in a session slot (so it's a retry), but
      the previous request with that seqid did not have "cachethis" set.
      
      The obvious thing to do might be to return NFS4ERR_RETRY_UNCACHED_REP,
      but the protocol only allows that to be returned on the op following the
      SEQUENCE, and there is no such op in this case.
      
      The protocol permits us to cache replies even if the client didn't ask
      us to.  And it's easy to do so in the case of solo SEQUENCE compounds.
      
      So, when we get a solo SEQUENCE, we can either return the previously
      cached reply or NFSERR_SEQ_FALSE_RETRY if we notice it differs in some
      way from the original call.
      
      Currently, we're returning a corrupt reply in the case a solo SEQUENCE
      matches a previous compound with more ops.  This actually matters
      because the Linux client recently started doing this as a way to recover
      from lost replies to idempotent operations in the case the process doing
      the original reply was killed: in that case it's difficult to keep the
      original arguments around to do a real retry, and the client no longer
      cares what the result is anyway, but it would like to make sure that the
      slot's sequence id has been incremented, and the solo SEQUENCE assures
      that: if the server never got the original reply, it will increment the
      sequence id.  If it did get the original reply, it won't increment, and
      nothing else that about the reply really matters much.  But we can at
      least attempt to return valid xdr!
      Tested-by: NOlga Kornievskaia <aglo@umich.edu>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      085def3a
  2. 06 10月, 2017 1 次提交
  3. 05 10月, 2017 3 次提交
  4. 06 9月, 2017 1 次提交
    • C
      nfsd: Incoming xdr_bufs may have content in tail buffer · eae03e2a
      Chuck Lever 提交于
      Since the beginning, svcsock has built a received RPC Call message
      by populating the xdr_buf's head, then placing the remaining
      message bytes in the xdr_buf's page list. The xdr_buf's tail is
      never populated.
      
      This means that an NFSv4 COMPOUND containing an NFS WRITE operation
      plus trailing operations has a page list that contains the WRITE
      data payload followed by the trailing operations. NFSv4 XDR decoders
      will not look in the xdr_buf's tail, ever, because svcsock never put
      anything there.
      
      To support transports that can pass the write payload in the
      xdr_buf's pagelist and trailing content in the xdr_buf's tail,
      introduce logic in READ_BUF that switches to the xdr_buf's tail vec
      when the decoder runs out of content in rq_arg.pages.
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      eae03e2a
  5. 01 9月, 2017 1 次提交
  6. 25 8月, 2017 7 次提交
  7. 02 8月, 2017 1 次提交
  8. 18 7月, 2017 1 次提交
  9. 14 7月, 2017 19 次提交
  10. 13 7月, 2017 1 次提交
    • J
      nfsd4: factor ctime into change attribute · 630458e7
      J. Bruce Fields 提交于
      Factoring ctime into the nfsv4 change attribute gives us better
      properties than just i_version alone.
      
      Eventually we'll likely also expose this (as opposed to raw i_version)
      to userspace, at which point we'll want to move it to a common helper,
      called from either userspace or individual filesystems.  For now, nfsd
      is the only user.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      630458e7