Skip to content

Commit 8fea9f8

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: "This includes a fix for a significant security miss in checking the RDMA_NLDEV_CMD_SYS_SET operation. Summary: - UAF in SRP - Error unwind failure in siw connection management - Missing error checks - NULL/ERR_PTR confusion in erdma - Possible string truncation in CMA configfs and mlx4 - Data ordering issue in bnxt_re - Missing stats decrement on object destroy in bnxt_re - Mlx5 bugs in this merge window: * Incorrect access_flag in the new mkey cache * Missing unlock on error in flow steering * lockdep possible deadlock on new mkey cache destruction (Plus a fix for this too) - Don't leak kernel stack memory to userspace in the CM - Missing permission validation for RDMA_NLDEV_CMD_SYS_SET" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/core: Require admin capabilities to set system parameters RDMA/mlx5: Remove not-used cache disable flag RDMA/cma: Initialize ib_sa_multicast structure to 0 when join RDMA/mlx5: Fix mkey cache possible deadlock on cleanup RDMA/mlx5: Fix NULL string error RDMA/mlx5: Fix mutex unlocking on error flow for steering anchor creation RDMA/mlx5: Fix assigning access flags to cache mkeys IB/mlx4: Fix the size of a buffer in add_port_entries() RDMA/bnxt_re: Decrement resource stats correctly RDMA/bnxt_re: Fix the handling of control path response data RDMA/cma: Fix truncation compilation warning in make_cma_ports RDMA/erdma: Fix NULL pointer access in regmr_cmd RDMA/erdma: Fix error code in erdma_create_scatter_mtt() RDMA/uverbs: Fix typo of sizeof argument RDMA/cxgb4: Check skb value for failure to allocate RDMA/siw: Fix connection failure handling RDMA/srp: Do not call scsi_done() from srp_abort()
2 parents 8271407 + c38d23a commit 8fea9f8

File tree

14 files changed

+54
-30
lines changed

14 files changed

+54
-30
lines changed

drivers/infiniband/core/cma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4968,7 +4968,7 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
49684968
int err = 0;
49694969
struct sockaddr *addr = (struct sockaddr *)&mc->addr;
49704970
struct net_device *ndev = NULL;
4971-
struct ib_sa_multicast ib;
4971+
struct ib_sa_multicast ib = {};
49724972
enum ib_gid_type gid_type;
49734973
bool send_only;
49744974

drivers/infiniband/core/cma_configfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group,
217217
return -ENOMEM;
218218

