Subject: CVE-2024-35831: io_uring: Fix release of pinned pages when __io_uaddr_map fails

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

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

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

io_uring: Fix release of pinned pages when __io_uaddr_map fails

Looking at the error path of __io_uaddr_map, if we fail after pinning
the pages for any reasons, ret will be set to -EINVAL and the error
handler won't properly release the pinned pages.

I didn't manage to trigger it without forcing a failure, but it can
happen in real life when memory is heavily fragmented.

The Linux kernel CVE team has assigned CVE-2024-35831 to this issue.

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

	Issue introduced in 6.6 with commit 223ef4743164 and fixed in 6.6.23 with commit 0b6f39c175ba
	Issue introduced in 6.6 with commit 223ef4743164 and fixed in 6.7.11 with commit 712e2c8415f5
	Issue introduced in 6.6 with commit 223ef4743164 and fixed in 6.8.2 with commit 4d376d7ad62b
	Issue introduced in 6.6 with commit 223ef4743164 and fixed in 6.9 with commit 67d1189d1095
	Issue introduced in 6.5.7 with commit 3f3164ce6396

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-2024-35831
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:
	io_uring/io_uring.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/0b6f39c175ba5f0ef72bdb3b9d2a06ad78621d62
	https://git.kernel.org/stable/c/712e2c8415f55a4a4ddaa98a430b87f624109f69
	https://git.kernel.org/stable/c/4d376d7ad62b6a8e8dfff56b559d9d275e5b9b3a
	https://git.kernel.org/stable/c/67d1189d1095d471ed7fa426c7e384a7140a5dd7