IB/rdmavt: Free kernel completion queue when done
Subsystems (2)
PATCH 1/1 IB/rdmavt: Free kernel completion queue when done
From: Kaike Wan <[email protected]>
When a kernel ULP requests the rdmavt to create a completion queue, it allocated the queue and set cq->kqueue to point to it. However, when the completion queue is destroyed, cq->queue is freed instead, leading to memory leak:
https://marc.info/?l=linux-rdma&m=158344182614924&w=2
unreferenced object 0xffffc90006639000 (size 12288):
comm "kworker/u128:0", pid 8, jiffies 4295777598 (age 589.085s)
hex dump (first 32 bytes):
4d 00 00 00 4d 00 00 00 00 c0 08 ac 8b 88 ff ff M...M...........
00 00 00 00 80 00 00 00 00 00 00 00 10 00 00 00 ................
backtrace:
[<0000000035a3d625>] __vmalloc_node_range+0x361/0x720
[<000000002942ce4f>] __vmalloc_node.constprop.30+0x63/0xb0
[<00000000f228f784>] rvt_create_cq+0x98a/0xd80 [rdmavt]
[<00000000b84aec66>] __ib_alloc_cq_user+0x281/0x1260 [ib_core]
[<00000000ef3764be>] nvme_rdma_cm_handler+0xdb7/0x1b80 [nvme_rdma]
[<00000000936b401c>] cma_cm_event_handler+0xb7/0x550 [rdma_cm]
[<00000000d9c40b7b>] addr_handler+0x195/0x310 [rdma_cm]
[<00000000c7398a03>] process_one_req+0xdd/0x600 [ib_core]
[<000000004d29675b>] process_one_work+0x920/0x1740
[<00000000efedcdb5>] worker_thread+0x87/0xb40
[<000000005688b340>] kthread+0x327/0x3f0
[<0000000043a168d6>] ret_from_fork+0x3a/0x50This patch fixes the issue by freeing cq->kqueue instead.
--- drivers/infiniband/sw/rdmavt/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rdmavt/cq.c +1 -1
@@ -327,7 +327,7 @@ void rvt_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)if (cq->ip)kref_put (&cq->ip->ref, rvt_release_mmap_info);else -vfree (cq->queue); +vfree (cq->kqueue); }/**
Jason Gunthorpe
AppliedQuoted 8 lines · Mike Marciniszyn
From: Kaike Wan <[email protected]>
When a kernel ULP requests the rdmavt to create a completion queue, it allocated the queue and set
cq->kqueueto point to it. However, when the completion queue is destroyed,cq->queueis freed instead, leading to memory leak:
Please always use lore.kernel.org for links to emails, I fixed it.
Quoted 28 lines
unreferenced object
0xffffc90006639000(size 12288):
comm "kworker/u128:0", pid 8, jiffies 4295777598 (age 589.085s)hex dump (first 32 bytes): 4d 00 00 00 4d 00 00 00 00 c0 08 ac 8b 88 ff ff M...M........... 00 00 00 00 80 00 00 00 00 00 00 00 10 00 00 00 ................ backtrace: [<0000000035a3d625>] __vmalloc_node_range+0x361/0x720 [<000000002942ce4f>] __vmalloc_node.constprop.30+0x63/0xb0 [<00000000f228f784>] rvt_create_cq+0x98a/0xd80 [rdmavt] [<00000000b84aec66>] __ib_alloc_cq_user+0x281/0x1260 [ib_core] [<00000000ef3764be>] nvme_rdma_cm_handler+0xdb7/0x1b80 [nvme_rdma] [<00000000936b401c>] cma_cm_event_handler+0xb7/0x550 [rdma_cm] [<00000000d9c40b7b>] addr_handler+0x195/0x310 [rdma_cm] [<00000000c7398a03>] process_one_req+0xdd/0x600 [ib_core] [<000000004d29675b>] process_one_work+0x920/0x1740 [<00000000efedcdb5>] worker_thread+0x87/0xb40 [<000000005688b340>] kthread+0x327/0x3f0 [<0000000043a168d6>] ret_from_fork+0x3a/0x50This patch fixes the issue by freeing
cq->kqueueinstead.Fixes 239b0e52d8aa ("IB/hfi1: Move rvt_cq_wc struct into uapi directory")Cc <[email protected]> # 5.4.xReported-by Yi Zhang <[email protected]>Reviewed-by Mike Marciniszyn <[email protected]>Reviewed-by Dennis Dalessandro <[email protected]>Signed-off-by Kaike Wan <[email protected]>Signed-off-by Dennis Dalessandro <[email protected]>
Quoted 3 lines
--
drivers/infiniband/sw/rdmavt/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to for-rc
Thanks,
Jason