Skip to content
  1. Dec 04, 2018
  2. Nov 30, 2018
  3. Nov 27, 2018
  4. Nov 23, 2018
    • Parav Pandit's avatar
      RDMA/core: Sync unregistration with netlink commands · 01b67117
      Parav Pandit authored
      
      
      When the rdma device is getting removed, get resource info can race with
      device removal, as below:
      
            CPU-0                                  CPU-1
          --------                               --------
          rdma_nl_rcv_msg()
             nldev_res_get_cq_dumpit()
                mutex_lock(device_lock);
                get device reference
                mutex_unlock(device_lock);        [..]
                                                  ib_unregister_device()
                                                  /* Valid reference to
                                                   * device->dev exists.
                                                   */
                                                   ib_dealloc_device()
      
                [..]
                provider->fill_res_entry();
      
      Even though device object is not freed, fill_res_entry() can get called on
      device which doesn't have a driver anymore. Kernel core device reference
      count is not sufficient, as this only keeps the structure valid, and
      doesn't guarantee the driver is still loaded.
      
      Similar race can occur with device renaming and device removal, where
      device_rename() tries to rename a unregistered device. While this is fine
      for devices of a class which are not net namespace aware, but it is
      incorrect for net namespace aware class coming in subsequent series.  If a
      class is net namespace aware, then the below [1] call trace is observed in
      above situation.
      
      Therefore, to avoid the race, keep a reference count and let device
      unregistration wait until all netlink users drop the reference.
      
      [1] Call trace:
      kernfs: ns required in 'infiniband' for 'mlx5_0'
      WARNING: CPU: 18 PID: 44270 at fs/kernfs/dir.c:842 kernfs_find_ns+0x104/0x120
      libahci i2c_core mlxfw libata dca [last unloaded: devlink]
      RIP: 0010:kernfs_find_ns+0x104/0x120
      Call Trace:
      kernfs_find_and_get_ns+0x2e/0x50
      sysfs_rename_link_ns+0x40/0xb0
      device_rename+0xb2/0xf0
      ib_device_rename+0xb3/0x100 [ib_core]
      nldev_set_doit+0x165/0x190 [ib_core]
      rdma_nl_rcv_msg+0x249/0x250 [ib_core]
      ? netlink_deliver_tap+0x8f/0x3e0
      rdma_nl_rcv+0xd6/0x120 [ib_core]
      netlink_unicast+0x17c/0x230
      netlink_sendmsg+0x2f0/0x3e0
      sock_sendmsg+0x30/0x40
      __sys_sendto+0xdc/0x160
      
      Fixes: da5c8507 ("RDMA/nldev: add driver-specific resource tracking")
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      01b67117
    • Parav Pandit's avatar
      RDMA/cma: Move cma module specific functions to cma_priv.h · eeb8df87
      Parav Pandit authored
      
      
      Currently several rdma_cm module specific functions are declared in
      core_priv.h file. Now that we have cma_priv.h file specific to rdma_cm
      kernel module, move them from core_priv.h to cma_priv.h
      
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      eeb8df87
    • Jason Gunthorpe's avatar
      RDMA/uverbs: Check for NULL driver methods for every write call · a140692a
      Jason Gunthorpe authored
      
      
      Add annotations to the uverbs_api structure indicating which driver
      methods are called by the implementation. If the required method
      is NULL the write API will be not be callable.
      
      This effectively duplicates the cmd_mask system, however it does it by
      expressing invariants required by the core code, not by delegating
      decision making to the driver. This is another step toward eliminating
      cmd_mask.
      
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      a140692a
    • Jason Gunthorpe's avatar
      RDMA/uverbs: Make all the method functions in uverbs_cmd static · 1de751ca
      Jason Gunthorpe authored
      
      
      Now that we use struct uverbs_uapi to link the method functions to the
      dispatcher there is no reason to have them be extern symbols.
      
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      1de751ca
    • Jason Gunthorpe's avatar
      RDMA/uverbs: Convert the write interface to use uverbs_api · d120c3c9
      Jason Gunthorpe authored
      
      
      This organizes the write commands into objects and links them to the
      uverbs_api data structure. The command path is reworked to use uapi
      instead of its internal structures.
      
      The command mask is moved from a runtime check to a registration time
      check in the uapi.
      
      Since the write interface does not have the object ID as part of the
      command, the radix bins are converted into linear lists to support the
      lookup.
      
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      d120c3c9
    • Jason Gunthorpe's avatar
      RDMA/verbs: Store the write/write_ex uapi entry points in the uverbs_api · 6884c6c4
      Jason Gunthorpe authored
      
      
      Bringing all uapi entry points into one place lets us deal with them
      consistently. For instance the write, write_ex and ioctl paths can be
      disabled when an API is not supported by the driver.
      
      This will replace the uverbs_cmd_table static arrays.
      
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      6884c6c4
    • Jason Gunthorpe's avatar
      RDMA/uverbs: Require all objects to have a driver destroy function · 0bd01f3d
      Jason Gunthorpe authored
      
      
      If we can't destroy the object then we certainly shouldn't allow it be
      created or used. Remove it from the uverbs_uapi in this case.
      
      This also disables methods of other objects that have mandatory object
      handle inputs - ie REG_DM_MR is now automatically removed if DM objects
      cannot be created.
      
      Typically drivers not supporting an interface will mark all of the
      supporting functions as NULL, including destroy.
      
      This is intended to automatically eliminate entire corner cases in the API
      that are difficult to test.
      
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      0bd01f3d