From bippy-c9c4e1df01b2 Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: <linux-cve-announce@vger.kernel.org>
Reply-to: <cve@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: CVE-2022-48777: mtd: parsers: qcom: Fix kernel panic on skipped partition

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

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

mtd: parsers: qcom: Fix kernel panic on skipped partition

In the event of a skipped partition (case when the entry name is empty)
the kernel panics in the cleanup function as the name entry is NULL.
Rework the parser logic by first checking the real partition number and
then allocate the space and set the data for the valid partitions.

The logic was also fundamentally wrong as with a skipped partition, the
parts number returned was incorrect by not decreasing it for the skipped
partitions.

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


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

	Issue introduced in 5.12 with commit 803eb124e1a6 and fixed in 5.15.25 with commit eb03cb6e03ff
	Issue introduced in 5.12 with commit 803eb124e1a6 and fixed in 5.16.11 with commit a2995fe23095
	Issue introduced in 5.12 with commit 803eb124e1a6 and fixed in 5.17 with commit 65d003cca335

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-48777
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/mtd/parsers/qcomsmempart.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/eb03cb6e03ffd9173e18e5fe87e4e3ce83820453
	https://git.kernel.org/stable/c/a2995fe23095ceda2dc382fbe057f5e164595548
	https://git.kernel.org/stable/c/65d003cca335cabc0160d3cd7daa689eaa9dd3cd
