From: "Zhu, Lingshan" <lingshan.zhu@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
"Huang Rui" <ray.huang@amd.com>
Cc: Alexander.Deucher@amd.com, felix.kuehling@amd.com,
amd-gfx@lists.freedesktop.org, "Khatri,
Sunil" <Sunil.Khatri@amd.com>
Subject: Re: [PATCH 01/10] drm/amdgpu: introduce amdgpu_lookup_queue_by_doorbell
Date: Tue, 22 Sep 2026 17:00:05 +0800 [thread overview]
Message-ID: <02168e96-1c44-4aaa-bde4-474c8264a3c7@amd.com> (raw)
In-Reply-To: <b277046c-a13b-4d47-a7fe-55e18a720e20@amd.com>
[-- Attachment #1: Type: text/plain, Size: 2713 bytes --]
On 9/22/2026 4:45 PM, Christian König wrote:
> On 9/22/26 10:39, Zhu, Lingshan wrote:
>> On 9/22/2026 4:04 PM, Christian König wrote:
>>
>>> On 9/22/26 09:55, Huang Rui wrote:
>>> ...
>>>>> As far as I can see we have solved the problems at hand and the rules how to handle the user queues should be pretty clear by now.
>>>>>
>>>> Assuming every kref_get() has a matching kref_put(), and the queue object
>>>> itself does not participate in a circular ownership chain, I don't
>>>> immediately see how taking a temporary queue reference would cause
>>>> correctness issues.
>>> The reference on the user queue object is meant to keep it alive for the duration of IOCTLs, e.g. prevent concurrent destruction from the close IOCTL.
>> why only IOCTL???? Since the kref has been embedded in the struct user queue, it should keep the queue alive during ANY OPERATIONS, Not only IOCTL.
>> Or it will race with the destruction callback in kref_put, and causing UAF problems.
>>
>> Do you see any kernel documents says that kref should only be used in ioctl contexts?
>> We just cycle over the same questions multiple times now. To limit the reference count to the IOCTL is a design decision I made.
> We just cycle over the same questions multiple times now. To limit the reference count to the IOCTL is a design decision I made.
>
> I tried to explain the rational behind that design decision multiple times now but it obviously doesn't seem to be understood.
>
> So to stop wasting my time I'm stopping to reply to this any further.
>
> This patch set is rejected.
This design is wrong, see kernel documents core-api/kref.rst:
krefs allow you to add reference counters to your objects. If you
have objects that are used in multiple places and passed around, and
you don't have refcounts, your code is almost certainly broken. If
you want refcounts, krefs are the way to go.
>
> Regards,
> Christian.
>
>>> It CAN'T be used to grab references from either atomic, interrupt or worker context since then you can't drop the reference any more without risking destruction from non IOCTL context which in turn causes tons of lifetime problems.
>>>
>>> This is just standard refcounting rules to keep objects alive during an IOCTL.
>> Where do you see such standard? It is just a atomic number, not a lock.
>>>> Could you please point us to the historical issue or the corresponding
>>>> commits that led to removing this approach previously?
>>> See Sunils original approach, he made exactly the same mistake and I already had to fix that back then.
>>>
>>> I don't remember if it was actually committed or if we only discussed that on the mailing list.
>>>
>>> Regards,
>>> Christian.
>>>
>>>> Thanks,
>>>> Ray
[-- Attachment #2: Type: text/html, Size: 4486 bytes --]
next prev parent reply other threads:[~2026-09-22 9:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 9:53 [PATCH 00/10] drm/amdgpu: secure userq lifecycle by its kref Zhu Lingshan
2026-08-28 9:53 ` [PATCH 01/10] drm/amdgpu: introduce amdgpu_lookup_queue_by_doorbell Zhu Lingshan
2026-08-28 13:08 ` Christian König
2026-08-28 15:59 ` Zhu, Lingshan
2026-08-31 8:21 ` Christian König
2026-09-01 8:50 ` Zhu, Lingshan
2026-09-22 6:08 ` Zhu, Lingshan
2026-09-22 7:35 ` Christian König
2026-09-22 7:51 ` Zhu, Lingshan
2026-09-22 7:55 ` Huang Rui
2026-09-22 8:04 ` Christian König
2026-09-22 8:39 ` Zhu, Lingshan
2026-09-22 8:45 ` Christian König
2026-09-22 9:00 ` Zhu, Lingshan [this message]
2026-08-28 9:53 ` [PATCH 02/10] drm/amdgpu: keep the userq manager alive as long as its queues Zhu Lingshan
2026-08-28 13:09 ` Christian König
2026-08-28 15:59 ` Zhu, Lingshan
2026-08-28 16:26 ` Christian König
2026-09-01 3:06 ` Zhu, Lingshan
2026-08-28 9:53 ` [PATCH 03/10] drm/amdgpu/gfx11: hold userq refs in private fault worker Zhu Lingshan
2026-08-28 13:11 ` Christian König
2026-08-28 15:59 ` Zhu, Lingshan
2026-08-28 9:53 ` [PATCH 04/10] drm/amdgpu/gfx12: " Zhu Lingshan
2026-08-28 9:53 ` [PATCH 05/10] drm/amdgpu: implement asynchronous userq destruction routine Zhu Lingshan
2026-08-28 9:53 ` [PATCH 06/10] drm/amdgpu: hold userq kref in MES reset Zhu Lingshan
2026-08-28 9:53 ` [PATCH 07/10] drm/amdgpu: hold userq kref during isolation scheduling Zhu Lingshan
2026-08-28 9:53 ` [PATCH 08/10] drm/amdgpu: hold userq kref during suspend and resume Zhu Lingshan
2026-08-28 9:53 ` [PATCH 09/10] drm/amdgpu: free userq by kref_put when fails to create Zhu Lingshan
2026-08-28 9:53 ` [PATCH 10/10] drm/amdgpu: take queue kref in userq_create to avoid UAF Zhu Lingshan
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=02168e96-1c44-4aaa-bde4-474c8264a3c7@amd.com \
--to=lingshan.zhu@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Sunil.Khatri@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=felix.kuehling@amd.com \
--cc=ray.huang@amd.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.