Skip to content

Commit 1abd8a8

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: "Here are eight fairly small fixes collected over the last two weeks. Regression and crashing bug fixes: - mlx4/5: Fixes for issues found from various checkers - A resource tracking and uverbs regression in the core code - qedr: NULL pointer regression found during testing - rxe: Various small bugs" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: IB/rxe: Fix missing completion for mem_reg work requests RDMA/core: Save kernel caller name when creating CQ using ib_create_cq() IB/uverbs: Fix ordering of ucontext check in ib_uverbs_write IB/mlx4: Fix an error handling path in 'mlx4_ib_rereg_user_mr()' RDMA/qedr: Fix NULL pointer dereference when running over iWARP without RDMA-CM IB/mlx5: Fix return value check in flow_counters_set_data() IB/mlx5: Fix memory leak in mlx5_ib_create_flow IB/rxe: avoid double kfree skb
2 parents d8894a0 + 375dc53 commit 1abd8a8

File tree

7 files changed

+59
-33
lines changed

7 files changed

+59
-33
lines changed

drivers/infiniband/core/uverbs_main.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,10 +736,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
736736
if (ret)
737737
return ret;
738738

739-
if (!file->ucontext &&
740-
(command != IB_USER_VERBS_CMD_GET_CONTEXT || extended))
741-
return -EINVAL;
742-
743739
if (extended) {
744740
if (count < (sizeof(hdr) + sizeof(ex_hdr)))
745741
return -EINVAL;
@@ -759,6 +755,16 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
759755
goto out;
760756
}
761757

758+
/*
759+
* Must be after the ib_dev check, as once the RCU clears ib_dev ==
760+
* NULL means ucontext == NULL
761+
*/
762+
if (!file->ucontext &&
763+
(command != IB_USER_VERBS_CMD_GET_CONTEXT || extended)) {
764+
ret = -EINVAL;
765+
goto out;
766+
}
767+
762768
if (!verify_command_mask(ib_dev, command, extended)) {
763769
ret = -EOPNOTSUPP;
764770
goto out;

drivers/infiniband/core/verbs.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,11 +1562,12 @@ EXPORT_SYMBOL(ib_destroy_qp);
15621562

15631563
/* Completion queues */
15641564

1565-
struct ib_cq *ib_create_cq(struct ib_device *device,
1566-
ib_comp_handler comp_handler,
1567-
void (*event_handler)(struct ib_event *, void *),
1568-
void *cq_context,
1569-
const struct ib_cq_init_attr *cq_attr)
1565+
struct ib_cq *__ib_create_cq(struct ib_device *device,
1566+
ib_comp_handler comp_handler,
1567+
void (*event_handler)(struct ib_event *, void *),
1568+
void *cq_context,
1569+
const struct ib_cq_init_attr *cq_attr,
1570+
const char *caller)
15701571
{
15711572
struct ib_cq *cq;
15721573

@@ -1580,12 +1581,13 @@ struct ib_cq *ib_create_cq(struct ib_device *device,
15801581
cq->cq_context = cq_context;
15811582
atomic_set(&cq->usecnt, 0);
15821583
cq->res.type = RDMA_RESTRACK_CQ;
1584+
cq->res.kern_name = caller;
15831585
rdma_restrack_add(&cq->res);
15841586
}
15851587

15861588
return cq;
15871589
}
1588-
EXPORT_SYMBOL(ib_create_cq);
1590+
EXPORT_SYMBOL(__ib_create_cq);
15891591

15901592
int rdma_set_cq_moderation(struct ib_cq *cq, u16 cq_count, u16 cq_period)
15911593
{

drivers/infiniband/hw/mlx4/mr.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,11 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
486486
}
487487

488488
if (flags & IB_MR_REREG_ACCESS) {
489-
if (ib_access_writable(mr_access_flags) && !mmr->umem->writable)
490-
return -EPERM;
489+
if (ib_access_writable(mr_access_flags) &&
490+
!mmr->umem->writable) {
491+
err = -EPERM;
492+
goto release_mpt_entry;
493+
}
491494

492495
err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
493496
convert_access(mr_access_flags));

drivers/infiniband/hw/mlx5/main.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,8 +3199,8 @@ static int flow_counters_set_data(struct ib_counters *ibcounters,
31993199
if (!mcounters->hw_cntrs_hndl) {
32003200
mcounters->hw_cntrs_hndl = mlx5_fc_create(
32013201
to_mdev(ibcounters->device)->mdev, false);
3202-
if (!mcounters->hw_cntrs_hndl) {
3203-
ret = -ENOMEM;
3202+
if (IS_ERR(mcounters->hw_cntrs_hndl)) {
3203+
ret = PTR_ERR(mcounters->hw_cntrs_hndl);
32043204
goto free;
32053205
}
32063206
hw_hndl = true;
@@ -3546,29 +3546,35 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
35463546
return ERR_PTR(-ENOMEM);
35473547

35483548
err = ib_copy_from_udata(ucmd, udata, required_ucmd_sz);
3549-
if (err) {
3550-
kfree(ucmd);
3551-
return ERR_PTR(err);
3552-
}
3549+
if (err)
3550+
goto free_ucmd;
35533551
}
35543552

3555-
if (flow_attr->priority > MLX5_IB_FLOW_LAST_PRIO)
3556-
return ERR_PTR(-ENOMEM);
3553+
if (flow_attr->priority > MLX5_IB_FLOW_LAST_PRIO) {
3554+
err = -ENOMEM;
3555+
goto free_ucmd;
3556+
}
35573557

35583558
if (domain != IB_FLOW_DOMAIN_USER ||
35593559
flow_attr->port > dev->num_ports ||
35603560
(flow_attr->flags & ~(IB_FLOW_ATTR_FLAGS_DONT_TRAP |
3561-
IB_FLOW_ATTR_FLAGS_EGRESS)))
3562-
return ERR_PTR(-EINVAL);
3561+
IB_FLOW_ATTR_FLAGS_EGRESS))) {
3562+
err = -EINVAL;
3563+
goto free_ucmd;
3564+
}
35633565

