Subject: CVE-2024-38659: enic: Validate length of nl attributes in enic_set_vf_port

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

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

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

enic: Validate length of nl attributes in enic_set_vf_port

enic_set_vf_port assumes that the nl attribute IFLA_PORT_PROFILE
is of length PORT_PROFILE_MAX and that the nl attributes
IFLA_PORT_INSTANCE_UUID, IFLA_PORT_HOST_UUID are of length PORT_UUID_MAX.
These attributes are validated (in the function do_setlink in rtnetlink.c)
using the nla_policy ifla_port_policy. The policy defines IFLA_PORT_PROFILE
as NLA_STRING, IFLA_PORT_INSTANCE_UUID as NLA_BINARY and
IFLA_PORT_HOST_UUID as NLA_STRING. That means that the length validation
using the policy is for the max size of the attributes and not on exact
size so the length of these attributes might be less than the sizes that
enic_set_vf_port expects. This might cause an out of bands
read access in the memcpys of the data of these
attributes in enic_set_vf_port.

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

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

	Issue introduced in 2.6.35 with commit f8bd909183ac and fixed in 4.19.316 with commit 2b649d7e0cb4
	Issue introduced in 2.6.35 with commit f8bd909183ac and fixed in 5.4.278 with commit ca63fb7af9d3
	Issue introduced in 2.6.35 with commit f8bd909183ac and fixed in 5.10.219 with commit 3c0d36972edb
	Issue introduced in 2.6.35 with commit f8bd909183ac and fixed in 5.15.161 with commit 25571a12fbc8
	Issue introduced in 2.6.35 with commit f8bd909183ac and fixed in 6.1.93 with commit 7077c22f84f4
	Issue introduced in 2.6.35 with commit f8bd909183ac and fixed in 6.6.33 with commit f6638e955ca0
	Issue introduced in 2.6.35 with commit f8bd909183ac and fixed in 6.9.4 with commit aee1955a1509
	Issue introduced in 2.6.35 with commit f8bd909183ac and fixed in 6.10 with commit e8021b94b041

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-38659
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:
	drivers/net/ethernet/cisco/enic/enic_main.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/2b649d7e0cb42a660f0260ef25fd55fdc9c6c600
	https://git.kernel.org/stable/c/ca63fb7af9d3e531aa25f7ae187bfc6c7166ec2d
	https://git.kernel.org/stable/c/3c0d36972edbe56fcf98899622d9b90ac9965227
	https://git.kernel.org/stable/c/25571a12fbc8a1283bd8380d461267956fd426f7
	https://git.kernel.org/stable/c/7077c22f84f41974a711604a42fd0e0684232ee5
	https://git.kernel.org/stable/c/f6638e955ca00c489894789492776842e102af9c
	https://git.kernel.org/stable/c/aee1955a1509a921c05c70dad5d6fc8563dfcb31
	https://git.kernel.org/stable/c/e8021b94b0412c37bcc79027c2e382086b6ce449