All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Chen Jeffy <jeffy.chen@rock-chips.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andy Yan <andy.yan@rock-chips.com>,
	Jianqun Xu <jay.xu@rock-chips.com>,
	Maxime Ripard <mripard@kernel.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, David Airlie <airlied@linux.ie>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	linux-media@vger.kernel.org, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [Linaro-mm-sig] Re: [PATCH v2] drm/gem: Fix GEM handle release errors
Date: Tue, 9 Aug 2022 11:08:56 +0200	[thread overview]
Message-ID: <71e47fe6-440b-e9ea-cd66-8362c41428ca@amd.com> (raw)
In-Reply-To: <0e284f57-e03c-f128-f6e7-52a58edbcd54@amd.com>

Hi Jeffy,

Am 09.08.22 um 09:55 schrieb Christian König:
> [SNIP]
>>>
>>>>
>>>>
>>>> So we are allowing GEM object to have multiple handles, and GEM 
>>>> object could have at most one dma-buf, doesn't that means that 
>>>> dma-buf could map to multiple handles?
>>>
>>> No, at least not for the same GEM file private. That's the reason 
>>> why the rb is indexed by the dma_buf object and not the handle.
>>>
>>> In other words the rb is so that you have exactly one handle for 
>>> each dma_buf in each file private.
>>
>> I don't think so, because if user get multiple handles for the same 
>> GEM obj and use drm_gem_prime_handle_to_fd() for those handles
>
> Mhm, that works? This is illegal and should have been prevented somehow.

At least I see the problem now. I'm just not sure how to fix it.

Your v2 patch indeed prevents leakage of the drm_prime_member for the 
additional handles, but those shouldn't have been added in the first place.

The issue is that with this we make it unpredictable which handle is 
returned. E.g. if we have handle 2,5,7 it can be that because of 
re-balancing the tree sometimes 2 and sometimes 5 is returned.

That's not really a good idea and breaks a couple of assumptions as far 
as I know.

Ideas?

Thanks,
Christian.

WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Chen Jeffy <jeffy.chen@rock-chips.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
	dri-devel@lists.freedesktop.org,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Andy Yan <andy.yan@rock-chips.com>,
	Jianqun Xu <jay.xu@rock-chips.com>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	linux-media@vger.kernel.org
Subject: Re: [Linaro-mm-sig] Re: [PATCH v2] drm/gem: Fix GEM handle release errors
Date: Tue, 9 Aug 2022 11:08:56 +0200	[thread overview]
Message-ID: <71e47fe6-440b-e9ea-cd66-8362c41428ca@amd.com> (raw)
In-Reply-To: <0e284f57-e03c-f128-f6e7-52a58edbcd54@amd.com>

Hi Jeffy,

Am 09.08.22 um 09:55 schrieb Christian König:
> [SNIP]
>>>
>>>>
>>>>
>>>> So we are allowing GEM object to have multiple handles, and GEM 
>>>> object could have at most one dma-buf, doesn't that means that 
>>>> dma-buf could map to multiple handles?
>>>
>>> No, at least not for the same GEM file private. That's the reason 
>>> why the rb is indexed by the dma_buf object and not the handle.
>>>
>>> In other words the rb is so that you have exactly one handle for 
>>> each dma_buf in each file private.
>>
>> I don't think so, because if user get multiple handles for the same 
>> GEM obj and use drm_gem_prime_handle_to_fd() for those handles
>
> Mhm, that works? This is illegal and should have been prevented somehow.

At least I see the problem now. I'm just not sure how to fix it.

Your v2 patch indeed prevents leakage of the drm_prime_member for the 
additional handles, but those shouldn't have been added in the first place.

The issue is that with this we make it unpredictable which handle is 
returned. E.g. if we have handle 2,5,7 it can be that because of 
re-balancing the tree sometimes 2 and sometimes 5 is returned.

That's not really a good idea and breaks a couple of assumptions as far 
as I know.

Ideas?

Thanks,
Christian.

  parent reply	other threads:[~2022-08-09  9:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03  8:32 [PATCH v2] drm/gem: Fix GEM handle release errors Jeffy Chen
2022-08-03  8:32 ` Jeffy Chen
2022-08-07 16:52 ` Christian König
2022-08-07 16:52   ` Christian König
2022-08-08  3:51   ` Chen Jeffy
2022-08-08  3:51     ` Chen Jeffy
2022-08-08 18:03     ` Christian König
2022-08-08 18:03       ` Christian König
2022-08-09  1:28       ` Chen Jeffy
2022-08-09  1:28         ` Chen Jeffy
2022-08-09  7:55         ` Christian König
2022-08-09  7:55           ` Christian König
2022-08-09  8:54           ` Chen Jeffy
2022-08-09  8:54             ` Chen Jeffy
2022-08-09  9:08           ` Christian König [this message]
2022-08-09  9:08             ` [Linaro-mm-sig] " Christian König
2022-08-09 10:02             ` Chen Jeffy
2022-08-09 10:02               ` Chen Jeffy
2022-08-09 10:18               ` Christian König
2022-08-09 10:18                 ` Christian König
2022-08-10  4:16                 ` Chen Jeffy
2022-08-10  4:16                   ` Chen Jeffy
2022-08-10  9:16                   ` Christian König
2022-08-10  9:16                     ` Christian König

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=71e47fe6-440b-e9ea-cd66-8362c41428ca@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@linux.ie \
    --cc=andy.yan@rock-chips.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jay.xu@rock-chips.com \
    --cc=jeffy.chen@rock-chips.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tzimmermann@suse.de \
    /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.