AW: [PATCH] drm/fdinfo: Protect against driver unbind
Christian König
christian.koenig at amd.com
Wed Apr 23 12:57:16 UTC 2025
On 4/22/25 17:10, Tvrtko Ursulin wrote:
>
> On 22/04/2025 10:20, Koenig, Christian wrote:
>> [AMD Official Use Only - AMD Internal Distribution Only]
>>
>> Reviewed-by: Christian König <christian.koenig at amd.com>
>
> Thanks!
>
> I could also add:
>
> Fixes: 3f09a0cd4ea3 ("drm: Add common fdinfo helper")
> Cc: <stable at vger.kernel.org> # v6.5+
>
> With a disclaimer that the problem predates the common helper. Not sure if it is worth it for such an edge case.
>
> I was planning to merge to drm-misc-next, but if I add the stable tag it would be drm-misc-fixes right?
Yeah even without the CC:stable tag that is clearly something for the -fixes branch I would say.
Regards,
Christian.
>
> Regards,
>
> Tvrtko
>
>> ________________________________________
>> Von: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
>> Gesendet: Freitag, 18. April 2025 18:25
>> An: dri-devel at lists.freedesktop.org
>> Cc: kernel-dev at igalia.com; Tvrtko Ursulin; Koenig, Christian; Lucas De Marchi; Rodrigo Vivi; Umesh Nerlige Ramappa
>> Betreff: [PATCH] drm/fdinfo: Protect against driver unbind
>>
>> If we unbind a driver from the PCI device with an active DRM client,
>> subsequent read of the fdinfo data associated with the file descriptor in
>> question will not end well.
>>
>> Protect the path with a drm_dev_enter/exit() pair.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
>> Cc: Christian König <christian.koenig at amd.com>
>> Cc: Lucas De Marchi <lucas.demarchi at intel.com>
>> Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
>> Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
>> ---
>> drivers/gpu/drm/drm_file.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
>> index c299cd94d3f7..cf2463090d3a 100644
>> --- a/drivers/gpu/drm/drm_file.c
>> +++ b/drivers/gpu/drm/drm_file.c
>> @@ -964,6 +964,10 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
>> struct drm_file *file = f->private_data;
>> struct drm_device *dev = file->minor->dev;
>> struct drm_printer p = drm_seq_file_printer(m);
>> + int idx;
>> +
>> + if (!drm_dev_enter(dev, &idx))
>> + return;
>>
>> drm_printf(&p, "drm-driver:\t%s\n", dev->driver->name);
>> drm_printf(&p, "drm-client-id:\t%llu\n", file->client_id);
>> @@ -983,6 +987,8 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
>>
>> if (dev->driver->show_fdinfo)
>> dev->driver->show_fdinfo(&p, file);
>> +
>> + drm_dev_exit(idx);
>> }
>> EXPORT_SYMBOL(drm_show_fdinfo);
>>
>> --
>> 2.48.0
>>
>
More information about the dri-devel
mailing list