From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
Maor Gottlieb <maorg@nvidia.com>, <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH rdma-rc 5/5] RDMA/ucma: Fix memory leak of connection request
Date: Mon, 14 Dec 2020 11:34:11 -0400 [thread overview]
Message-ID: <20201214153411.GT552508@nvidia.com> (raw)
In-Reply-To: <20201213132940.345554-6-leon@kernel.org>
On Sun, Dec 13, 2020 at 03:29:40PM +0200, Leon Romanovsky wrote:
> From: Maor Gottlieb <maorg@nvidia.com>
>
> Add missing call to xa_erase when destroy connection request.
> It fixes the below memory leak.
>
> unreferenced object 0xffff88812a340490 (size 576):
> comm “kworker/5:0”, pid 96291, jiffies 4296565270 (age 1835.596s)
> hex dump (first 32 bytes):
> 00 20 03 00 00 00 00 00 00 00 00 00 00 00 00 00 . …………..
> a0 d3 1a a0 ff ff ff ff a8 04 34 2a 81 88 ff ff ……….4*….
> backtrace:
> [<0000000059399d4c>] xas_alloc+0x94/0xb0
> [<00000000d855673c>] xas_create+0x1f4/0×4c0
> [<00000000336166d1>] xas_store+0x52/0×5e0
> [<000000006b811da0>] __xa_alloc+0xab/0×140
> [<00000000cf0e9936>] ucma_alloc_ctx+0x197/0×1f0 [rdma_ucm]
> [<000000008f99b6bb>] ucma_event_handler+0x17b/0×2e0 [rdma_ucm]
> [<000000000a07fc34>] cma_cm_event_handler+0x6f/0×390 [rdma_cm]
> [<00000000fe05d574>] cma_ib_req_handler+0x1163/0×2370 [rdma_cm]
> [<000000004516baf4>] cm_work_handler+0xeda/0×2340 [ib_cm]
> [<000000008a83945b>] process_one_work+0x27c/0×610
> [<00000000b71b71e2>] worker_thread+0x2d/0×3c0
> [<00000000caab54ff>] kthread+0x125/0×140
> [<000000004303d699>] ret_from_fork+0x1f/0×30
>
> Fixes: a1d33b70dbbc ("RDMA/ucma: Rework how new connections are passed through event delivery")
> Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> drivers/infiniband/core/ucma.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
> index 7dab9a27a145..b0b9ea90a27d 100644
> +++ b/drivers/infiniband/core/ucma.c
> @@ -549,8 +549,10 @@ static int ucma_free_ctx(struct ucma_context *ctx)
> list_for_each_entry_safe(uevent, tmp, &list, list) {
> list_del(&uevent->list);
> if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST &&
> - uevent->conn_req_ctx != ctx)
> + uevent->conn_req_ctx != ctx) {
> + xa_erase(&ctx_table, uevent->conn_req_ctx->id);
> __destroy_id(uevent->conn_req_ctx);
Oooh, yes this is wrong, but this fix isn't right.
At this point ucma_finish_ctx() has been called so this must be
careful to avoid racing with parallel access from the FD side.
Actually all this destroy stuff still looks subtly wrong, sigh. Let me
try again.
Jason
next prev parent reply other threads:[~2020-12-14 15:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-13 13:29 [PATCH rdma-rc 0/5] Fixes to v5.10 Leon Romanovsky
2020-12-13 13:29 ` [PATCH rdma-rc 1/5] RDMA/mlx5: Fix MR cache memory leak Leon Romanovsky
2020-12-13 13:29 ` [PATCH rdma-rc 2/5] IB/umad: Return EIO in case of when device disassociated Leon Romanovsky
2020-12-13 13:29 ` [PATCH rdma-rc 3/5] IB/umad: Return EPOLLERR " Leon Romanovsky
2021-01-12 19:25 ` Jason Gunthorpe
2020-12-13 13:29 ` [PATCH rdma-rc 4/5] RDMA/cma: Don't overwrite sgid_attr after device is released Leon Romanovsky
2020-12-14 19:26 ` Jason Gunthorpe
2020-12-15 5:23 ` Leon Romanovsky
2020-12-13 13:29 ` [PATCH rdma-rc 5/5] RDMA/ucma: Fix memory leak of connection request Leon Romanovsky
2020-12-14 15:34 ` Jason Gunthorpe [this message]
2020-12-14 19:27 ` [PATCH rdma-rc 0/5] Fixes to v5.10 Jason Gunthorpe
2020-12-15 5:25 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201214153411.GT552508@nvidia.com \
--to=jgg@nvidia.com \
--cc=dledford@redhat.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.