1. 09 7月, 2013 1 次提交
  2. 04 7月, 2013 1 次提交
  3. 02 7月, 2013 9 次提交
    • N
      sunrpc: Don't schedule an upcall on a replaced cache entry. · 0bebc633
      NeilBrown 提交于
      When a cache entry is replaced, the "expiry_time" get set to
      zero by a call to "cache_fresh_locked(..., 0)" at the end of
      "sunrpc_cache_update".
      
      This low expiry time makes cache_check() think that the 'refresh_age'
      is negative, so the 'age' is comparatively large and a refresh is
      triggered.
      However refreshing a replaced entry it pointless, it cannot achieve
      anything useful.
      
      So teach cache_check to ignore a low refresh_age when expiry_time
      is zero.
      Reported-by: NBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      0bebc633
    • N
      net/sunrpc: xpt_auth_cache should be ignored when expired. · 7715cde8
      NeilBrown 提交于
      commit d202cce8
          sunrpc: never return expired entries in sunrpc_cache_lookup
      
      moved the 'entry is expired' test from cache_check to
      sunrpc_cache_lookup, so that it happened early and some races could
      safely be ignored.
      
      However the ip_map (in svcauth_unix.c) has a separate single-item
      cache which allows quick lookup without locking.  An entry in this
      case would not be subject to the expiry test and so could be used
      well after it has expired.
      
      This is not normally a big problem because the first time it is used
      after it is expired an up-call will be scheduled to refresh the entry
      (if it hasn't been scheduled already) and the old entry will then
      be invalidated.  So on the second attempt to use it after it has
      expired, ip_map_cached_get will discard it.
      
      However that is subtle and not ideal, so replace the "!cache_valid"
      test with "cache_is_expired".
      In doing this we drop the test on the "CACHE_VALID" bit.  This is
      unnecessary as the bit is never cleared, and an entry will only
      be cached if the bit is set.
      Reported-by: NBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      7715cde8
    • N
      sunrpc/cache: ensure items removed from cache do not have pending upcalls. · 013920eb
      NeilBrown 提交于
      It is possible for a race to set CACHE_PENDING after cache_clean()
      has removed a cache entry from the cache.
      If CACHE_PENDING is still set when the entry is finally 'put',
      the cache_dequeue() will never happen and we can leak memory.
      
      So set a new flag 'CACHE_CLEANED' when we remove something from
      the cache, and don't queue any upcall if it is set.
      
      If CACHE_PENDING is set before CACHE_CLEANED, the call that
      cache_clean() makes to cache_fresh_unlocked() will free memory
      as needed.  If CACHE_PENDING is set after CACHE_CLEANED, the
      test in sunrpc_cache_pipe_upcall will ensure that the memory
      is not allocated.
      
      Reported-by: <bstroesser@ts.fujitsu.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      013920eb
    • N
      sunrpc/cache: use cache_fresh_unlocked consistently and correctly. · 2a1c7f53
      NeilBrown 提交于
      cache_fresh_unlocked() is called when a cache entry
      has been updated and ensures that if there were any
      pending upcalls, they are cleared.
      
      So every time we update a cache entry, we should call this,
      and this should be the only way that we try to clear
      pending calls (that sort of uniformity makes code sooo much
      easier to read).
      
      try_to_negate_entry() will (possibly) mark an entry as
      negative.  If it doesn't, it is because the entry already
      is VALID.
      So the entry will be valid on exit, so it is appropriate to
      call cache_fresh_unlocked().
      So tidy up try_to_negate_entry() to do that, and remove
      partial open-coded cache_fresh_unlocked() from the one
      call-site of try_to_negate_entry().
      
      In the other branch of the 'switch(cache_make_upcall())',
      we again have a partial open-coded version of cache_fresh_unlocked().
      Replace that with a real call.
      
      And again in cache_clean(), use a real call to cache_fresh_unlocked().
      
      These call sites might previously have called
      cache_revisit_request() if CACHE_PENDING wasn't set.
      This is never necessary because cache_revisit_request() can
      only do anything if the item is in the cache_defer_hash,
      However any time that an item is added to the cache_defer_hash
      (setup_deferral), the code immediately tests CACHE_PENDING,
      and removes the entry again if it is clear.  So all other
      places we only need to 'cache_revisit_request' if we've
      just cleared CACHE_PENDING.
      Reported-by: NBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: NNeilBrown  <neilb@suse.de>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      2a1c7f53
    • N
      sunrpc/cache: remove races with queuing an upcall. · f9e1aedc
      NeilBrown 提交于
      We currently queue an upcall after setting CACHE_PENDING,
      and dequeue after clearing CACHE_PENDING.
      So a request should only be present when CACHE_PENDING is set.
      
      However we don't combine the test and the enqueue/dequeue in
      a protected region, so it is possible (if unlikely) for a race
      to result in a request being queued without CACHE_PENDING set,
      or a request to be absent despite CACHE_PENDING.
      
      So: include a test for CACHE_PENDING inside the regions of
      enqueue and dequeue where queue_lock is held, and abort
      the operation if the value is not as expected.
      
      Also remove the early 'return' from cache_dequeue() to ensure that it
      always removes all entries: As there is no locking between setting
      CACHE_PENDING and calling sunrpc_cache_pipe_upcall it is not
      inconceivable for some other thread to clear CACHE_PENDING and then
      someone else to set it and call sunrpc_cache_pipe_upcall, both before
      the original threads completed the call.
      
      With this, it perfectly safe and correct to:
       - call cache_dequeue() if and only if we have just
         cleared CACHE_PENDING
       - call sunrpc_cache_pipe_upcall() (via cache_make_upcall)
         if and only if we have just set CACHE_PENDING.
      Reported-by: NBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      f9e1aedc
    • J
      svcrpc: don't error out on small tcp fragment · 1f691b07
      J. Bruce Fields 提交于
      Though clients we care about mostly don't do this, it is possible for
      rpc requests to be sent in multiple fragments.  Here we have a sanity
      check to ensure that the final received rpc isn't too small--except that
      the number we're actually checking is the length of just the final
      fragment, not of the whole rpc.  So a perfectly legal rpc that's
      unluckily fragmented could cause the server to close the connection
      here.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      1f691b07
    • J
      svcrpc: fix handling of too-short rpc's · cf3aa02c
      J. Bruce Fields 提交于
      If we detect that an rpc is too short, we abort and close the
      connection.  Except, there's a bug here: we're leaving sk_datalen
      nonzero without leaving any pages in the sk_pages array.  The most
      likely result of the inconsistency is a subsequent crash in
      svc_tcp_clear_pages.
      
      Also demote the BUG_ON in svc_tcp_clear_pages to a WARN.
      
      Cc: stable@kernel.org
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      cf3aa02c
    • J
      svcrpc: store gss mech in svc_cred · 0dc1531a
      J. Bruce Fields 提交于
      Store a pointer to the gss mechanism used in the rq_cred and cl_cred.
      This will make it easier to enforce SP4_MACH_CRED, which needs to
      compare the mechanism used on the exchange_id with that used on
      protected operations.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      0dc1531a
    • J
      svcrpc: introduce init_svc_cred · 44234063
      J. Bruce Fields 提交于
      Common helper to zero out fields of the svc_cred.
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      44234063
  4. 29 6月, 2013 5 次提交
  5. 19 6月, 2013 1 次提交
    • J
      rpc_pipefs: only set rpc_dentry_ops if d_op isn't already set · e401452d
      Jeff Layton 提交于
      We had a report of a reproducible WARNING:
      
      [ 1360.039358] ------------[ cut here ]------------
      [ 1360.043978] WARNING: at fs/dcache.c:1355 d_set_d_op+0x8d/0xc0()
      [ 1360.049880] Hardware name: HP Z200 Workstation
      [ 1360.054308] Modules linked in: nfsv4 nfs dns_resolver fscache nfsd
      auth_rpcgss nfs_acl lockd sunrpc sg acpi_cpufreq mperf coretemp kvm_intel kvm
      snd_hda_codec_realtek snd_hda_intel snd_hda_codec hp_wmi crc32c_intel
      snd_hwdep e1000e snd_seq snd_seq_device snd_pcm snd_page_alloc snd_timer snd
      sparse_keymap rfkill soundcore serio_raw ptp iTCO_wdt pps_core pcspkr
      iTCO_vendor_support mei microcode lpc_ich mfd_core wmi xfs libcrc32c sr_mod
      sd_mod cdrom crc_t10dif radeon i2c_algo_bit drm_kms_helper ttm ahci libahci
      drm i2c_core libata dm_mirror dm_region_hash dm_log dm_mod [last unloaded:
      auth_rpcgss]
      [ 1360.107406] Pid: 8814, comm: mount.nfs4 Tainted: G         I --------------   3.9.0-0.55.el7.x86_64 #1
      [ 1360.116771] Call Trace:
      [ 1360.119219]  [<ffffffff810610c0>] warn_slowpath_common+0x70/0xa0
      [ 1360.125208]  [<ffffffff810611aa>] warn_slowpath_null+0x1a/0x20
      [ 1360.131025]  [<ffffffff811af46d>] d_set_d_op+0x8d/0xc0
      [ 1360.136159]  [<ffffffffa05a7d6f>] __rpc_lookup_create_exclusive+0x4f/0x80 [sunrpc]
      [ 1360.143710]  [<ffffffffa05a8cc6>] rpc_mkpipe_dentry+0x86/0x170 [sunrpc]
      [ 1360.150311]  [<ffffffffa062a7b6>] nfs_idmap_new+0x96/0x130 [nfsv4]
      [ 1360.156475]  [<ffffffffa062e7cd>] nfs4_init_client+0xad/0x2d0 [nfsv4]
      [ 1360.162902]  [<ffffffff812f02df>] ? idr_get_empty_slot+0x16f/0x3c0
      [ 1360.169062]  [<ffffffff812f0582>] ? idr_mark_full+0x52/0x60
      [ 1360.174615]  [<ffffffff812f0699>] ? idr_alloc+0x79/0xe0
      [ 1360.179826]  [<ffffffffa0598081>] ? __rpc_init_priority_wait_queue+0x81/0xc0 [sunrpc]
      [ 1360.187635]  [<ffffffffa05980f3>] ? rpc_init_wait_queue+0x13/0x20 [sunrpc]
      [ 1360.194493]  [<ffffffffa05d05da>] nfs_get_client+0x27a/0x350 [nfs]
      [ 1360.200666]  [<ffffffffa062e438>] nfs4_set_client.isra.8+0x78/0x100 [nfsv4]
      [ 1360.207624]  [<ffffffffa062f2f3>] nfs4_create_server+0xf3/0x3a0 [nfsv4]
      [ 1360.214222]  [<ffffffffa06284be>] nfs4_remote_mount+0x2e/0x60 [nfsv4]
      [ 1360.220644]  [<ffffffff8119ea79>] mount_fs+0x39/0x1b0
      [ 1360.225691]  [<ffffffff81153880>] ? __alloc_percpu+0x10/0x20
      [ 1360.231348]  [<ffffffff811b7ccf>] vfs_kern_mount+0x5f/0xf0
      [ 1360.236822]  [<ffffffffa0628396>] nfs_do_root_mount+0x86/0xc0 [nfsv4]
      [ 1360.243246]  [<ffffffffa06287b4>] nfs4_try_mount+0x44/0xc0 [nfsv4]
      [ 1360.249410]  [<ffffffffa05d1457>] ? get_nfs_version+0x27/0x80 [nfs]
      [ 1360.255659]  [<ffffffffa05db985>] nfs_fs_mount+0x5c5/0xd10 [nfs]
      [ 1360.261650]  [<ffffffffa05dc550>] ? nfs_clone_super+0x140/0x140 [nfs]
      [ 1360.268074]  [<ffffffffa05da8e0>] ? param_set_portnr+0x60/0x60 [nfs]
      [ 1360.274406]  [<ffffffff8119ea79>] mount_fs+0x39/0x1b0
      [ 1360.279443]  [<ffffffff81153880>] ? __alloc_percpu+0x10/0x20
      [ 1360.285088]  [<ffffffff811b7ccf>] vfs_kern_mount+0x5f/0xf0
      [ 1360.290556]  [<ffffffff811b9f5d>] do_mount+0x1fd/0xa00
      [ 1360.295677]  [<ffffffff81137dee>] ? __get_free_pages+0xe/0x50
      [ 1360.301405]  [<ffffffff811b9be6>] ? copy_mount_options+0x36/0x170
      [ 1360.307479]  [<ffffffff811ba7e3>] sys_mount+0x83/0xc0
      [ 1360.312515]  [<ffffffff8160ad59>] system_call_fastpath+0x16/0x1b
      [ 1360.318503] ---[ end trace 8fa1f4cbc36094a7 ]---
      
      The problem is that we're ending up in __rpc_lookup_create_exclusive
      with a negative dentry that already has d_op set. A little debugging
      has shown that when we hit this, the d_ops are already set to
      simple_dentry_operations.
      
      I believe that what's happening is that during a mount, idmapd is racing
      in and doing a lookup of /var/lib/nfs/rpc_pipefs/nfs/clnt???/idmap.
      Before that dentry reference is released, the kernel races in to create
      that file and finds the new negative dentry, which already has the
      d_op set.
      
      This patch just avoids setting the d_op if it's already set.
      simple_dentry_operations and rpc_dentry_operations are functionally
      equivalent so it shouldn't matter which one it's set to.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      e401452d
  6. 13 6月, 2013 1 次提交
  7. 07 6月, 2013 3 次提交
  8. 29 5月, 2013 2 次提交
  9. 23 5月, 2013 1 次提交
    • T
      SUNRPC: Prevent an rpc_task wakeup race · a3c3cac5
      Trond Myklebust 提交于
      The lockless RPC_IS_QUEUED() test in __rpc_execute means that we need to
      be careful about ordering the calls to rpc_test_and_set_running(task) and
      rpc_clear_queued(task). If we get the order wrong, then we may end up
      testing the RPC_TASK_RUNNING flag after __rpc_execute() has looped
      and changed the state of the rpc_task.
      Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Cc: stable@vger.kernel.org
      a3c3cac5
  10. 21 5月, 2013 1 次提交
  11. 16 5月, 2013 3 次提交
  12. 15 5月, 2013 1 次提交
  13. 13 5月, 2013 1 次提交
  14. 12 5月, 2013 1 次提交
    • C
      freezer: add unsafe versions of freezable helpers for NFS · 416ad3c9
      Colin Cross 提交于
      NFS calls the freezable helpers with locks held, which is unsafe
      and will cause lockdep warnings when 6aa97070 "lockdep: check
      that no locks held at freeze time" is reapplied (it was reverted
      in dbf520a9).  NFS shouldn't be doing this, but it has
      long-running syscalls that must hold a lock but also shouldn't
      block suspend.  Until NFS freeze handling is rewritten to use a
      signal to exit out of the critical section, add new *_unsafe
      versions of the helpers that will not run the lockdep test when
      6aa97070 is reapplied, and call them from NFS.
      
      In practice the likley result of holding the lock while freezing
      is that a second task blocked on the lock will never freeze,
      aborting suspend, but it is possible to manufacture a case using
      the cgroup freezer, the lock, and the suspend freezer to create
      a deadlock.  Silencing the lockdep warning here will allow
      problems to be found in other drivers that may have a more
      serious deadlock risk, and prevent new problems from being added.
      Signed-off-by: NColin Cross <ccross@android.com>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      416ad3c9
  15. 08 5月, 2013 1 次提交
  16. 06 5月, 2013 1 次提交
  17. 04 5月, 2013 1 次提交
  18. 01 5月, 2013 1 次提交
  19. 30 4月, 2013 5 次提交