Commit d53f4d93 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'v7.0-rc-part1-ksmbd-and-smbdirect-fixes' of git://git.samba.org/ksmbd

Pull smb server and smbdirect updates from Steve French:

 - Fix tcp connection leak

 - Fix potential use after free when freeing multichannel

 - Fix locking problem in showing channel list

 - Locking improvement for tree connection

 - Fix infinite loop when signing errors

 - Add /proc interface for monitoring server state

 - Fixes to avoid mixing iWarp and InfiniBand/RoCEv1/RoCEv2
   port ranges used for smbdirect

 - Fixes for smbdirect credit handling problems, these make
   the connections more reliable

* tag 'v7.0-rc-part1-ksmbd-and-smbdirect-fixes' of git://git.samba.org/ksmbd: (32 commits)
  ksmbd: fix non-IPv6 build
  ksmbd: convert tree_conns_lock to rw_semaphore
  ksmbd: fix missing chann_lock while iterating session channel list
  ksmbd: add chann_lock to protect ksmbd_chann_list xarray
  smb: server: correct value for smb_direct_max_fragmented_recv_size
  smb: client: correct value for smbd_max_fragmented_recv_size
  smb: server: fix leak of active_num_conn in ksmbd_tcp_new_connection()
  ksmbd: add procfs interface for runtime monitoring and statistics
  ksmbd: fix infinite loop caused by next_smb2_rcv_hdr_off reset in error paths
  smb: server: make use of rdma_restrict_node_type()
  smb: client: make use of rdma_restrict_node_type()
  RDMA/core: introduce rdma_restrict_node_type()
  smb: client: let send_done handle a completion without IB_SEND_SIGNALED
  smb: client: let smbd_post_send_negotiate_req() use smbd_post_send()
  smb: client: fix last send credit problem causing disconnects
  smb: client: make use of smbdirect_socket.send_io.bcredits
  smb: client: use smbdirect_send_batch processing
  smb: client: introduce and use smbd_{alloc, free}_send_io()
  smb: client: split out smbd_ib_post_send()
  smb: client: port and use the wait_for_credits logic used by server
  ...
parents 2831fa8b 8f7df60f
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -793,6 +793,9 @@ static int cma_acquire_dev_by_src_ip(struct rdma_id_private *id_priv)

	mutex_lock(&lock);
	list_for_each_entry(cma_dev, &dev_list, list) {
		if (id_priv->restricted_node_type != RDMA_NODE_UNSPECIFIED &&
		    id_priv->restricted_node_type != cma_dev->device->node_type)
			continue;
		rdma_for_each_port (cma_dev->device, port) {
			gidp = rdma_protocol_roce(cma_dev->device, port) ?
			       &iboe_gid : &gid;
@@ -1015,6 +1018,7 @@ __rdma_create_id(struct net *net, rdma_cm_event_handler event_handler,
		return ERR_PTR(-ENOMEM);

	id_priv->state = RDMA_CM_IDLE;
	id_priv->restricted_node_type = RDMA_NODE_UNSPECIFIED;
	id_priv->id.context = context;
	id_priv->id.event_handler = event_handler;
	id_priv->id.ps = ps;
@@ -4177,6 +4181,32 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
}
EXPORT_SYMBOL(rdma_resolve_addr);

int rdma_restrict_node_type(struct rdma_cm_id *id, u8 node_type)
{
	struct rdma_id_private *id_priv =
		container_of(id, struct rdma_id_private, id);
	int ret = 0;

	switch (node_type) {
	case RDMA_NODE_UNSPECIFIED:
	case RDMA_NODE_IB_CA:
	case RDMA_NODE_RNIC:
		break;
	default:
		return -EINVAL;
	}

	mutex_lock(&lock);
	if (id_priv->cma_dev)
		ret = -EALREADY;
	else
		id_priv->restricted_node_type = node_type;
	mutex_unlock(&lock);

	return ret;
}
EXPORT_SYMBOL(rdma_restrict_node_type);

int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
{
	struct rdma_id_private *id_priv =
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ struct rdma_id_private {

	int			internal_id;
	enum rdma_cm_state	state;
	u8			restricted_node_type;
	spinlock_t		lock;
	struct mutex		qp_mutex;

+440 −128

File changed.

Preview size limit exceeded, changes collapsed.

+18 −0
Original line number Diff line number Diff line
@@ -162,6 +162,17 @@ struct smbdirect_socket {
			mempool_t		*pool;
		} mem;

		/*
		 * This is a coordination for smbdirect_send_batch.
		 *
		 * There's only one possible credit, which means
		 * only one instance is running at a time.
		 */
		struct {
			atomic_t count;
			wait_queue_head_t wait_queue;
		} bcredits;

		/*
		 * The local credit state for ib_post_send()
		 */
@@ -239,6 +250,7 @@ struct smbdirect_socket {
		 */
		struct {
			u16 target;
			atomic_t available;
			atomic_t count;
		} credits;

@@ -370,6 +382,9 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
	INIT_DELAYED_WORK(&sc->idle.timer_work, __smbdirect_socket_disabled_work);
	disable_delayed_work_sync(&sc->idle.timer_work);

	atomic_set(&sc->send_io.bcredits.count, 0);
	init_waitqueue_head(&sc->send_io.bcredits.wait_queue);

	atomic_set(&sc->send_io.lcredits.count, 0);
	init_waitqueue_head(&sc->send_io.lcredits.wait_queue);

@@ -387,6 +402,7 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
	INIT_WORK(&sc->recv_io.posted.refill_work, __smbdirect_socket_disabled_work);
	disable_work_sync(&sc->recv_io.posted.refill_work);

	atomic_set(&sc->recv_io.credits.available, 0);
	atomic_set(&sc->recv_io.credits.count, 0);

	INIT_LIST_HEAD(&sc->recv_io.reassembly.list);
@@ -483,6 +499,8 @@ struct smbdirect_send_batch {
	 */
	bool need_invalidate_rkey;
	u32 remote_key;

	int credit;
};

struct smbdirect_recv_io {
+1 −0
Original line number Diff line number Diff line
@@ -18,3 +18,4 @@ $(obj)/ksmbd_spnego_negtokeninit.asn1.o: $(obj)/ksmbd_spnego_negtokeninit.asn1.c
$(obj)/ksmbd_spnego_negtokentarg.asn1.o: $(obj)/ksmbd_spnego_negtokentarg.asn1.c $(obj)/ksmbd_spnego_negtokentarg.asn1.h

ksmbd-$(CONFIG_SMB_SERVER_SMBDIRECT) += transport_rdma.o
ksmbd-$(CONFIG_PROC_FS) += proc.o
Loading