35643566
if (is_egress &&
35653567
(flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT ||
3566-
flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT))
3567-
return ERR_PTR(-EINVAL);
3568+
flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT)) {
3569+
err = -EINVAL;
3570+
goto free_ucmd;
3571+
}
35683572

35693573
dst = kzalloc(sizeof(*dst), GFP_KERNEL);
3570-
if (!dst)
3571-
return ERR_PTR(-ENOMEM);
3574+
if (!dst) {
3575+
err = -ENOMEM;
3576+
goto free_ucmd;
3577+
}
35723578

35733579
mutex_lock(&dev->flow_db->lock);
35743580

@@ -3637,8 +3643,8 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
36373643
unlock:
36383644
mutex_unlock(&dev->flow_db->lock);
36393645
kfree(dst);
3646+
free_ucmd:
36403647
kfree(ucmd);
3641-
kfree(handler);
36423648
return ERR_PTR(err);
36433649
}
36443650

drivers/infiniband/hw/qedr/verbs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,9 @@ int qedr_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
19571957
}
19581958

19591959
if (attr_mask & (IB_QP_AV | IB_QP_PATH_MTU)) {
1960+
if (rdma_protocol_iwarp(&dev->ibdev, 1))
1961+
return -EINVAL;
1962+
19601963
if (attr_mask & IB_QP_PATH_MTU) {
19611964
if (attr->path_mtu < IB_MTU_256 ||
19621965
attr->path_mtu > IB_MTU_4096) {

drivers/infiniband/sw/rxe/rxe_req.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ int rxe_requester(void *arg)
645645
} else {
646646
goto exit;
647647
}
648+
if ((wqe->wr.send_flags & IB_SEND_SIGNALED) ||
649+
qp->sq_sig_type == IB_SIGNAL_ALL_WR)
650+
rxe_run_task(&qp->comp.task, 1);
648651
qp->req.wqe_index = next_index(qp->sq.queue,
649652
qp->req.wqe_index);
650653
goto next_wqe;
@@ -709,6 +712,7 @@ int rxe_requester(void *arg)
709712

710713
if (fill_packet(qp, wqe, &pkt, skb, payload)) {
711714
pr_debug("qp#%d Error during fill packet\n", qp_num(qp));
715+
kfree_skb(skb);
712716
goto err;
713717
}
714718

@@ -740,7 +744,6 @@ int rxe_requester(void *arg)
740744
goto next_wqe;
741745

742746
err:
743-
kfree_skb(skb);
744747
wqe->status = IB_WC_LOC_PROT_ERR;
745748
wqe->state = wqe_state_error;
746749
__rxe_do_task(&qp->comp.task);

include/rdma/ib_verbs.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3391,11 +3391,14 @@ int ib_process_cq_direct(struct ib_cq *cq, int budget);
33913391
*
33923392
* Users can examine the cq structure to determine the actual CQ size.
33933393
*/
3394-
struct ib_cq *ib_create_cq(struct ib_device *device,
3395-
ib_comp_handler comp_handler,
3396-
void (*event_handler)(struct ib_event *, void *),
3397-
void *cq_context,
3398-
const struct ib_cq_init_attr *cq_attr);
3394+
struct ib_cq *__ib_create_cq(struct ib_device *device,
3395+
ib_comp_handler comp_handler,
3396+
void (*event_handler)(struct ib_event *, void *),
3397+
void *cq_context,
3398+
const struct ib_cq_init_attr *cq_attr,
3399+
const char *caller);
3400+
#define ib_create_cq(device, cmp_hndlr, evt_hndlr, cq_ctxt, cq_attr) \
3401+
__ib_create_cq((device), (cmp_hndlr), (evt_hndlr), (cq_ctxt), (cq_attr), KBUILD_MODNAME)
33993402

34003403
/**
34013404
* ib_resize_cq - Modifies the capacity of the CQ.

0 commit comments

Comments
 (0)