Subject: CVE-2024-44966: binfmt_flat: Fix corruption when not offsetting data start

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

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

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

binfmt_flat: Fix corruption when not offsetting data start

Commit 04d82a6d0881 ("binfmt_flat: allow not offsetting data start")
introduced a RISC-V specific variant of the FLAT format which does
not allocate any space for the (obsolete) array of shared library
pointers. However, it did not disable the code which initializes the
array, resulting in the corruption of sizeof(long) bytes before the DATA
segment, generally the end of the TEXT segment.

Introduce MAX_SHARED_LIBS_UPDATE which depends on the state of
CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET to guard the initialization of
the shared library pointer region so that it will only be initialized
if space is reserved for it.

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

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

	Issue introduced in 5.13 with commit 04d82a6d0881 and fixed in 5.15.165 with commit 3a684499261d
	Issue introduced in 5.13 with commit 04d82a6d0881 and fixed in 6.1.106 with commit af65d5383854
	Issue introduced in 5.13 with commit 04d82a6d0881 and fixed in 6.6.47 with commit 49df34d2b7da
	Issue introduced in 5.13 with commit 04d82a6d0881 and fixed in 6.10.6 with commit 9350ba06ee61
	Issue introduced in 5.13 with commit 04d82a6d0881 and fixed in 6.11 with commit 3eb3cd5992f7

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-44966
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/binfmt_flat.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/3a684499261d0f7ed5ee72793025c88c2276809c
	https://git.kernel.org/stable/c/af65d5383854cc3f172a7d0843b628758bf462c8
	https://git.kernel.org/stable/c/49df34d2b7da9e57c839555a2f7877291ce45ad1
	https://git.kernel.org/stable/c/9350ba06ee61db392c486716ac68ecc20e030f7c
	https://git.kernel.org/stable/c/3eb3cd5992f7a0c37edc8d05b4c38c98758d8671