Commit 6d064432 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'v6.19-rc6-server-fixes' of git://git.samba.org/ksmbd

Pull smb server fixes from Steve French:

 - Use the original nents value for ib_dma_unmap_sg(), preventing
   potential memory corruption in the RDMA transport layer

 - Fix a naming discrepancy in the kernel-doc for
   ksmbd_vfs_kern_path_start_removing() as identified by sparse static
   analysis

 - Reset smb_direct_port to its default value during initialization to
   ensure the correct port is used when switching between different RDMA
   device types without module reload

* tag 'v6.19-rc6-server-fixes' of git://git.samba.org/ksmbd:
  smb: server: reset smb_direct_port = SMB_DIRECT_PORT_INFINIBAND on init
  smb: server: fix comment for ksmbd_vfs_kern_path_start_removing()
  ksmbd: smbd: fix dma_unmap_sg() nents
parents 5bde8370 5914d98f
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -1353,14 +1353,12 @@ static int get_sg_list(void *buf, int size, struct scatterlist *sg_list, int nen

static int get_mapped_sg_list(struct ib_device *device, void *buf, int size,
			      struct scatterlist *sg_list, int nentries,
			      enum dma_data_direction dir)
			      enum dma_data_direction dir, int *npages)
{
	int npages;

	npages = get_sg_list(buf, size, sg_list, nentries);
	if (npages < 0)
	*npages = get_sg_list(buf, size, sg_list, nentries);
	if (*npages < 0)
		return -EINVAL;
	return ib_dma_map_sg(device, sg_list, npages, dir);
	return ib_dma_map_sg(device, sg_list, *npages, dir);
}

static int post_sendmsg(struct smbdirect_socket *sc,
@@ -1431,12 +1429,13 @@ static int smb_direct_post_send_data(struct smbdirect_socket *sc,
	for (i = 0; i < niov; i++) {
		struct ib_sge *sge;
		int sg_cnt;
		int npages;

		sg_init_table(sg, SMBDIRECT_SEND_IO_MAX_SGE - 1);
		sg_cnt = get_mapped_sg_list(sc->ib.dev,
					    iov[i].iov_base, iov[i].iov_len,
					    sg, SMBDIRECT_SEND_IO_MAX_SGE - 1,
					    DMA_TO_DEVICE);
					    DMA_TO_DEVICE, &npages);
		if (sg_cnt <= 0) {
			pr_err("failed to map buffer\n");
			ret = -ENOMEM;
@@ -1444,7 +1443,7 @@ static int smb_direct_post_send_data(struct smbdirect_socket *sc,
		} else if (sg_cnt + msg->num_sge > SMBDIRECT_SEND_IO_MAX_SGE) {
			pr_err("buffer not fitted into sges\n");
			ret = -E2BIG;
			ib_dma_unmap_sg(sc->ib.dev, sg, sg_cnt,
			ib_dma_unmap_sg(sc->ib.dev, sg, npages,
					DMA_TO_DEVICE);
			goto err;
		}
@@ -2708,6 +2707,7 @@ int ksmbd_rdma_init(void)
{
	int ret;

	smb_direct_port = SMB_DIRECT_PORT_INFINIBAND;
	smb_direct_listener.cm_id = NULL;

	ret = ib_register_client(&smb_direct_ib_client);
+1 −1
Original line number Diff line number Diff line
@@ -1227,7 +1227,7 @@ int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *filepath,
}

/**
 * ksmbd_vfs_kern_path_start_remove() - lookup a file and get path info prior to removal
 * ksmbd_vfs_kern_path_start_removing() - lookup a file and get path info prior to removal
 * @work:		work
 * @filepath:		file path that is relative to share
 * @flags:		lookup flags