Patch "fbdev: Fix invalid page access after closing deferred I/O devices" 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: Fix invalid page access after closing deferred I/O devices

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-fix-invalid-page-access-after-closing-deferred.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 00cfec7001b41fd83fb3736cd71f29d09329bae2
Author: Takashi Iwai <tiwai@xxxxxxx>
Date:   Sun Jan 29 09:28:56 2023 +0100

    fbdev: Fix invalid page access after closing deferred I/O devices
    
    [ Upstream commit 3efc61d95259956db25347e2a9562c3e54546e20 ]
    
    When a fbdev with deferred I/O is once opened and closed, the dirty
    pages still remain queued in the pageref list, and eventually later
    those may be processed in the delayed work.  This may lead to a
    corruption of pages, hitting an Oops.
    
    This patch makes sure to cancel the delayed work and clean up the
    pageref list at closing the device for addressing the bug.  A part of
    the cleanup code is factored out as a new helper function that is
    called from the common fb_release().
    
    Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@xxxxxxxxx>
    Cc: <stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
    Tested-by: Miko Larsson <mikoxyzzz@xxxxxxxxx>
    Fixes: 56c134f7f1b5 ("fbdev: Track deferred-I/O pages in pageref struct")
    Reviewed-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
    Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230129082856.22113-1-tiwai@xxxxxxx
    Stable-dep-of: 33cd6ea9c067 ("fbdev: flush deferred IO before closing")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
index 5faeca61d3dd..b3f41f432ec2 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c
@@ -292,7 +292,7 @@ void fb_deferred_io_open(struct fb_info *info,
 }
 EXPORT_SYMBOL_GPL(fb_deferred_io_open);
 
-void fb_deferred_io_cleanup(struct fb_info *info)
+void fb_deferred_io_release(struct fb_info *info)
 {
 	struct fb_deferred_io *fbdefio = info->fbdefio;
 	struct page *page;
@@ -306,6 +306,14 @@ void fb_deferred_io_cleanup(struct fb_info *info)
 		page = fb_deferred_io_page(info, i);
 		page->mapping = NULL;
 	}
+}
+EXPORT_SYMBOL_GPL(fb_deferred_io_release);
+
+void fb_deferred_io_cleanup(struct fb_info *info)
+{
+	struct fb_deferred_io *fbdefio = info->fbdefio;
+
+	fb_deferred_io_release(info);
 
 	kvfree(info->pagerefs);
 	mutex_destroy(&fbdefio->lock);
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 1b288a613a6e..ec7a883715e3 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1454,6 +1454,10 @@ __releases(&info->lock)
 	struct fb_info * const info = file->private_data;
 
 	lock_fb_info(info);
+#if IS_ENABLED(CONFIG_FB_DEFERRED_IO)
+	if (info->fbdefio)
+		fb_deferred_io_release(info);
+#endif
 	if (info->fbops->fb_release)
 		info->fbops->fb_release(info,1);
 	module_put(info->fbops->owner);
diff --git a/include/linux/fb.h b/include/linux/fb.h
index b322d30f6225..433cddf8442b 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -675,6 +675,7 @@ extern int  fb_deferred_io_init(struct fb_info *info);
 extern void fb_deferred_io_open(struct fb_info *info,
 				struct inode *inode,
 				struct file *file);
+extern void fb_deferred_io_release(struct fb_info *info);
 extern void fb_deferred_io_cleanup(struct fb_info *info);
 extern int fb_deferred_io_fsync(struct file *file, loff_t start,
 				loff_t end, int datasync);




[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