Subject: CVE-2023-52731: fbdev: Fix invalid page access after closing deferred I/O devices

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

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

In the Linux kernel, the following vulnerability has been resolved:

fbdev: Fix invalid page access after closing deferred I/O devices

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().

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

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

	Issue introduced in 5.19 with commit 56c134f7f1b5 and fixed in 6.1.13 with commit f1d91f0e9d5a
	Issue introduced in 5.19 with commit 56c134f7f1b5 and fixed in 6.2 with commit 3efc61d95259

Please see https://www.kernel.org for 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-52731
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
	drivers/video/fbdev/core/fbmem.c
	include/linux/fb.h

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/87b9802ca824fcee7915e717e9a60471af62e8e9
	https://git.kernel.org/stable/c/f1d91f0e9d5a240a809698d7d9c5a538e7dcc149
	https://git.kernel.org/stable/c/3efc61d95259956db25347e2a9562c3e54546e20