Subject: CVE-2024-40902: jfs: xattr: fix buffer overflow for invalid xattr

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

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

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

jfs: xattr: fix buffer overflow for invalid xattr

When an xattr size is not what is expected, it is printed out to the
kernel log in hex format as a form of debugging.  But when that xattr
size is bigger than the expected size, printing it out can cause an
access off the end of the buffer.

Fix this all up by properly restricting the size of the debug hex dump
in the kernel log.

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

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

	Fixed in 4.19.317 with commit f0dedb5c511e
	Fixed in 5.4.279 with commit 1e84c9b18381
	Fixed in 5.10.221 with commit fc745f6e83cb
	Fixed in 5.15.162 with commit 480e5bc21f2c
	Fixed in 6.1.95 with commit 33aecc5799c9
	Fixed in 6.6.35 with commit 4598233d9748
	Fixed in 6.9.6 with commit b537cb2f4c4a
	Fixed in 6.10 with commit 7c55b78818cf

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-40902
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/jfs/xattr.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/f0dedb5c511ed82cbaff4997a8decf2351ba549f
	https://git.kernel.org/stable/c/1e84c9b1838152a87cf453270a5fa75c5037e83a
	https://git.kernel.org/stable/c/fc745f6e83cb650f9a5f2c864158e3a5ea76dad0
	https://git.kernel.org/stable/c/480e5bc21f2c42d90c2c16045d64d824dcdd5ec7
	https://git.kernel.org/stable/c/33aecc5799c93d3ee02f853cb94e201f9731f123
	https://git.kernel.org/stable/c/4598233d9748fe4db4e13b9f473588aa25e87d69
	https://git.kernel.org/stable/c/b537cb2f4c4a1357479716a9c339c0bda03d873f
	https://git.kernel.org/stable/c/7c55b78818cfb732680c4a72ab270cc2d2ee3d0f