Skip to content

Commit 9420e8a

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: "A small set of late-rc patches, mostly fixes for various crashers, some syzkaller fixes and a mlx5 HW limitation: - Several MAINTAINERS updates - Memory leak regression in ODP - Several fixes for syzkaller related crashes. Google recently taught syzkaller to create the software RDMA devices - Crash fixes for HFI1 - Several fixes for mlx5 crashes - Prevent unprivileged access to an unsafe mlx5 HW resource" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/mlx5: Block delay drop to unprivileged users RDMA/mlx5: Fix access to wrong pointer while performing flush due to error RDMA/core: Ensure security pkey modify is not lost MAINTAINERS: Clean RXE section and add Zhu as RXE maintainer IB/hfi1: Ensure pq is not left on waitlist IB/rdmavt: Free kernel completion queue when done RDMA/mad: Do not crash if the rdma device does not have a umad interface RDMA/core: Fix missing error check on dev_set_name() RDMA/nl: Do not permit empty devices names during RDMA_NLDEV_CMD_NEWLINK/SET RDMA/mlx5: Fix the number of hwcounters of a dynamic counter MAINTAINERS: Update maintainers for HISILICON ROCE DRIVER RDMA/odp: Fix leaking the tgid for implicit ODP
2 parents 1b649e0 + ba80013 commit 9420e8a

File tree

12 files changed

+94
-34
lines changed

12 files changed

+94
-34
lines changed

MAINTAINERS

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7579,7 +7579,8 @@ F: Documentation/admin-guide/perf/hisi-pmu.rst
75797579

75807580
HISILICON ROCE DRIVER
75817581
M: Lijun Ou <[email protected]>
7582-
M: Wei Hu(Xavier) <[email protected]>
7582+
M: Wei Hu(Xavier) <[email protected]>
7583+
M: Weihang Li <[email protected]>
75837584
75847585
S: Maintained
75857586
F: drivers/infiniband/hw/hns/
@@ -15421,11 +15422,9 @@ F: drivers/infiniband/sw/siw/
1542115422
F: include/uapi/rdma/siw-abi.h
1542215423

1542315424
SOFT-ROCE DRIVER (rxe)
15424-
M: Moni Shoua <monis@mellanox.com>
15425+
M: Zhu Yanjun <yanjunz@mellanox.com>
1542515426
1542615427
S: Supported
15427-
W: https://github.com/SoftRoCE/rxe-dev/wiki/rxe-dev:-Home
15428-
Q: http://patchwork.kernel.org/project/linux-rdma/list/
1542915428
F: drivers/infiniband/sw/rxe/
1543015429
F: include/uapi/rdma/rdma_user_rxe.h
1543115430

drivers/infiniband/core/device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,9 @@ static int add_one_compat_dev(struct ib_device *device,
896896
cdev->dev.parent = device->dev.parent;
897897
rdma_init_coredev(cdev, device, read_pnet(&rnet->net));
898898
cdev->dev.release = compatdev_release;
899-
dev_set_name(&cdev->dev, "%s", dev_name(&device->dev));
899+
ret = dev_set_name(&cdev->dev, "%s", dev_name(&device->dev));
900+
if (ret)
901+
goto add_err;
900902

901903
ret = device_add(&cdev->dev);
902904
if (ret)

drivers/infiniband/core/nldev.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,10 @@ static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
918918

919919
nla_strlcpy(name, tb[RDMA_NLDEV_ATTR_DEV_NAME],
920920
IB_DEVICE_NAME_MAX);
921+
if (strlen(name) == 0) {
922+
err = -EINVAL;
923+
goto done;
924+
}
921925
err = ib_device_rename(device, name);
922926
goto done;
923927
}
@@ -1514,7 +1518,7 @@ static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
15141518

15151519
nla_strlcpy(ibdev_name, tb[RDMA_NLDEV_ATTR_DEV_NAME],
15161520
sizeof(ibdev_name));
1517-
if (strchr(ibdev_name, '%'))
1521+
if (strchr(ibdev_name, '%') || strlen(ibdev_name) == 0)
15181522
return -EINVAL;
15191523

15201524
nla_strlcpy(type, tb[RDMA_NLDEV_ATTR_LINK_TYPE], sizeof(type));

