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

+94 -34
+3 -4
MAINTAINERS
··· 7579 7579 7580 7580 HISILICON ROCE DRIVER 7581 7581 M: Lijun Ou <oulijun@huawei.com> 7582 - M: Wei Hu(Xavier) <xavier.huwei@huawei.com> 7582 + M: Wei Hu(Xavier) <huwei87@hisilicon.com> 7583 + M: Weihang Li <liweihang@huawei.com> 7583 7584 L: linux-rdma@vger.kernel.org 7584 7585 S: Maintained 7585 7586 F: drivers/infiniband/hw/hns/ ··· 15422 15421 F: include/uapi/rdma/siw-abi.h 15423 15422 15424 15423 SOFT-ROCE DRIVER (rxe) 15425 - M: Moni Shoua <monis@mellanox.com> 15424 + M: Zhu Yanjun <yanjunz@mellanox.com> 15426 15425 L: linux-rdma@vger.kernel.org 15427 15426 S: Supported 15428 - W: https://github.com/SoftRoCE/rxe-dev/wiki/rxe-dev:-Home 15429 - Q: http://patchwork.kernel.org/project/linux-rdma/list/ 15430 15427 F: drivers/infiniband/sw/rxe/ 15431 15428 F: include/uapi/rdma/rdma_user_rxe.h 15432 15429
+3 -1
drivers/infiniband/core/device.c
··· 896 896 cdev->dev.parent = device->dev.parent; 897 897 rdma_init_coredev(cdev, device, read_pnet(&rnet->net)); 898 898 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; 900 902 901 903 ret = device_add(&cdev->dev); 902 904 if (ret)
+5 -1
drivers/infiniband/core/nldev.c
··· 918 918 919 919 nla_strlcpy(name, tb[RDMA_NLDEV_ATTR_DEV_NAME], 920 920 IB_DEVICE_NAME_MAX); 921 + if (strlen(name) == 0) { 922 + err = -EINVAL; 923 + goto done; 924 + } 921 925 err = ib_device_rename(device, name); 922 926 goto done; 923 927 } ··· 1518 1514 1519 1515 nla_strlcpy(ibdev_name, tb[RDMA_NLDEV_ATTR_DEV_NAME], 1520 1516 sizeof(ibdev_name)); 1521 - if (strchr(ibdev_name, '%')) 1517 + if (strchr(ibdev_name, '%') || strlen(ibdev_name) == 0) 1522 1518 return -EINVAL; 1523 1519 1524 1520 nla_strlcpy(type, tb[RDMA_NLDEV_ATTR_LINK_TYPE], sizeof(type));
+3 -8
drivers/infiniband/core/security.c
··· 349 349 else if (qp_pps) 350 350 new_pps->main.pkey_index = qp_pps->main.pkey_index; 351 351 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)) 353 355 new_pps->main.state = IB_PORT_PKEY_VALID; 354 - 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 356 362 357 if (qp_attr_mask & IB_QP_ALT_PATH) { 363 358 new_pps->alt.port_num = qp_attr->alt_port_num;
+1 -1
drivers/infiniband/core/umem_odp.c
··· 275 275 mmu_interval_notifier_remove(&umem_odp->notifier); 276 276 kvfree(umem_odp->dma_list); 277 277 kvfree(umem_odp->page_list); 278 - put_pid(umem_odp->tgid); 279 278 } 279 + put_pid(umem_odp->tgid); 280 280 kfree(umem_odp); 281 281 } 282 282 EXPORT_SYMBOL(ib_umem_odp_release);
+22 -11
drivers/infiniband/core/user_mad.c
··· 1129 1129 .llseek = no_llseek, 1130 1130 }; 1131 1131 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 + 1132 1146 static int ib_umad_get_nl_info(struct ib_device *ibdev, void *client_data, 1133 1147 struct ib_client_nl_info *res) 1134 1148 { 1135 - struct ib_umad_device *umad_dev = client_data; 1149 + struct ib_umad_port *port = get_port(ibdev, client_data, res->port); 1136 1150 1137 - if (!rdma_is_port_valid(ibdev, res->port)) 1138 - return -EINVAL; 1151 + if (IS_ERR(port)) 1152 + return PTR_ERR(port); 1139 1153 1140 1154 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; 1143 1156 return 0; 1144 1157 } 1145 1158 ··· 1167 1154 static int ib_issm_get_nl_info(struct ib_device *ibdev, void *client_data, 1168 1155 struct ib_client_nl_info *res) 1169 1156 { 1170 - struct ib_umad_device *umad_dev = 1171 - ib_get_client_data(ibdev, &umad_client); 1157 + struct ib_umad_port *port = get_port(ibdev, client_data, res->port); 1172 1158 1173 - if (!rdma_is_port_valid(ibdev, res->port)) 1174 - return -EINVAL; 1159 + if (IS_ERR(port)) 1160 + return PTR_ERR(port); 1175 1161 1176 1162 res->abi = IB_USER_MAD_ABI_VERSION; 1177 - res->cdev = &umad_dev->ports[res->port - rdma_start_port(ibdev)].sm_dev; 1178 - 1163 + res->cdev = &port->sm_dev; 1179 1164 return 0; 1180 1165 } 1181 1166
+22 -3
drivers/infiniband/hw/hfi1/user_sdma.c
··· 141 141 */ 142 142 xchg(&pq->state, SDMA_PKT_Q_DEFERRED); 143 143 if (list_empty(&pq->busy.list)) { 144 + pq->busy.lock = &sde->waitlock; 144 145 iowait_get_priority(&pq->busy); 145 146 iowait_queue(pkts_sent, &pq->busy, &sde->dmawait); 146 147 } ··· 156 155 { 157 156 struct hfi1_user_sdma_pkt_q *pq = 158 157 container_of(wait, struct hfi1_user_sdma_pkt_q, busy); 158 + pq->busy.lock = NULL; 159 159 xchg(&pq->state, SDMA_PKT_Q_ACTIVE); 160 160 wake_up(&wait->wait_dma); 161 161 }; ··· 258 256 return ret; 259 257 } 260 258 259 + static void flush_pq_iowait(struct hfi1_user_sdma_pkt_q *pq) 260 + { 261 + unsigned long flags; 262 + seqlock_t *lock = pq->busy.lock; 263 + 264 + if (!lock) 265 + return; 266 + write_seqlock_irqsave(lock, flags); 267 + if (!list_empty(&pq->busy.list)) { 268 + list_del_init(&pq->busy.list); 269 + pq->busy.lock = NULL; 270 + } 271 + write_sequnlock_irqrestore(lock, flags); 272 + } 273 + 261 274 int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd, 262 275 struct hfi1_ctxtdata *uctxt) 263 276 { ··· 298 281 kfree(pq->reqs); 299 282 kfree(pq->req_in_use); 300 283 kmem_cache_destroy(pq->txreq_cache); 284 + flush_pq_iowait(pq); 301 285 kfree(pq); 302 286 } else { 303 287 spin_unlock(&fd->pq_rcu_lock); ··· 605 587 if (ret < 0) { 606 588 if (ret != -EBUSY) 607 589 goto free_req; 608 - wait_event_interruptible_timeout( 590 + if (wait_event_interruptible_timeout( 609 591 pq->busy.wait_dma, 610 - (pq->state == SDMA_PKT_Q_ACTIVE), 592 + pq->state == SDMA_PKT_Q_ACTIVE, 611 593 msecs_to_jiffies( 612 - SDMA_IOWAIT_TIMEOUT)); 594 + SDMA_IOWAIT_TIMEOUT)) <= 0) 595 + flush_pq_iowait(pq); 613 596 } 614 597 } 615 598 *count += idx;
+25 -2
drivers/infiniband/hw/mlx5/cq.c
··· 330 330 dump_cqe(dev, cqe); 331 331 } 332 332 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 + 333 349 static void free_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf) 334 350 { 335 351 mlx5_frag_buf_free(dev->mdev, &buf->frag_buf); ··· 384 368 } 385 369 386 370 static void sw_comp(struct mlx5_ib_qp *qp, int num_entries, struct ib_wc *wc, 387 - int *npolled, int is_send) 371 + int *npolled, bool is_send) 388 372 { 389 373 struct mlx5_ib_wq *wq; 390 374 unsigned int cur; ··· 399 383 return; 400 384 401 385 for (i = 0; i < cur && np < num_entries; i++) { 402 - wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; 386 + unsigned int idx; 387 + 388 + idx = (is_send) ? wq->last_poll : wq->tail; 389 + idx &= (wq->wqe_cnt - 1); 390 + wc->wr_id = wq->wrid[idx]; 403 391 wc->status = IB_WC_WR_FLUSH_ERR; 404 392 wc->vendor_err = MLX5_CQE_SYNDROME_WR_FLUSH_ERR; 405 393 wq->tail++; 394 + if (is_send) 395 + wq->last_poll = wq->w_list[idx].next; 406 396 np++; 407 397 wc->qp = &qp->ibqp; 408 398 wc++; ··· 495 473 wqe_ctr = be16_to_cpu(cqe64->wqe_counter); 496 474 idx = wqe_ctr & (wq->wqe_cnt - 1); 497 475 handle_good_req(wc, cqe64, wq, idx); 476 + handle_atomics(*cur_qp, cqe64, wq->last_poll, idx); 498 477 wc->wr_id = wq->wrid[idx]; 499 478 wq->tail = wq->wqe_head[idx] + 1; 500 479 wc->status = IB_WC_SUCCESS;
+3 -2
drivers/infiniband/hw/mlx5/main.c
··· 5722 5722 const struct mlx5_ib_counters *cnts = 5723 5723 get_counters(dev, counter->port - 1); 5724 5724 5725 - /* Q counters are in the beginning of all counters */ 5726 5725 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, 5728 5729 RDMA_HW_STATS_DEFAULT_LIFESPAN); 5729 5730 } 5730 5731
+1
drivers/infiniband/hw/mlx5/mlx5_ib.h
··· 288 288 unsigned head; 289 289 unsigned tail; 290 290 u16 cur_post; 291 + u16 last_poll; 291 292 void *cur_edge; 292 293 }; 293 294
+5
drivers/infiniband/hw/mlx5/qp.c
··· 3775 3775 qp->sq.cur_post = 0; 3776 3776 if (qp->sq.wqe_cnt) 3777 3777 qp->sq.cur_edge = get_sq_edge(&qp->sq, 0); 3778 + qp->sq.last_poll = 0; 3778 3779 qp->db.db[MLX5_RCV_DBR] = 0; 3779 3780 qp->db.db[MLX5_SND_DBR] = 0; 3780 3781 } ··· 6204 6203 min_resp_len = offsetof(typeof(resp), reserved) + sizeof(resp.reserved); 6205 6204 if (udata->outlen && udata->outlen < min_resp_len) 6206 6205 return ERR_PTR(-EINVAL); 6206 + 6207 + if (!capable(CAP_SYS_RAWIO) && 6208 + init_attr->create_flags & IB_WQ_FLAGS_DELAY_DROP) 6209 + return ERR_PTR(-EPERM); 6207 6210 6208 6211 dev = to_mdev(pd->device); 6209 6212 switch (init_attr->wq_type) {
+1 -1
drivers/infiniband/sw/rdmavt/cq.c
··· 327 327 if (cq->ip) 328 328 kref_put(&cq->ip->ref, rvt_release_mmap_info); 329 329 else 330 - vfree(cq->queue); 330 + vfree(cq->kqueue); 331 331 } 332 332 333 333 /**