Subject: CVE-2022-48779: net: mscc: ocelot: fix use-after-free in ocelot_vlan_del()

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

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

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

net: mscc: ocelot: fix use-after-free in ocelot_vlan_del()

ocelot_vlan_member_del() will free the struct ocelot_bridge_vlan, so if
this is the same as the port's pvid_vlan which we access afterwards,
what we're accessing is freed memory.

Fix the bug by determining whether to clear ocelot_port->pvid_vlan prior
to calling ocelot_vlan_member_del().

The Linux kernel CVE team has assigned CVE-2022-48779 to this issue.

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

	Issue introduced in 5.16 with commit d4004422f6f9 and fixed in 5.16.11 with commit c98bed60cdd7
	Issue introduced in 5.16 with commit d4004422f6f9 and fixed in 5.17 with commit ef5764057540

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-2022-48779
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/mscc/ocelot.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/c98bed60cdd7f22237ae256cc9c1c3087206b8a2
	https://git.kernel.org/stable/c/ef57640575406f57f5b3393cf57f457b0ace837e