drivers/infiniband/core/security.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,16 +349,11 @@ static struct ib_ports_pkeys *get_new_pps(const struct ib_qp *qp,
349349
else if (qp_pps)
350350
new_pps->main.pkey_index = qp_pps->main.pkey_index;
351351

352-
if ((qp_attr_mask & IB_QP_PKEY_INDEX) && (qp_attr_mask & IB_QP_PORT))
352+
if (((qp_attr_mask & IB_QP_PKEY_INDEX) &&
353+
(qp_attr_mask & IB_QP_PORT)) ||
354+
(qp_pps && qp_pps->main.state != IB_PORT_PKEY_NOT_VALID))
353355
new_pps->main.state = IB_PORT_PKEY_VALID;
354356

355-
if (!(qp_attr_mask & (IB_QP_PKEY_INDEX | IB_QP_PORT)) && qp_pps) {
356-
new_pps->main.port_num = qp_pps->main.port_num;
357-
new_pps->main.pkey_index = qp_pps->main.pkey_index;
358-
if (qp_pps->main.state != IB_PORT_PKEY_NOT_VALID)
359-
new_pps->main.state = IB_PORT_PKEY_VALID;
360-
}
361-
362357
if (qp_attr_mask & IB_QP_ALT_PATH) {
363358
new_pps->alt.port_num = qp_attr->alt_port_num;
364359
new_pps->alt.pkey_index = qp_attr->alt_pkey_index;

drivers/infiniband/core/umem_odp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ void ib_umem_odp_release(struct ib_umem_odp *umem_odp)
275275
mmu_interval_notifier_remove(&umem_odp->notifier);
276276
kvfree(umem_odp->dma_list);
277277
kvfree(umem_odp->page_list);
278-
put_pid(umem_odp->tgid);
279278
}
279+
put_pid(umem_odp->tgid);
280280
kfree(umem_odp);
281281
}
282282
EXPORT_SYMBOL(ib_umem_odp_release);

drivers/infiniband/core/user_mad.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,17 +1129,30 @@ static const struct file_operations umad_sm_fops = {
11291129
.llseek = no_llseek,
11301130
};
11311131

1132+
static struct ib_umad_port *get_port(struct ib_device *ibdev,
1133+
struct ib_umad_device *umad_dev,
1134+
unsigned int port)
1135+
{
1136+
if (!umad_dev)
1137+
return ERR_PTR(-EOPNOTSUPP);
1138+
if (!rdma_is_port_valid(ibdev, port))
1139+
return ERR_PTR(-EINVAL);
1140+
if (!rdma_cap_ib_mad(ibdev, port))
1141+
return ERR_PTR(-EOPNOTSUPP);
1142+
1143+
return &umad_dev->ports[port - rdma_start_port(ibdev)];
1144+
}
1145+
11321146
static int ib_umad_get_nl_info(struct ib_device *ibdev, void *client_data,
11331147
struct ib_client_nl_info *res)
11341148
{
1135-
struct ib_umad_device *umad_dev = client_data;
1149+
struct ib_umad_port *port = get_port(ibdev, client_data, res->port);
11361150

1137-
if (!rdma_is_port_valid(ibdev, res->port))
1138-
return -EINVAL;
1151+
if (IS_ERR(port))
1152+
return PTR_ERR(port);
11391153

11401154
res->abi = IB_USER_MAD_ABI_VERSION;
1141-
res->cdev = &umad_dev->ports[res->port - rdma_start_port(ibdev)].dev;
1142-
1155+
res->cdev = &port->dev;
11431156
return 0;
11441157
}
11451158

@@ -1154,15 +1167,13 @@ MODULE_ALIAS_RDMA_CLIENT("umad");
11541167
static int ib_issm_get_nl_info(struct ib_device *ibdev, void *client_data,
11551168
struct ib_client_nl_info *res)
11561169
{
1157-
struct ib_umad_device *umad_dev =
1158-
ib_get_client_data(ibdev, &umad_client);
1170+
struct ib_umad_port *port = get_port(ibdev, client_data, res->port);
11591171

1160-
if (!rdma_is_port_valid(ibdev, res->port))
1161-
return -EINVAL;
1172+
if (IS_ERR(port))
1173+
return PTR_ERR(port);
11621174

11631175
res->abi = IB_USER_MAD_ABI_VERSION;
1164-
res->cdev = &umad_dev->ports[res->port - rdma_start_port(ibdev)].sm_dev;
1165-
1176+
res->cdev = &port->sm_dev;
11661177
return 0;
11671178
}
11681179

drivers/infiniband/hw/hfi1/user_sdma.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static int defer_packet_queue(
141141
*/
142142
xchg(&pq->state, SDMA_PKT_Q_DEFERRED);
143143
if (list_empty(&pq->busy.list)) {
144+
pq->busy.lock = &sde->waitlock;
144145
iowait_get_priority(&pq->busy);
145146
iowait_queue(pkts_sent, &pq->busy, &sde->dmawait);
146147
}
@@ -155,6 +156,7 @@ static void activate_packet_queue(struct iowait *wait, int reason)
155156
{
156157
struct hfi1_user_sdma_pkt_q *pq =
157158
container_of(wait, struct hfi1_user_sdma_pkt_q, busy);
159+
pq->busy.lock = NULL;
158160
xchg(&pq->state, SDMA_PKT_Q_ACTIVE);
159161
wake_up(&wait->wait_dma);
160162
};
@@ -256,6 +258,21 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,
256258
return ret;
257259
}
258260

