Subject: CVE-2023-52746: xfrm/compat: prevent potential spectre v1 gadget in xfrm_xlate32_attr()

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

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

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

xfrm/compat: prevent potential spectre v1 gadget in xfrm_xlate32_attr()

  int type = nla_type(nla);

  if (type > XFRMA_MAX) {
            return -EOPNOTSUPP;
  }

@type is then used as an array index and can be used
as a Spectre v1 gadget.

  if (nla_len(nla) < compat_policy[type].len) {

array_index_nospec() can be used to prevent leaking
content of kernel memory to malicious users.

The Linux kernel CVE team has assigned CVE-2023-52746 to this issue.

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

	Issue introduced in 5.10 with commit 5106f4a8acff and fixed in 5.10.168 with commit a893cc644812
	Issue introduced in 5.10 with commit 5106f4a8acff and fixed in 5.15.94 with commit 5dc688fae6b7
	Issue introduced in 5.10 with commit 5106f4a8acff and fixed in 6.1.12 with commit 419674224390
	Issue introduced in 5.10 with commit 5106f4a8acff and fixed in 6.2 with commit b6ee89638538

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-2023-52746
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:
	net/xfrm/xfrm_compat.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/a893cc644812728e86e9aff517fd5698812ecef0
	https://git.kernel.org/stable/c/5dc688fae6b7be9dbbf5304a3d2520d038e06db5
	https://git.kernel.org/stable/c/419674224390fca298020fc0751a20812f84b12d
	https://git.kernel.org/stable/c/b6ee896385380aa621102e8ea402ba12db1cabff