1. 06 9月, 2018 1 次提交
    • A
      IB/ipoib: Avoid a race condition between start_xmit and cm_rep_handler · 816e846c
      Aaron Knister 提交于
      Inside of start_xmit() the call to check if the connection is up and the
      queueing of the packets for later transmission is not atomic which leaves
      a window where cm_rep_handler can run, set the connection up, dequeue
      pending packets and leave the subsequently queued packets by start_xmit()
      sitting on neigh->queue until they're dropped when the connection is torn
      down. This only applies to connected mode. These dropped packets can
      really upset TCP, for example, and cause multi-minute delays in
      transmission for open connections.
      
      Here's the code in start_xmit where we check to see if the connection is
      up:
      
             if (ipoib_cm_get(neigh)) {
                     if (ipoib_cm_up(neigh)) {
                             ipoib_cm_send(dev, skb, ipoib_cm_get(neigh));
                             goto unref;
                     }
             }
      
      The race occurs if cm_rep_handler execution occurs after the above
      connection check (specifically if it gets to the point where it acquires
      priv->lock to dequeue pending skb's) but before the below code snippet in
      start_xmit where packets are queued.
      
             if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
                     push_pseudo_header(skb, phdr->hwaddr);
                     spin_lock_irqsave(&priv->lock, flags);
                     __skb_queue_tail(&neigh->queue, skb);
                     spin_unlock_irqrestore(&priv->lock, flags);
             } else {
                     ++dev->stats.tx_dropped;
                     dev_kfree_skb_any(skb);
             }
      
      The patch acquires the netif tx lock in cm_rep_handler for the section
      where it sets the connection up and dequeues and retransmits deferred
      skb's.
      
      Fixes: 839fcaba ("IPoIB: Connected mode experimental support")
      Cc: stable@vger.kernel.org
      Signed-off-by: NAaron Knister <aaron.s.knister@nasa.gov>
      Tested-by: NIra Weiny <ira.weiny@intel.com>
      Reviewed-by: NIra Weiny <ira.weiny@intel.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      816e846c
  2. 03 8月, 2018 11 次提交
    • J
      IB/ipoib: Consolidate checking of the proposed child interface · 76010976
      Jason Gunthorpe 提交于
      Move all the checking for pkey and other validity to the __ipoib_vlan_add
      function. This removes the last difference from the control flow
      of the __ipoib_vlan_add to make the overall design simpler to
      understand.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NErez Shitrit <erezsh@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      76010976
    • J
      IB/ipoib: Maintain the child_intfs list from ndo_init/uninit · 13476d35
      Jason Gunthorpe 提交于
      This fixes a bug in the netlink path where the vlan_rwsem was not
      held around __ipoib_vlan_add causing the child_intfs to be manipulated
      unsafely.
      
      In the process this greatly simplifies the vlan_rwsem write side locking
      to only cover a single non-sleeping statement.
      
      This also further increases the safety of the removal ordering by holding
      the netdev of the parent while the child is active to ensure most bugs
      become either an oops on a NULL priv or a deadlock on the netdev refcount.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      13476d35
    • J
      IB/ipoib: Do not remove child devices from within the ndo_uninit · 25405d98
      Jason Gunthorpe 提交于
      Switching to priv_destructor and needs_free_netdev created a subtle
      ordering problem in ipoib_remove_one.
      
      Now that unregister_netdev frees the netdev and priv we must ensure that
      the children are unregistered before trying to unregister the parent,
      or child unregister will use after free.
      
      The solution is to unregister the children, then parent, in the same batch
      all while holding the rtnl_lock. This closes all the races where a new
      child could have been added and ensures proper ordering.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      25405d98
    • J
      IB/ipoib: Get rid of the sysfs_mutex · ee190ab7
      Jason Gunthorpe 提交于
      This mutex was introduced to deal with the deadlock formed by calling
      unregister_netdev from within the sysfs callback of a netdev.
      
      Now that we have priv_destructor and needs_free_netdev we can switch
      to the more targeted solution of running the unregister from a
      work queue. This avoids the deadlock and gets rid of the mutex.
      
      The next patch in the series needs this mutex eliminated to create
      atomicity of unregisteration.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      ee190ab7
    • J
      RDMA/netdev: Use priv_destructor for netdev cleanup · 9f49a5b5
      Jason Gunthorpe 提交于
      Now that the unregister_netdev flow for IPoIB no longer relies on external
      code we can now introduce the use of priv_destructor and
      needs_free_netdev.
      
      The rdma_netdev flow is switched to use the netdev common priv_destructor
      instead of the special free_rdma_netdev and the IPOIB ULP adjusted:
       - priv_destructor needs to switch to point to the ULP's destructor
         which will then call the rdma_ndev's in the right order
       - We need to be careful around the error unwind of register_netdev
         as it sometimes calls priv_destructor on failure
       - ULPs need to use ndo_init/uninit to ensure proper ordering
         of failures around register_netdev
      
      Switching to priv_destructor is a necessary pre-requisite to using
      the rtnl new_link mechanism.
      
      The VNIC user for rdma_netdev should also be revised, but that is left for
      another patch.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NDenis Drozdov <denisd@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      9f49a5b5
    • J
      IB/ipoib: Move init code to ndo_init · eaeb3984
      Jason Gunthorpe 提交于
      Now that we have a proper ndo_uninit, move code that naturally pairs
      with the ndo_uninit into ndo_init. This allows the netdev core to natually
      handle ordering.
      
      This fixes the situation where register_netdev can fail before calling
      ndo_init, in which case it wouldn't call ndo_uninit either.
      
      Also move a bunch of duplicated init code that is shared between child
      and parent for clarity. Now the child and parent register functions look
      very similar.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      eaeb3984
    • J
      IB/ipoib: Move all uninit code into ndo_uninit · 7cbee87c
      Jason Gunthorpe 提交于
      Currently uninit is sometimes done twice in error flows, and is sprinkled
      a bit all over the place.
      
      Improve the clarity of the design by moving all uninit only into
      ndo_uinit.
      
      Some duplication is removed:
       - Sometimes IPOIB_STOP_NEIGH_GC was done before unregister, but
         this duplicates the process in ipoib_neigh_hash_init
       - Flushing priv->wq was sometimes done before unregister,
         but that duplicates what has been done in ndo_uninit
      
      Uniniting the IB event queue must remain before unregister_netdev as it
      requires the RTNL lock to be dropped, this is moved to a helper to make
      that flow really clear and remove some duplication in error flows.
      
      If register_netdev fails (and ndo_init is NULL) then it almost always
      calls ndo_uninit, which lets us remove all the extra code from the error
      unwinds. The next patch in the series will close the 'almost always' hole
      by pairing a proper ndo_init with ndo_uninit.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      7cbee87c
    • E
      IB/ipoib: Use cancel_delayed_work_sync for neigh-clean task · cda8daf1
      Erez Shitrit 提交于
      The neigh_reap_task is self restarting, but so long as we call
      cancel_delayed_work_sync() it will be guaranteed to not be running and
      never start again. Thus we don't need to have the racy
      IPOIB_STOP_NEIGH_GC bit, or the confusing mismatch of places sometimes
      calling flush_workqueue after the cancel.
      
      This fixes a situation where the GC work could have been left running
      in some rare situations.
      Signed-off-by: NErez Shitrit <erezsh@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      cda8daf1
    • J
      IB/ipoib: Get rid of IPOIB_FLAG_GOING_DOWN · 577e07ff
      Jason Gunthorpe 提交于
      This essentially duplicates the netdev's reg_state, so just use that
      directly. The reg_state is updated under the rntl_lock, and all places
      using GOING_DOWN already acquire the rtnl_lock so checking is safe.
      
      Since the only place we use GOING_DOWN is for the parent device this
      does not fix any bugs, but it is a step to tidy up the unregister flow
      so that after later patches the flow is uniform and sane.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      577e07ff
    • M
      scsi: target: srp, vscsi, sbp, qla: use target_remove_session · b287e351
      Mike Christie 提交于
      This converts the drivers that called transport_deregister_session_configfs
      and then immediately called transport_deregister_session to use
      target_remove_session.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Reviewed-by: NBart Van Assche <bart.vanassche@wdc.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Chris Boot <bootc@bootc.net>
      Cc: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
      Cc: Michael Cyr <mikecyr@linux.vnet.ibm.com>
      Cc: <qla2xxx-upstream@qlogic.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      b287e351
    • M
      scsi: target: rename target_alloc_session · fa834287
      Mike Christie 提交于
      Rename target_alloc_session to target_setup_session to avoid confusion with
      the other transport session allocation function that only allocates the
      session and because the target_alloc_session does so much more. It
      allocates the session, sets up the nacl and registers the session.
      
      The next patch will then add a remove function to match the setup in this
      one, so it should make sense for all drivers, except iscsi, to just call
      those 2 functions to setup and remove a session.
      
      iscsi will continue to be the odd driver.
      Signed-off-by: NMike Christie <mchristi@redhat.com>
      Reviewed-by: NBart Van Assche <bart.vanassche@wdc.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Chris Boot <bootc@bootc.net>
      Cc: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
      Cc: Michael Cyr <mikecyr@linux.vnet.ibm.com>
      Cc: <qla2xxx-upstream@qlogic.com>
      Cc: Johannes Thumshirn <jth@kernel.org>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      fa834287
  3. 02 8月, 2018 1 次提交
  4. 01 8月, 2018 1 次提交
  5. 31 7月, 2018 3 次提交
  6. 30 7月, 2018 1 次提交
  7. 25 7月, 2018 6 次提交
  8. 24 7月, 2018 1 次提交
  9. 14 7月, 2018 2 次提交
  10. 11 7月, 2018 1 次提交
  11. 10 7月, 2018 6 次提交
  12. 04 7月, 2018 3 次提交
    • B
      ib_srpt: Fix a use-after-free in __srpt_close_all_ch() · 14d15c2b
      Bart Van Assche 提交于
      BUG: KASAN: use-after-free in srpt_set_enabled+0x1a9/0x1e0 [ib_srpt]
      Read of size 4 at addr ffff8801269d23f8 by task check/29726
      
      CPU: 4 PID: 29726 Comm: check Not tainted 4.18.0-rc2-dbg+ #4
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
      Call Trace:
       dump_stack+0xa4/0xf5
       print_address_description+0x6f/0x270
       kasan_report+0x241/0x360
       __asan_load4+0x78/0x80
       srpt_set_enabled+0x1a9/0x1e0 [ib_srpt]
       srpt_tpg_enable_store+0xb8/0x120 [ib_srpt]
       configfs_write_file+0x14e/0x1d0 [configfs]
       __vfs_write+0xd2/0x3b0
       vfs_write+0x101/0x270
       ksys_write+0xab/0x120
       __x64_sys_write+0x43/0x50
       do_syscall_64+0x77/0x230
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x7f235cfe6154
      
      Fixes: aaf45bd8 ("IB/srpt: Detect session shutdown reliably")
      Signed-off-by: NBart Van Assche <bart.vanassche@wdc.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      14d15c2b
    • B
      ib_srpt: Fix a use-after-free in srpt_close_ch() · 99525095
      Bart Van Assche 提交于
      Avoid that KASAN reports the following:
      
      BUG: KASAN: use-after-free in srpt_close_ch+0x4f/0x1b0 [ib_srpt]
      Read of size 4 at addr ffff880151180cb8 by task check/4681
      
      CPU: 15 PID: 4681 Comm: check Not tainted 4.18.0-rc2-dbg+ #4
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
      Call Trace:
       dump_stack+0xa4/0xf5
       print_address_description+0x6f/0x270
       kasan_report+0x241/0x360
       __asan_load4+0x78/0x80
       srpt_close_ch+0x4f/0x1b0 [ib_srpt]
       srpt_set_enabled+0xf7/0x1e0 [ib_srpt]
       srpt_tpg_enable_store+0xb8/0x120 [ib_srpt]
       configfs_write_file+0x14e/0x1d0 [configfs]
       __vfs_write+0xd2/0x3b0
       vfs_write+0x101/0x270
       ksys_write+0xab/0x120
       __x64_sys_write+0x43/0x50
       do_syscall_64+0x77/0x230
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Fixes: aaf45bd8 ("IB/srpt: Detect session shutdown reliably")
      Signed-off-by: NBart Van Assche <bart.vanassche@wdc.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      99525095
    • B
      IB/srp: Remove driver version and release data information · af7b641e
      Bart Van Assche 提交于
      Remove the driver version and release date information because such
      information is not relevant for an upstream driver. See also commit
      e1267b01 ("RDMA: Remove useless MODULE_VERSION").
      Signed-off-by: NBart Van Assche <bart.vanassche@wdc.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      af7b641e
  13. 03 7月, 2018 1 次提交
  14. 30 6月, 2018 2 次提交