Re: [PATCH v3 1/4] fbdev: Prevent possible use-after-free in fb_release()

From: Javier Martinez Canillas
Date: Tue May 10 2022 - 05:06:25 EST


Hello Thomas,

On 5/10/22 10:50, Thomas Zimmermann wrote:

[snip]

>>> Drivers shouldn't really explicitly call this helper in my opinion.
>
> One more stupid question: does armada actually use
> drm_fbdev_fb_destroy()? It's supposed to be a callback for struct
> fb_ops. Armada uses it's own instance of fb_ops, which apparently
> doesn't contain fb_destroy. [1]
>

No stupid question at all. You are correct on this. So I guess we still
need this call in the drivers that don't provide a .fb_destroy() handler.

I see many options here:

1) Document in drm_fb_helper_alloc_fbi() that drivers only need to call
drm_fb_helper_fini() explicitly if they are not setting up a fbdev
with drm_fbdev_generic_setup(), otherwise is not needed.

2) Make drm_fbdev_fb_destroy() an exported symbol so drivers that have
custom fb_ops can use it.

3) Set .fb_destroy to drm_fbdev_fb_destroy() if isn't set by drivers when
they call drm_fb_helper_initial_config() or drm_fb_helper_fill_info().

I'm leaning towards option (3). Then the fb_info release will be automatic
whether drivers are using the generic setup or a custom one.

--
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat