From: "Christian König" <christian.koenig@amd.com>
To: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>,
Alex Deucher <alexander.deucher@amd.com>,
Xinhui.Pan@amd.com, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] drm/radeon: Initialize fences array entries in radeon_sa_bo_next_hole
Date: Wed, 8 Jun 2022 10:35:13 +0200 [thread overview]
Message-ID: <b2bfdb5e-25d7-22d8-1788-ba34256e7664@amd.com> (raw)
In-Reply-To: <20220607151933.32850-1-xiaohuizhang@ruc.edu.cn>
Am 07.06.22 um 17:19 schrieb Xiaohui Zhang:
> Similar to the handling of amdgpu_sa_bo_next_hole in commit 6a15f3ff19a8
> ("drm/amdgpu: Initialize fences array entries in amdgpu_sa_bo_next_hole"),
> we thought a patch might be needed here as well.
>
> The entries were only initialized once in radeon_sa_bo_new. If a fence
> wasn't signalled yet in the first radeon_sa_bo_next_hole call, but then
> got signalled before a later radeon_sa_bo_next_hole call, it could
> destroy the fence but leave its pointer in the array, resulting in
> use-after-free in radeon_sa_bo_new.
I would rather like to see the sub allocator moved into a common drm helper.
Regards,
Christian.
>
> Signed-off-by: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>
> ---
> drivers/gpu/drm/radeon/radeon_sa.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c
> index 310c322c7112..0981948bd9ed 100644
> --- a/drivers/gpu/drm/radeon/radeon_sa.c
> +++ b/drivers/gpu/drm/radeon/radeon_sa.c
> @@ -267,6 +267,8 @@ static bool radeon_sa_bo_next_hole(struct radeon_sa_manager *sa_manager,
> for (i = 0; i < RADEON_NUM_RINGS; ++i) {
> struct radeon_sa_bo *sa_bo;
>
> + fences[i] = NULL;
> +
> if (list_empty(&sa_manager->flist[i])) {
> continue;
> }
> @@ -332,10 +334,8 @@ int radeon_sa_bo_new(struct radeon_device *rdev,
>
> spin_lock(&sa_manager->wq.lock);
> do {
> - for (i = 0; i < RADEON_NUM_RINGS; ++i) {
> - fences[i] = NULL;
> + for (i = 0; i < RADEON_NUM_RINGS; ++i)
> tries[i] = 0;
> - }
>
> do {
> radeon_sa_bo_try_free(sa_manager);
prev parent reply other threads:[~2022-06-08 9:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 15:19 Xiaohui Zhang
2022-06-07 18:36 ` Alex Deucher
2022-06-08 8:35 ` Christian König [this message]
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=b2bfdb5e-25d7-22d8-1788-ba34256e7664@amd.com \
--to=christian.koenig@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiaohuizhang@ruc.edu.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®