219219
for (i = 0; i < ports_num; i++) {
220-
char port_str[10];
220+
char port_str[11];
221221

222222
ports[i].port_num = i + 1;
223223
snprintf(port_str, sizeof(port_str), "%u", i + 1);

drivers/infiniband/core/nldev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,7 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
25292529
},
25302530
[RDMA_NLDEV_CMD_SYS_SET] = {
25312531
.doit = nldev_set_sys_set_doit,
2532+
.flags = RDMA_NL_ADMIN_PERM,
25322533
},
25332534
[RDMA_NLDEV_CMD_STAT_SET] = {
25342535
.doit = nldev_stat_set_doit,

drivers/infiniband/core/uverbs_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static ssize_t verify_hdr(struct ib_uverbs_cmd_hdr *hdr,
546546
if (hdr->in_words * 4 != count)
547547
return -EINVAL;
548548

549-
if (count < method_elm->req_size + sizeof(hdr)) {
549+
if (count < method_elm->req_size + sizeof(*hdr)) {
550550
/*
551551
* rdma-core v18 and v19 have a bug where they send DESTROY_CQ
552552
* with a 16 byte write instead of 24. Old kernels didn't

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,10 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
910910
list_del(&qp->list);
911911
mutex_unlock(&rdev->qp_lock);
912912
atomic_dec(&rdev->stats.res.qp_count);
913+
if (qp->qplib_qp.type == CMDQ_CREATE_QP_TYPE_RC)
914+
atomic_dec(&rdev->stats.res.rc_qp_count);
915+
else if (qp->qplib_qp.type == CMDQ_CREATE_QP_TYPE_UD)
916+
atomic_dec(&rdev->stats.res.ud_qp_count);
913917

914918
ib_umem_release(qp->rumem);
915919
ib_umem_release(qp->sumem);

drivers/infiniband/hw/bnxt_re/qplib_rcfw.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,6 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
665665
blocked = cookie & RCFW_CMD_IS_BLOCKING;
666666
cookie &= RCFW_MAX_COOKIE_VALUE;
667667
crsqe = &rcfw->crsqe_tbl[cookie];
668-
crsqe->is_in_used = false;
669668

670669
if (WARN_ONCE(test_bit(FIRMWARE_STALL_DETECTED,
671670
&rcfw->cmdq.flags),
@@ -681,8 +680,14 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
681680
atomic_dec(&rcfw->timeout_send);
682681

683682
if (crsqe->is_waiter_alive) {
684-
if (crsqe->resp)
683+
if (crsqe->resp) {
685684
memcpy(crsqe->resp, qp_event, sizeof(*qp_event));
685+
/* Insert write memory barrier to ensure that
686+
* response data is copied before clearing the
687+
* flags
688+
*/
689+
smp_wmb();
690+
}
686691
if (!blocked)
687692
wait_cmds++;
688693
}
@@ -694,6 +699,8 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
694699
if (!is_waiter_alive)
695700
crsqe->resp = NULL;
696701

702+
crsqe->is_in_used = false;
703+
697704
hwq->cons += req_size;
698705

699706
/* This is a case to handle below scenario -

drivers/infiniband/hw/cxgb4/cm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,9 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
19651965
int win;
19661966

19671967
skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
1968+
if (!skb)
1969+
return -ENOMEM;
1970+
19681971
req = __skb_put_zero(skb, sizeof(*req));
19691972
req->op_compl = htonl(WR_OP_V(FW_OFLD_CONNECTION_WR));
19701973
req->len16_pkd = htonl(FW_WR_LEN16_V(DIV_ROUND_UP(sizeof(*req), 16)));

drivers/infiniband/hw/erdma/erdma_verbs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ static int create_qp_cmd(struct erdma_ucontext *uctx, struct erdma_qp *qp)
133133
static int regmr_cmd(struct erdma_dev *dev, struct erdma_mr *mr)
134134
{
135135
struct erdma_pd *pd = to_epd(mr->ibmr.pd);
136+
u32 mtt_level = ERDMA_MR_MTT_0LEVEL;
136137
struct erdma_cmdq_reg_mr_req req;
137-
u32 mtt_level;
138138

139139
erdma_cmdq_build_reqhdr(&req.hdr, CMDQ_SUBMOD_RDMA, CMDQ_OPCODE_REG_MR);
140140

@@ -147,10 +147,9 @@ static int regmr_cmd(struct erdma_dev *dev, struct erdma_mr *mr)
147147
req.phy_addr[0] = sg_dma_address(mr->mem.mtt->sglist);
148148
mtt_level = mr->mem.mtt->level;
149149
}
150-
} else {
150+
} else if (mr->type != ERDMA_MR_TYPE_DMA) {
151151
memcpy(req.phy_addr, mr->mem.mtt->buf,
152152
MTT_SIZE(mr->mem.page_cnt));
153-
mtt_level = ERDMA_MR_MTT_0LEVEL;
154153
}
155154

156155
req.cfg0 = FIELD_PREP(ERDMA_CMD_MR_VALID_MASK, mr->valid) |
@@ -655,7 +654,7 @@ static struct erdma_mtt *erdma_create_scatter_mtt(struct erdma_dev *dev,
655654

656655
mtt = kzalloc(sizeof(*mtt), GFP_KERNEL);
657656
if (!mtt)
658-
return NULL;
657+
return ERR_PTR(-ENOMEM);
659658

660659
mtt->size = ALIGN(size, PAGE_SIZE);
661660
mtt->buf = vzalloc(mtt->size);

drivers/infiniband/hw/mlx4/sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void del_sysfs_port_mcg_attr(struct mlx4_ib_dev *device, int port_num,
223223
static int add_port_entries(struct mlx4_ib_dev *device, int port_num)
224224
{
225225
int i;
226-
char buff[11];
226+
char buff[12];
227227
struct mlx4_ib_iov_port *port = NULL;
228228
int ret = 0 ;
229229
struct ib_port_attr attr;

drivers/infiniband/hw/mlx5/fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2470,8 +2470,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_STEERING_ANCHOR_CREATE)(
24702470
mlx5_steering_anchor_destroy_res(ft_prio);
24712471
put_flow_table:
24722472
put_flow_table(dev, ft_prio, true);
2473-
mutex_unlock(&dev->flow_db->lock);
24742473
free_obj:
2474+
mutex_unlock(&dev->flow_db->lock);
24752475
kfree(obj);
24762476

24772477
return err;

0 commit comments

Comments
 (0)