Subject: CVE-2024-36975: KEYS: trusted: Do not use WARN when encode fails

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

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

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

KEYS: trusted: Do not use WARN when encode fails

When asn1_encode_sequence() fails, WARN is not the correct solution.

1. asn1_encode_sequence() is not an internal function (located
   in lib/asn1_encode.c).
2. Location is known, which makes the stack trace useless.
3. Results a crash if panic_on_warn is set.

It is also noteworthy that the use of WARN is undocumented, and it
should be avoided unless there is a carefully considered rationale to
use it.

Replace WARN with pr_err, and print the return value instead, which is
only useful piece of information.

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

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

	Issue introduced in 5.13 with commit f2219745250f and fixed in 5.15.160 with commit 96f650995c70
	Issue introduced in 5.13 with commit f2219745250f and fixed in 6.1.92 with commit 681935009fec
	Issue introduced in 5.13 with commit f2219745250f and fixed in 6.6.32 with commit 1c652e1e1067
	Issue introduced in 5.13 with commit f2219745250f and fixed in 6.8.11 with commit d32c6e09f7c4
	Issue introduced in 5.13 with commit f2219745250f and fixed in 6.9.2 with commit ff91cc12faf7
	Issue introduced in 5.13 with commit f2219745250f and fixed in 6.10 with commit 050bf3c793a0

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-36975
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:
	security/keys/trusted-keys/trusted_tpm2.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/96f650995c70237b061b497c66755e32908f8972
	https://git.kernel.org/stable/c/681935009fec3fc22af97ee312d4a24ccf3cf087
	https://git.kernel.org/stable/c/1c652e1e10676f942149052d9329b8bf2703529a
	https://git.kernel.org/stable/c/d32c6e09f7c4bec3ebc4941323f0aa6366bc1487
	https://git.kernel.org/stable/c/ff91cc12faf798f573dab2abc976c1d5b1862fea
	https://git.kernel.org/stable/c/050bf3c793a07f96bd1e2fd62e1447f731ed733b