Commit 89bfd401 authored by Daniel Vetter's avatar Daniel Vetter Committed by Javier Martinez Canillas

fbdev: Prevent possible use-after-free in fb_release()

Most fbdev drivers have issues with the fb_info lifetime, because call to
framebuffer_release() from their driver's .remove callback, rather than
doing from fbops.fb_destroy callback.

Doing that will destroy the fb_info too early, while references to it may
still exist, leading to a use-after-free error.

To prevent this, check the fb_info reference counter when attempting to
kfree the data structure in framebuffer_release(). That will leak it but
at least will prevent the mentioned error.
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220505220413.365977-1-javierm@redhat.com
parent 135332f3
...@@ -80,6 +80,10 @@ void framebuffer_release(struct fb_info *info) ...@@ -80,6 +80,10 @@ void framebuffer_release(struct fb_info *info)
{ {
if (!info) if (!info)
return; return;
if (WARN_ON(refcount_read(&info->count)))
return;
kfree(info->apertures); kfree(info->apertures);
kfree(info); kfree(info);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment