1. 02 3月, 2016 1 次提交
    • J
      nfsd4: fix bad bounds checking · 4aed9c46
      J. Bruce Fields 提交于
      A number of spots in the xdr decoding follow a pattern like
      
      	n = be32_to_cpup(p++);
      	READ_BUF(n + 4);
      
      where n is a u32.  The only bounds checking is done in READ_BUF itself,
      but since it's checking (n + 4), it won't catch cases where n is very
      large, (u32)(-4) or higher.  I'm not sure exactly what the consequences
      are, but we've seen crashes soon after.
      
      Instead, just break these up into two READ_BUF()s.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      4aed9c46
  2. 23 1月, 2016 1 次提交
    • A
      wrappers for ->i_mutex access · 5955102c
      Al Viro 提交于
      parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
      inode_foo(inode) being mutex_foo(&inode->i_mutex).
      
      Please, use those for access to ->i_mutex; over the coming cycle
      ->i_mutex will become rwsem, with ->lookup() done with it held
      only shared.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      5955102c
  3. 15 1月, 2016 1 次提交
  4. 09 1月, 2016 2 次提交
    • N
      nfsd: don't hold i_mutex over userspace upcalls · bbddca8e
      NeilBrown 提交于
      We need information about exports when crossing mountpoints during
      lookup or NFSv4 readdir.  If we don't already have that information
      cached, we may have to ask (and wait for) rpc.mountd.
      
      In both cases we currently hold the i_mutex on the parent of the
      directory we're asking rpc.mountd about.  We've seen situations where
      rpc.mountd performs some operation on that directory that tries to take
      the i_mutex again, resulting in deadlock.
      
      With some care, we may be able to avoid that in rpc.mountd.  But it
      seems better just to avoid holding a mutex while waiting on userspace.
      
      It appears that lookup_one_len is pretty much the only operation that
      needs the i_mutex.  So we could just drop the i_mutex elsewhere and do
      something like
      
      	mutex_lock()
      	lookup_one_len()
      	mutex_unlock()
      
      In many cases though the lookup would have been cached and not required
      the i_mutex, so it's more efficient to create a lookup_one_len() variant
      that only takes the i_mutex when necessary.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      bbddca8e
    • J
      nfsd: give up on CB_LAYOUTRECALLs after two lease periods · 6b9b2107
      Jeff Layton 提交于
      Have the CB_LAYOUTRECALL code treat NFS4_OK and NFS4ERR_DELAY returns
      equivalently. Change the code to periodically resend CB_LAYOUTRECALLS
      until the ls_layouts list is empty or the client returns a different
      error code.
      
      If we go for two lease periods without the list being emptied or the
      client sending a hard error, then we give up and clean out the list
      anyway.
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      Tested-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      6b9b2107
  5. 07 1月, 2016 3 次提交
  6. 23 12月, 2015 2 次提交
    • S
      nfsd: Register callbacks on the inetaddr_chain and inet6addr_chain · 36684996
      Scott Mayhew 提交于
      Register callbacks on inetaddr_chain and inet6addr_chain to trigger
      cleanup of nfsd transport sockets when an ip address is deleted.
      Signed-off-by: NScott Mayhew <smayhew@redhat.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      36684996
    • J
      nfsd: don't base cl_cb_status on stale information · d4f72cb7
      J. Bruce Fields 提交于
      The rpc client we use to send callbacks may change occasionally.  (In
      the 4.0 case, the client can use setclientid/setclientid_confirm to
      update the callback parameters.  In the 4.1+ case, sessions and
      connections can come and go.)
      
      The update is done from the callback thread by nfsd4_process_cb_update,
      which shuts down the old rpc client and then creates a new one.
      
      The client shutdown kills any ongoing rpc calls.  There won't be any new
      ones till the new one's created and the callback thread moves on.
      
      When an rpc encounters a problem that may suggest callback rpc's
      aren't working any longer, it normally sets NFSD4_CB_DOWN, so the server
      can tell the client something's wrong.
      
      But if the rpc notices CB_UPDATE is set, then the failure may just be a
      normal result of shutting down the callback client.  Or it could just be
      a coincidence, but in any case, it means we're runing with the old
      about-to-be-discarded client, so the failure's not interesting.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      d4f72cb7
  7. 17 12月, 2015 1 次提交
  8. 08 12月, 2015 2 次提交
  9. 25 11月, 2015 4 次提交
    • J
      nfsd4: fix gss-proxy 4.1 mounts for some AD principals · 414ca017
      J. Bruce Fields 提交于
      The principal name on a gss cred is used to setup the NFSv4.0 callback,
      which has to have a client principal name to authenticate to.
      
      That code wants the name to be in the form servicetype@hostname.
      rpc.svcgssd passes down such names (and passes down no principal name at
      all in the case the principal isn't a service principal).
      
      gss-proxy always passes down the principal name, and passes it down in
      the form servicetype/hostname@REALM.  So we've been munging the name
      gss-proxy passes down into the format the NFSv4.0 callback code expects,
      or throwing away the name if we can't.
      
      Since the introduction of the MACH_CRED enforcement in NFSv4.1, we've
      also been using the principal name to verify that certain operations are
      done as the same principal as was used on the original EXCHANGE_ID call.
      
      For that application, the original name passed down by gss-proxy is also
      useful.
      
      Lack of that name in some cases was causing some kerberized NFSv4.1
      mount failures in an Active Directory environment.
      
      This fix only works in the gss-proxy case.  The fix for legacy
      rpc.svcgssd would be more involved, and rpc.svcgssd already has other
      problems in the AD case.
      Reported-and-tested-by: NJames Ralston <ralston@pobox.com>
      Acked-by: NSimo Sorce <simo@redhat.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      414ca017
    • J
      nfsd: fix unlikely NULL deref in mach_creds_match · 920dd9bb
      J. Bruce Fields 提交于
      We really shouldn't allow a client to be created with cl_mach_cred set
      unless it also has a principal name.
      
      This also allows us to fail such cases immediately on EXCHANGE_ID as
      opposed to waiting and incorrectly returning WRONG_CRED on the following
      CREATE_SESSION.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      920dd9bb
    • J
      nfsd: minor consolidation of mach_cred handling code · 50c7b948
      J. Bruce Fields 提交于
      Minor cleanup, no change in functionality.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      50c7b948
    • J
      nfsd: helper for dup of possibly NULL string · 50043859
      J. Bruce Fields 提交于
      Technically the initialization in the NULL case isn't even needed as the
      only caller already has target zeroed out, but it seems safer to keep
      copy_cred generic.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      50043859
  10. 24 11月, 2015 3 次提交
  11. 10 11月, 2015 3 次提交
    • A
      nfsd: fix race with open / open upgrade stateids · 7fc0564e
      Andrew Elble 提交于
      We observed multiple open stateids on the server for files that
      seemingly should have been closed.
      
      nfsd4_process_open2() tests for the existence of a preexisting
      stateid. If one is not found, the locks are dropped and a new
      one is created. The problem is that init_open_stateid(), which
      is also responsible for hashing the newly initialized stateid,
      doesn't check to see if another open has raced in and created
      a matching stateid. This fix is to enable init_open_stateid() to
      return the matching stateid and have nfsd4_process_open2()
      swap to that stateid and switch to the open upgrade path.
      In testing this patch, coverage to the newly created
      path indicates that the race was indeed happening.
      Signed-off-by: NAndrew Elble <aweits@rit.edu>
      Reviewed-by: NJeff Layton <jlayton@poochiereds.net>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      7fc0564e
    • A
      nfsd: eliminate sending duplicate and repeated delegations · 34ed9872
      Andrew Elble 提交于
      We've observed the nfsd server in a state where there are
      multiple delegations on the same nfs4_file for the same client.
      The nfs client does attempt to DELEGRETURN these when they are presented to
      it - but apparently under some (unknown) circumstances the client does not
      manage to return all of them. This leads to the eventual
      attempt to CB_RECALL more than one delegation with the same nfs
      filehandle to the same client. The first recall will succeed, but the
      next recall will fail with NFS4ERR_BADHANDLE. This leads to the server
      having delegations on cl_revoked that the client has no way to FREE
      or DELEGRETURN, with resulting inability to recover. The state manager
      on the server will continually assert SEQ4_STATUS_RECALLABLE_STATE_REVOKED,
      and the state manager on the client will be looping unable to satisfy
      the server.
      
      List discussion also reports a race between OPEN and DELEGRETURN that
      will be avoided by only sending the delegation once to the
      client. This is also logically in accordance with RFC5561 9.1.1 and 10.2.
      
      So, let's:
      
      1.) Not hand out duplicate delegations.
      2.) Only send them to the client once.
      
      RFC 5561:
      
      9.1.1:
      "Delegations and layouts, on the other hand, are not associated with a
      specific owner but are associated with the client as a whole
      (identified by a client ID)."
      
      10.2:
      "...the stateid for a delegation is associated with a client ID and may be
      used on behalf of all the open-owners for the given client.  A
      delegation is made to the client as a whole and not to any specific
      process or thread of control within it."
      Reported-by: NEric Meddaugh <etmsys@rit.edu>
      Cc: Trond Myklebust <trond.myklebust@primarydata.com>
      Cc: Olga Kornievskaia <aglo@umich.edu>
      Signed-off-by: NAndrew Elble <aweits@rit.edu>
      Cc: stable@vger.kernel.org
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      34ed9872
    • J
      nfsd: remove recurring workqueue job to clean DRC · 3e80dbcd
      Jeff Layton 提交于
      We have a shrinker, we clean out the cache when nfsd is shut down, and
      prune the chains on each request. A recurring workqueue job seems like
      unnecessary overhead. Just remove it.
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      3e80dbcd
  12. 24 10月, 2015 5 次提交
    • J
      nfsd: ensure that seqid morphing operations are atomic wrt to copies · 9767feb2
      Jeff Layton 提交于
      Bruce points out that the increment of the seqid in stateids is not
      serialized in any way, so it's possible for racing calls to bump it
      twice and end up sending the same stateid. While we don't have any
      reports of this problem it _is_ theoretically possible, and could lead
      to spurious state recovery by the client.
      
      In the current code, update_stateid is always followed by a memcpy of
      that stateid, so we can combine the two operations. For better
      atomicity, we add a spinlock to the nfs4_stid and hold that when bumping
      the seqid and copying the stateid.
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      9767feb2
    • J
      nfsd: serialize layout stateid morphing operations · cc8a5532
      Jeff Layton 提交于
      In order to allow the client to make a sane determination of what
      happened with racing LAYOUTGET/LAYOUTRETURN/CB_LAYOUTRECALL calls, we
      must ensure that the seqids return accurately represent the order of
      operations. The simplest way to do that is to ensure that operations on
      a single stateid are serialized.
      
      This patch adds a mutex to the layout stateid, and locks it when
      checking the layout stateid's seqid. The mutex is held over the entire
      operation and released after the seqid is bumped.
      
      Note that in the case of CB_LAYOUTRECALL we must move the increment of
      the seqid and setting into a new cb "prepare" operation. The lease
      infrastructure will call the lm_break callback with a spinlock held, so
      and we can't take the mutex in that codepath.
      
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      cc8a5532
    • J
      nfsd: improve client_has_state to check for unused openowners · 4eaea134
      J. Bruce Fields 提交于
      At least in the v4.0 case openowners can hang around for a while after
      last close, but they shouldn't really block (for example), a new mount
      with a different principal.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      4eaea134
    • J
      nfsd: fix clid_inuse on mount with security change · 2b634821
      J. Bruce Fields 提交于
      In bakeathon testing Solaris client was getting CLID_INUSE error when
      doing a krb5 mount soon after an auth_sys mount, or vice versa.
      
      That's not really necessary since in this case the old client doesn't
      have any state any more:
      
      	http://tools.ietf.org/html/rfc7530#page-103
      
      	"when the server gets a SETCLIENTID for a client ID that
      	currently has no state, or it has state but the lease has
      	expired, rather than returning NFS4ERR_CLID_INUSE, the server
      	MUST allow the SETCLIENTID and confirm the new client ID if
      	followed by the appropriate SETCLIENTID_CONFIRM."
      
      This doesn't fix the problem completely since our client_has_state()
      check counts openowners left around to handle close replays, which we
      should probably just remove in this case.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      2b634821
    • J
      nfsd: move include of state.h from trace.c to trace.h · 825213e5
      Jeff Layton 提交于
      Any file which includes trace.h will need to include state.h, even if
      they aren't using any state tracepoints. Ensure that we include any
      headers that might be needed in trace.h instead of relying on the
      *.c files to have the right ones.
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      825213e5
  13. 13 10月, 2015 4 次提交
  14. 10 10月, 2015 1 次提交
  15. 02 9月, 2015 2 次提交
  16. 01 9月, 2015 5 次提交