261+
static void flush_pq_iowait(struct hfi1_user_sdma_pkt_q *pq)
262+
{
263+
unsigned long flags;
264+
seqlock_t *lock = pq->busy.lock;
265+
266+
if (!lock)
267+
return;
268+
write_seqlock_irqsave(lock, flags);
269+
if (!list_empty(&pq->busy.list)) {
270+
list_del_init(&pq->busy.list);
271+
pq->busy.lock = NULL;
272+
}
273+
write_sequnlock_irqrestore(lock, flags);
274+
}
275+
259276
int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd,
260277
struct hfi1_ctxtdata *uctxt)
261278
{
@@ -281,6 +298,7 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd,
281298
kfree(pq->reqs);
282299
kfree(pq->req_in_use);
283300
kmem_cache_destroy(pq->txreq_cache);
301+
flush_pq_iowait(pq);
284302
kfree(pq);
285303
} else {
286304
spin_unlock(&fd->pq_rcu_lock);
@@ -587,11 +605,12 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
587605
if (ret < 0) {
588606
if (ret != -EBUSY)
589607
goto free_req;
590-
wait_event_interruptible_timeout(
608+
if (wait_event_interruptible_timeout(
591609
pq->busy.wait_dma,
592-
(pq->state == SDMA_PKT_Q_ACTIVE),
610+
pq->state == SDMA_PKT_Q_ACTIVE,
593611
msecs_to_jiffies(
594-
SDMA_IOWAIT_TIMEOUT));
612+
SDMA_IOWAIT_TIMEOUT)) <= 0)
613+
flush_pq_iowait(pq);
595614
}
596615
}
597616
*count += idx;

drivers/infiniband/hw/mlx5/cq.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,22 @@ static void mlx5_handle_error_cqe(struct mlx5_ib_dev *dev,
330330
dump_cqe(dev, cqe);
331331
}
332332

333+
static void handle_atomics(struct mlx5_ib_qp *qp, struct mlx5_cqe64 *cqe64,
334+
u16 tail, u16 head)
335+
{
336+
u16 idx;
337+
338+
do {
339+
idx = tail & (qp->sq.wqe_cnt - 1);
340+
if (idx == head)
341+
break;
342+
343+
tail = qp->sq.w_list[idx].next;
344+
} while (1);
345+
tail = qp->sq.w_list[idx].next;
346+
qp->sq.last_poll = tail;
347+
}
348+
333349
static void free_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf)
334350
{
335351
mlx5_frag_buf_free(dev->mdev, &buf->frag_buf);
@@ -368,7 +384,7 @@ static void get_sig_err_item(struct mlx5_sig_err_cqe *cqe,
368384
}
369385

370386
static void sw_comp(struct mlx5_ib_qp *qp, int num_entries, struct ib_wc *wc,
371-
int *npolled, int is_send)
387+
int *npolled, bool is_send)
372388
{
373389
struct mlx5_ib_wq *wq;
374390
unsigned int cur;
@@ -383,10 +399,16 @@ static void sw_comp(struct mlx5_ib_qp *qp, int num_entries, struct ib_wc *wc,
383399
return;
384400

385401
for (i = 0; i < cur && np < num_entries; i++) {
386-
wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
402+
unsigned int idx;
403+
404+
idx = (is_send) ? wq->last_poll : wq->tail;
405+
idx &= (wq->wqe_cnt - 1);
406+
wc->wr_id = wq->wrid[idx];
387407
wc->status = IB_WC_WR_FLUSH_ERR;
388408
wc->vendor_err = MLX5_CQE_SYNDROME_WR_FLUSH_ERR;
389409
wq->tail++;
410+
if (is_send)
411+
wq->last_poll = wq->w_list[idx].next;
390412
np++;
391413
wc->qp = &qp->ibqp;
392414
wc++;
@@ -473,6 +495,7 @@ static int mlx5_poll_one(struct mlx5_ib_cq *cq,
473495
wqe_ctr = be16_to_cpu(cqe64->wqe_counter);
474496
idx = wqe_ctr & (wq->wqe_cnt - 1);
475497
handle_good_req(wc, cqe64, wq, idx);
498+
handle_atomics(*cur_qp, cqe64, wq->last_poll, idx);
476499
wc->wr_id = wq->wrid[idx];
477500
wq->tail = wq->wqe_head[idx] + 1;
478501
wc->status = IB_WC_SUCCESS;

drivers/infiniband/hw/mlx5/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5722,9 +5722,10 @@ mlx5_ib_counter_alloc_stats(struct rdma_counter *counter)
57225722
const struct mlx5_ib_counters *cnts =
57235723
get_counters(dev, counter->port - 1);
57245724

5725-
/* Q counters are in the beginning of all counters */
57265725
return rdma_alloc_hw_stats_struct(cnts->names,
5727-
cnts->num_q_counters,
5726+
cnts->num_q_counters +
5727+
cnts->num_cong_counters +
5728+
cnts->num_ext_ppcnt_counters,
57285729
RDMA_HW_STATS_DEFAULT_LIFESPAN);
57295730
}
57305731

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ struct mlx5_ib_wq {
288288
unsigned head;
289289
unsigned tail;
290290
u16 cur_post;
291+
u16 last_poll;
291292
void *cur_edge;
292293
};
293294

0 commit comments

Comments
 (0)