Skip to content

Commit 1424c3e

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fixes from Jason Gunthorpe: "The usual collection of small driver bug fixes: - Fix error unwind bugs in hfi1, irdma rtrs - Old bug with IPoIB children interfaces possibly using the wrong number of queues - Really old bug in usnic calling iommu_map in an atomic context - Recent regression from the DMABUF locking rework - Missing user data validation in MANA" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/rtrs: Don't call kobject_del for srv_path->kobj RDMA/mana_ib: Prevent array underflow in mana_ib_create_qp_raw() IB/hfi1: Assign npages earlier RDMA/umem: Use dma-buf locked API to solve deadlock RDMA/usnic: use iommu_map_atomic() under spin_lock() RDMA/irdma: Fix potential NULL-ptr-dereference IB/IPoIB: Fix legacy IPoIB due to wrong number of queues IB/hfi1: Restore allocated resources on failed copyout
2 parents e544a07 + 2de49fb commit 1424c3e

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

drivers/infiniband/core/umem_dmabuf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
2626
if (umem_dmabuf->sgt)
2727
goto wait_fence;
2828

29-
sgt = dma_buf_map_attachment_unlocked(umem_dmabuf->attach,
30-
DMA_BIDIRECTIONAL);
29+
sgt = dma_buf_map_attachment(umem_dmabuf->attach,
30+
DMA_BIDIRECTIONAL);
3131
if (IS_ERR(sgt))
3232
return PTR_ERR(sgt);
3333

@@ -103,8 +103,8 @@ void ib_umem_dmabuf_unmap_pages(struct ib_umem_dmabuf *umem_dmabuf)
103103
umem_dmabuf->last_sg_trim = 0;
104104
}
105105

106-
dma_buf_unmap_attachment_unlocked(umem_dmabuf->attach, umem_dmabuf->sgt,
107-
DMA_BIDIRECTIONAL);
106+
dma_buf_unmap_attachment(umem_dmabuf->attach, umem_dmabuf->sgt,
107+
DMA_BIDIRECTIONAL);
108108

109109
umem_dmabuf->sgt = NULL;
110110
}

