CVE-2024-56685: ASoC: mediatek: Check num_codecs is not zero to avoid panic during probe
In the Linux kernel, the following vulnerability has been resolved:
ASoC: mediatek: Check numcodecs is not zero to avoid panic during probe
Following commit 13f58267cda3 ("ASoC: soc.h: don't create dummy Component via COMPDUMMY()"), COMPDUMMY() became an array with zero length, and only gets populated with the dummy struct after the card is registered. Since the sound card driver's probe happens before the card registration, accessing any of the members of a dummy component during probe will result in undefined behavior.
This can be observed in the mt8188 and mt8195 machine sound drivers. By omitting a dai link subnode in the sound card's node in the Devicetree, the default uninitialized dummy codec is used, and when its dainame pointer gets passed to strcmp() it results in a null pointer dereference and a kernel panic.
In addition to that, setcardcodecinfo() in the generic helpers file, mtk-soundcard-driver.c, will populate a dai link with a dummy codec when a dai link node is present in DT but with no codec property.
The result is that at probe time, a dummy codec can either be uninitialized with numcodecs = 0, or be an initialized dummy codec, with numcodecs = 1 and dainame = "snd-soc-dummy-dai". In order to accommodate for both situations, check that numcodecs is not zero before accessing the codecs' fields but still check for the codec's dai name against "snd-soc-dummy-dai" as needed.
While at it, also drop the check that dainame is not null in the mt8192 driver, introduced in commit 4d4e1b6319e5 ("ASoC: mediatek: mt8192: Check existence of dainame before dereferencing"), as it is actually redundant given the preceding numcodecs != 0 check.
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2024-56685?
CVE-2024-56685 has a moderate severity rating due to its potential to cause a panic during probe execution in the Linux kernel.
How do I fix CVE-2024-56685?
To fix CVE-2024-56685, ensure you have updated to a patched version of the Linux kernel that includes the commit address in the vulnerability details.
What software is affected by CVE-2024-56685?
CVE-2024-56685 affects the Linux kernel, specifically variations that utilize ASoC components.
What are the implications of CVE-2024-56685?
The implications of CVE-2024-56685 include possible system crashes if num_codecs is incorrectly configured during initialization.
Is CVE-2024-56685 easily exploitable?
CVE-2024-56685 is not easily exploitable but could lead to denial of service if the conditions are met during device probing.