public inbox for amd-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang@amd.com>
To: "Koenig, Christian" <Christian.Koenig@amd.com>
Cc: "StDenis, Tom" <Tom.StDenis@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 1/2] drm/ttm: set ttm_buffer_object pointer as null after it's freed
Date: Mon, 10 Sep 2018 19:58:27 +0800	[thread overview]
Message-ID: <20180910115826.GA10993@hr-amur2> (raw)
In-Reply-To: <a8e4bd5e-2e2f-7158-9131-b63757a49c4e@amd.com>

On Mon, Sep 10, 2018 at 05:25:48PM +0800, Koenig, Christian wrote:
> Am 10.09.2018 um 11:23 schrieb Huang Rui:
> > On Mon, Sep 10, 2018 at 11:00:04AM +0200, Christian König wrote:
> >> Hi Ray,
> >>
> >> well those patches doesn't make sense, the pointer is only local to
> >> the function.
> > You're right.
> > I narrowed it with gdb dump from ttm_bo_bulk_move_lru_tail+0x2b, the
> > use-after-free should be in below codes:
> >
> > man = &bulk->tt[i].first->bdev->man[TTM_PL_TT];
> > ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false);
> >
> > Is there a case, when orignal bo is destroyed in the bulk pos, but it
> > doesn't update pos->first pointer, then we still use it during the bulk
> > moving?
> 
> Only when a per VM BO is freed or the VM destroyed.
> 
> The first case should now be handled by "drm/amdgpu: set bulk_moveable 
> to false when a per VM is released" and when we use a destroyed VM we 
> would see other problems as well.

When a VM instance is teared down, all BOs which belong to that VM should
be removed from LRU list. How can we use a destroyed VM when we submmit a
command? You know, we do the bulk moving at the last step of submission.

> 
> BTW: Just pushed this commit to the repository, should show up any second.

I see, thanks.

Thanks,
Ray

> 
> Christian.
> 
> >
> > Thanks,
> > Ray
> >
> >> Regards,
> >> Christian.
> >>
> >> Am 10.09.2018 um 10:57 schrieb Huang Rui:
> >>> It avoids to be refered again after freed.
> >>>
> >>> Signed-off-by: Huang Rui <ray.huang@amd.com>
> >>> Cc: Christian König <christian.koenig@amd.com>
> >>> Cc: Tom StDenis <Tom.StDenis@amd.com>
> >>> ---
> >>>   drivers/gpu/drm/ttm/ttm_bo.c | 1 +
> >>>   1 file changed, 1 insertion(+)
> >>>
> >>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> >>> index 138c989..d3ef5f8 100644
> >>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> >>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> >>> @@ -54,6 +54,7 @@ static struct attribute ttm_bo_count = {
> >>>   static void ttm_bo_default_destroy(struct ttm_buffer_object *bo)
> >>>   {
> >>>   	kfree(bo);
> >>> +	bo = NULL;
> >>>   }
> >>>   static inline int ttm_mem_type_from_place(const struct ttm_place *place,
> >> _______________________________________________
> >> amd-gfx mailing list
> >> amd-gfx@lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-09-10 11:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10  8:57 [PATCH 1/2] drm/ttm: set ttm_buffer_object pointer as null after it's freed Huang Rui
     [not found] ` <1536569876-27262-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2018-09-10  8:57   ` [PATCH 2/2] drm/amdgpu: set tbo pointer as null after amdgpu bo is freed Huang Rui
2018-09-10  9:00   ` [PATCH 1/2] drm/ttm: set ttm_buffer_object pointer as null after it's freed Christian König
     [not found]     ` <d40314d2-f1c4-b353-bda6-50aed5dda8db-5C7GfCeVMHo@public.gmane.org>
2018-09-10  9:23       ` Huang Rui
2018-09-10  9:25         ` Christian König
2018-09-10 11:58           ` Huang Rui [this message]
2018-09-10 12:05           ` Huang Rui
2018-09-10 12:49             ` Christian König
     [not found]               ` <746c5afd-9264-7dfa-4e3c-425ea82453ff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-10 12:59                 ` Tom St Denis
     [not found]                   ` <382aab77-b9e2-1d18-ecd8-cd763227e5d0-5C7GfCeVMHo@public.gmane.org>
2018-09-10 13:04                     ` Christian König
     [not found]                       ` <c26b96d6-a9b2-8609-4779-bf1f25402fe7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-10 13:05                         ` Tom St Denis
     [not found]                           ` <1e1de90f-dc8c-4395-2375-3351f06d80b4-5C7GfCeVMHo@public.gmane.org>
2018-09-10 13:10                             ` Christian König
     [not found]                               ` <6d66a7c9-5904-2b23-4a65-f4995753009d-5C7GfCeVMHo@public.gmane.org>
2018-09-11  7:34                                 ` Huang Rui

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=20180910115826.GA10993@hr-amur2 \
    --to=ray.huang@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Tom.StDenis@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    /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