Subject: CVE-2021-47040: io_uring: fix overflows checks in provide buffers

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

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

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

io_uring: fix overflows checks in provide buffers

Colin reported before possible overflow and sign extension problems in
io_provide_buffers_prep(). As Linus pointed out previous attempt did nothing
useful, see d81269fecb8ce ("io_uring: fix provide_buffers sign extension").

Do that with help of check_<op>_overflow helpers. And fix struct
io_provide_buf::len type, as it doesn't make much sense to keep it
signed.

The Linux kernel CVE team has assigned CVE-2021-47040 to this issue.

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

	Issue introduced in 5.8 with commit efe68c1ca8f4 and fixed in 5.10.37 with commit cbbc13b115b8
	Issue introduced in 5.8 with commit efe68c1ca8f4 and fixed in 5.11.21 with commit 51bf90901952
	Issue introduced in 5.8 with commit efe68c1ca8f4 and fixed in 5.12.4 with commit 84b8c266c4bf
	Issue introduced in 5.8 with commit efe68c1ca8f4 and fixed in 5.13 with commit 38134ada0cee

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-2021-47040
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:
	fs/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/cbbc13b115b8f18e0a714d89f87fbdc499acfe2d
	https://git.kernel.org/stable/c/51bf90901952aaac564bbdb36b2b503050c53dd9
	https://git.kernel.org/stable/c/84b8c266c4bfe9ed5128e13253c388deb74b1b03
	https://git.kernel.org/stable/c/38134ada0ceea3e848fe993263c0ff6207fd46e7