drivers/infiniband/hw/hfi1/file_ops.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,12 +1318,15 @@ static int user_exp_rcv_setup(struct hfi1_filedata *fd, unsigned long arg,
13181318
addr = arg + offsetof(struct hfi1_tid_info, tidcnt);
13191319
if (copy_to_user((void __user *)addr, &tinfo.tidcnt,
13201320
sizeof(tinfo.tidcnt)))
1321-
return -EFAULT;
1321+
ret = -EFAULT;
13221322

13231323
addr = arg + offsetof(struct hfi1_tid_info, length);
1324-
if (copy_to_user((void __user *)addr, &tinfo.length,
1324+
if (!ret && copy_to_user((void __user *)addr, &tinfo.length,
13251325
sizeof(tinfo.length)))
13261326
ret = -EFAULT;
1327+
1328+
if (ret)
1329+
hfi1_user_exp_rcv_invalid(fd, &tinfo);
13271330
}
13281331

13291332
return ret;

drivers/infiniband/hw/hfi1/user_exp_rcv.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,11 @@ static void unpin_rcv_pages(struct hfi1_filedata *fd,
160160
static int pin_rcv_pages(struct hfi1_filedata *fd, struct tid_user_buf *tidbuf)
161161
{
162162
int pinned;
163-
unsigned int npages;
163+
unsigned int npages = tidbuf->npages;
164164
unsigned long vaddr = tidbuf->vaddr;
165165
struct page **pages = NULL;
166166
struct hfi1_devdata *dd = fd->uctxt->dd;
167167

168-
/* Get the number of pages the user buffer spans */
169-
npages = num_user_pages(vaddr, tidbuf->length);
170-
if (!npages)
171-
return -EINVAL;
172-
173168
if (npages > fd->uctxt->expected_count) {
174169
dd_dev_err(dd, "Expected buffer too big\n");
175170
return -EINVAL;
@@ -196,7 +191,6 @@ static int pin_rcv_pages(struct hfi1_filedata *fd, struct tid_user_buf *tidbuf)
196191
return pinned;
197192
}
198193
tidbuf->pages = pages;
199-
tidbuf->npages = npages;
200194
fd->tid_n_pinned += pinned;
201195
return pinned;
202196
}
@@ -274,6 +268,7 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
274268
mutex_init(&tidbuf->cover_mutex);
275269
tidbuf->vaddr = tinfo->vaddr;
276270
tidbuf->length = tinfo->length;
271+
tidbuf->npages = num_user_pages(tidbuf->vaddr, tidbuf->length);
277272
tidbuf->psets = kcalloc(uctxt->expected_count, sizeof(*tidbuf->psets),
278273
GFP_KERNEL);
279274
if (!tidbuf->psets) {

drivers/infiniband/hw/irdma/cm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,9 @@ static int irdma_add_mqh_4(struct irdma_device *iwdev,
17221722
continue;
17231723

17241724
idev = in_dev_get(ip_dev);
1725+
if (!idev)
1726+
continue;
1727+
17251728
in_dev_for_each_ifa_rtnl(ifa, idev) {
17261729
ibdev_dbg(&iwdev->ibdev,
17271730
"CM: Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n",

drivers/infiniband/hw/mana/qp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
289289

290290
/* IB ports start with 1, MANA Ethernet ports start with 0 */
291291
port = ucmd.port;
292-
if (ucmd.port > mc->num_ports)
292+
if (port < 1 || port > mc->num_ports)
293293
return -EINVAL;
294294

295295
if (attr->cap.max_send_wr > MAX_SEND_BUFFERS_PER_QUEUE) {

drivers/infiniband/hw/usnic/usnic_uiom.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ static int usnic_uiom_map_sorted_intervals(struct list_head *intervals,
276276
size = pa_end - pa_start + PAGE_SIZE;
277277
usnic_dbg("va 0x%lx pa %pa size 0x%zx flags 0x%x",
278278
va_start, &pa_start, size, flags);
279-
err = iommu_map(pd->domain, va_start, pa_start,
280-
size, flags);
279+
err = iommu_map_atomic(pd->domain, va_start,
280+
pa_start, size, flags);
281281
if (err) {
282282
usnic_err("Failed to map va 0x%lx pa %pa size 0x%zx with err %d\n",
283283
va_start, &pa_start, size, err);
@@ -293,8 +293,8 @@ static int usnic_uiom_map_sorted_intervals(struct list_head *intervals,
293293
size = pa - pa_start + PAGE_SIZE;
294294
usnic_dbg("va 0x%lx pa %pa size 0x%zx flags 0x%x\n",
295295
va_start, &pa_start, size, flags);
296-
err = iommu_map(pd->domain, va_start, pa_start,
297-
size, flags);
296+
err = iommu_map_atomic(pd->domain, va_start,
297+
pa_start, size, flags);
298298
if (err) {
299299
usnic_err("Failed to map va 0x%lx pa %pa size 0x%zx with err %d\n",
300300
va_start, &pa_start, size, err);

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,14 @@ int ipoib_intf_init(struct ib_device *hca, u32 port, const char *name,
22002200
rn->attach_mcast = ipoib_mcast_attach;
22012201
rn->detach_mcast = ipoib_mcast_detach;
22022202
rn->hca = hca;
2203+
2204+
rc = netif_set_real_num_tx_queues(dev, 1);
2205+
if (rc)
2206+
goto out;
2207+
2208+
rc = netif_set_real_num_rx_queues(dev, 1);
2209+
if (rc)
2210+
goto out;
22032211
}
22042212

22052213
priv->rn_ops = dev->netdev_ops;

drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,8 @@ void rtrs_srv_destroy_path_files(struct rtrs_srv_path *srv_path)
312312

313313
if (srv_path->kobj.state_in_sysfs) {
314314
sysfs_remove_group(&srv_path->kobj, &rtrs_srv_path_attr_group);
315-
kobject_del(&srv_path->kobj);
316315
kobject_put(&srv_path->kobj);
316+
rtrs_srv_destroy_once_sysfs_root_folders(srv_path);
317317
}
318318

319-
rtrs_srv_destroy_once_sysfs_root_folders(srv_path);
320319
}

0 commit comments

Comments
 (0)