Patch "fbdev: Prevent possible use-after-free in fb_release()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

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

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     fbdev-prevent-possible-use-after-free-in-fb_release.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6482e9f6a97501252eac6bf4a54636431b05e80e
Author: Daniel Vetter <daniel.vetter@xxxxxxxx>
Date:   Fri May 6 00:04:13 2022 +0200

    fbdev: Prevent possible use-after-free in fb_release()
    
    [ Upstream commit 89bfd4017e58faaf70411555e7f508495114e90b ]
    
    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: Daniel Vetter <daniel.vetter@xxxxxxxxx>
    Signed-off-by: Javier Martinez Canillas <javierm@xxxxxxxxxx>
    Reviewed-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220505220413.365977-1-javierm@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c
index 65dae05fff8e..ce699396d6ba 100644
--- a/drivers/video/fbdev/core/fbsysfs.c
+++ b/drivers/video/fbdev/core/fbsysfs.c
@@ -80,6 +80,10 @@ void framebuffer_release(struct fb_info *info)
 {
 	if (!info)
 		return;
+
+	if (WARN_ON(refcount_read(&info->count)))
+		return;
+
 	kfree(info->apertures);
 	kfree(info);
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux