Commit e3c81bae authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull rdma fixes from Jason Gunthorpe:
 "Seems bigger than usual, a number of things were posted near/during
  the merg window:

   - Fix some compilation regressions related to the new DMABUF code

   - Close a race with ib_register_device() vs netdev events that causes
     GID table corruption

   - Compilation warnings with some compilers in bng_re

   - Correct error unwind in bng_re and the umem pinned dmabuf

   - Avoid NULL pointer crash in ionic during query_port()

   - Check the size for uAPI validation checks in EFA

   - Several system call stack leaks in drivers found with AI

   - Fix the new restricted_node_type so it works with wildcard listens
     too"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
  RDMA/uverbs: Import DMA-BUF module in uverbs_std_types_dmabuf file
  RDMA/umem: Fix double dma_buf_unpin in failure path
  RDMA/core: Check id_priv->restricted_node_type in cma_listen_on_dev()
  RDMA/ionic: Fix kernel stack leak in ionic_create_cq()
  RDMA/irdma: Fix kernel stack leak in irdma_create_user_ah()
  IB/mthca: Add missed mthca_unmap_user_db() for mthca_create_srq()
  RDMA/efa: Fix typo in efa_alloc_mr()
  RDMA/ionic: Fix potential NULL pointer dereference in ionic_query_port
  RDMA/bng_re: Unwind bng_re_dev_init properly
  RDMA/bng_re: Remove unnessary validity checks
  RDMA/core: Fix stale RoCE GIDs during netdev events at registration
  RDMA/uverbs: select CONFIG_DMA_SHARED_BUFFER
parents b9c8fc2c 7c2889af
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ menuconfig INFINIBAND
	depends on INET
	depends on m || IPV6 != m
	depends on !ALPHA
	select DMA_SHARED_BUFFER
	select IRQ_POLL
	select DIMLIB
	help
+13 −0
Original line number Diff line number Diff line
@@ -926,6 +926,13 @@ static int gid_table_setup_one(struct ib_device *ib_dev)
	if (err)
		return err;

	/*
	 * Mark the device as ready for GID cache updates. This allows netdev
	 * event handlers to update the GID cache even before the device is
	 * fully registered.
	 */
	ib_device_enable_gid_updates(ib_dev);

	rdma_roce_rescan_device(ib_dev);

	return err;
@@ -1637,6 +1644,12 @@ void ib_cache_release_one(struct ib_device *device)

void ib_cache_cleanup_one(struct ib_device *device)
{
	/*
	 * Clear the GID updates mark first to prevent event handlers from
	 * accessing the device while it's being torn down.
	 */
	ib_device_disable_gid_updates(device);

	/* The cleanup function waits for all in-progress workqueue
	 * elements and cleans up the GID cache. This function should be
	 * called after the device was removed from the devices list and
+5 −1
Original line number Diff line number Diff line
@@ -2729,6 +2729,9 @@ static int cma_listen_on_dev(struct rdma_id_private *id_priv,
	*to_destroy = NULL;
	if (cma_family(id_priv) == AF_IB && !rdma_cap_ib_cm(cma_dev->device, 1))
		return 0;
	if (id_priv->restricted_node_type != RDMA_NODE_UNSPECIFIED &&
	    id_priv->restricted_node_type != cma_dev->device->node_type)
		return 0;

	dev_id_priv =
		__rdma_create_id(net, cma_listen_handler, id_priv,
@@ -2736,6 +2739,7 @@ static int cma_listen_on_dev(struct rdma_id_private *id_priv,
	if (IS_ERR(dev_id_priv))
		return PTR_ERR(dev_id_priv);

	dev_id_priv->restricted_node_type = id_priv->restricted_node_type;
	dev_id_priv->state = RDMA_CM_ADDR_BOUND;
	memcpy(cma_src_addr(dev_id_priv), cma_src_addr(id_priv),
	       rdma_addr_size(cma_src_addr(id_priv)));
@@ -4194,7 +4198,7 @@ int rdma_restrict_node_type(struct rdma_cm_id *id, u8 node_type)
	}

	mutex_lock(&lock);
	if (id_priv->cma_dev)
	if (READ_ONCE(id_priv->state) != RDMA_CM_IDLE)
		ret = -EALREADY;
	else
		id_priv->restricted_node_type = node_type;
+3 −0
Original line number Diff line number Diff line
@@ -100,6 +100,9 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
			      roce_netdev_callback cb,
			      void *cookie);

void ib_device_enable_gid_updates(struct ib_device *device);
void ib_device_disable_gid_updates(struct ib_device *device);

typedef int (*nldev_callback)(struct ib_device *device,
			      struct sk_buff *skb,
			      struct netlink_callback *cb,
+33 −1
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ static struct workqueue_struct *ib_unreg_wq;
static DEFINE_XARRAY_FLAGS(devices, XA_FLAGS_ALLOC);
static DECLARE_RWSEM(devices_rwsem);
#define DEVICE_REGISTERED XA_MARK_1
#define DEVICE_GID_UPDATES XA_MARK_2

static u32 highest_client_id;
#define CLIENT_REGISTERED XA_MARK_1
@@ -2412,11 +2413,42 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
	unsigned long index;

	down_read(&devices_rwsem);
	xa_for_each_marked (&devices, index, dev, DEVICE_REGISTERED)
	xa_for_each_marked(&devices, index, dev, DEVICE_GID_UPDATES)
		ib_enum_roce_netdev(dev, filter, filter_cookie, cb, cookie);
	up_read(&devices_rwsem);
}

/**
 * ib_device_enable_gid_updates - Mark device as ready for GID cache updates
 * @device: Device to mark
 *
 * Called after GID table is allocated and initialized. After this mark is set,
 * netdevice event handlers can update the device's GID cache. This allows
 * events that arrive during device registration to be processed, avoiding
 * stale GID entries when netdev properties change during the device
 * registration process.
 */
void ib_device_enable_gid_updates(struct ib_device *device)
{
	down_write(&devices_rwsem);
	xa_set_mark(&devices, device->index, DEVICE_GID_UPDATES);
	up_write(&devices_rwsem);
}

/**
 * ib_device_disable_gid_updates - Clear the GID updates mark
 * @device: Device to unmark
 *
 * Called before GID table cleanup to prevent event handlers from accessing
 * the device while it's being torn down.
 */
void ib_device_disable_gid_updates(struct ib_device *device)
{
	down_write(&devices_rwsem);
	xa_clear_mark(&devices, device->index, DEVICE_GID_UPDATES);
	up_write(&devices_rwsem);
}

/*
 * ib_enum_all_devs - enumerate all ib_devices
 * @cb: Callback to call for each found ib_device
Loading