Commit f2e3644e authored by Xinghai Cen's avatar Xinghai Cen Committed by Junxian Huang
Browse files

Revert "RDMA/hns: Fix UAF for cq async event"

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBJ9LU


CVE: NA

----------------------------------------------------------------------

This reverts commit b92d44ad.

Fixes: b92d44ad ("RDMA/hns: Fix UAF for cq async event")
Signed-off-by: default avatarXinghai Cen <cenxinghai@h-partners.com>
parent 337c42b1
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
		return ret;
	}

	ret = xa_err(xa_store_irq(&cq_table->array, hr_cq->cqn, hr_cq, GFP_KERNEL));
	ret = xa_err(xa_store(&cq_table->array, hr_cq->cqn, hr_cq, GFP_KERNEL));
	if (ret) {
		ibdev_err(ibdev, "failed to xa_store CQ, ret = %d.\n", ret);
		goto err_put;
@@ -218,7 +218,7 @@ static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
	return 0;

err_xa:
	xa_erase_irq(&cq_table->array, hr_cq->cqn);
	xa_erase(&cq_table->array, hr_cq->cqn);
err_put:
	hns_roce_table_put(hr_dev, &cq_table->table, hr_cq->cqn);

@@ -240,7 +240,6 @@ static void free_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
	}

	xa_erase(&cq_table->array, hr_cq->cqn);
	xa_erase_irq(&cq_table->array, hr_cq->cqn);

	/* Waiting interrupt process procedure carried out */
	synchronize_irq(hr_dev->eq_table.eq[hr_cq->vector].irq);
@@ -552,6 +551,13 @@ void hns_roce_cq_event(struct hns_roce_dev *hr_dev, u32 cqn, int event_type)
	struct ib_event event;
	struct ib_cq *ibcq;

	hr_cq = xa_load(&hr_dev->cq_table.array,
			cqn & (hr_dev->caps.num_cqs - 1));
	if (!hr_cq) {
		dev_warn(dev, "async event for bogus CQ 0x%06x\n", cqn);
		return;
	}

	if (event_type != HNS_ROCE_EVENT_TYPE_CQ_ID_INVALID &&
	    event_type != HNS_ROCE_EVENT_TYPE_CQ_ACCESS_ERROR &&
	    event_type != HNS_ROCE_EVENT_TYPE_CQ_OVERFLOW) {
@@ -560,16 +566,7 @@ void hns_roce_cq_event(struct hns_roce_dev *hr_dev, u32 cqn, int event_type)
		return;
	}

	xa_lock(&hr_dev->cq_table.array);
	hr_cq = xa_load(&hr_dev->cq_table.array,
			cqn & (hr_dev->caps.num_cqs - 1));
	if (hr_cq)
	refcount_inc(&hr_cq->refcount);
	xa_unlock(&hr_dev->cq_table.array);
	if (!hr_cq) {
		dev_warn(dev, "async event for bogus CQ 0x%06x\n", cqn);
		return;
	}

	ibcq = &hr_cq->ib_cq;
	if (ibcq->event_handler) {