Subject: CVE-2023-21660: fbdev: flush deferred IO before closing

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

fbdev: flush deferred IO before closing

When framebuffer gets closed, the queued deferred IO gets cancelled. This
can cause some last display data to vanish. This is problematic for users
who send a still image to the framebuffer, then close the file: the image
may never appear.

To ensure none of display data get lost, flush the queued deferred IO
first before closing.

Another possible solution is to delete the cancel_delayed_work_sync()
instead. The difference is that the display may appear some time after
closing. However, the clearing of page mapping after this needs to be
removed too, because the page mapping is used by the deferred work. It is
not completely obvious whether it is okay to not clear the page mapping.
For a patch intended for stable trees, go with the simple and obvious
solution.

The Linux kernel CVE team has assigned CVE-2023-21660 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 2.6.22 with commit 60b59beafba8 and fixed in 6.1.75 with commit 81f444f22816
	Issue introduced in 2.6.22 with commit 60b59beafba8 and fixed in 6.6.14 with commit 2db6388d8a7f
	Issue introduced in 2.6.22 with commit 60b59beafba8 and fixed in 6.7.2 with commit 21ba4f2543bd
	Issue introduced in 2.6.22 with commit 60b59beafba8 and fixed in 6.8-rc1 with commit 33cd6ea9c067

Please see https://www.kernel.org or a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2023-21660
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/video/fbdev/core/fb_defio.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/81f444f22816
	https://git.kernel.org/stable/c/2db6388d8a7f
	https://git.kernel.org/stable/c/21ba4f2543bd
	https://git.kernel.org/stable/c/33cd6ea9c067