ASoC: meson: Keep link pointers valid on realloc failure
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 7864a79f37b55769b817d5e6c5ae0ca4bfdba93b · < 8fec16898f184e5f8f8fdd09ff1ced2bd7ffc13d| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
ASoC: meson: Keep link pointers valid on realloc failure
meson_card_reallocate_links() grows the DAI link and private data arrays with two consecutive krealloc() calls and updates the owner pointers only after both calls have succeeded.
A successful krealloc() may move the data: it frees the old block and returns a new one. When that happens for the link array and the second krealloc() then fails, card->dai_link still points to the block that krealloc() already freed, and the error path frees the new block too. The probe error path then calls meson_card_clean_references(), which dereferences card->dai_link and kfree()s it again, resulting in a use-after-free and a double free.
Commit card->dai_link and card->num_links right after the first krealloc() succeeds, so the pointer always refers to a valid allocation that meson_card_clean_references() can walk and free. krealloc() with __GFP_ZERO zero-initializes the added entries, so walking them on the error path is safe. With both failure paths reduced to a plain return, drop the goto labels and the error message.
From the CVE record · Linux
The Linux kernel’s ASoC meson driver can retain a freed DAI link pointer if its first array reallocation moves the data and a second reallocation fails. The probe error path then dereferences and frees that pointer again, causing a use-after-free and double free. The input does not establish whether an attacker can trigger these conditions or whether access or user interaction is required.
Engineers running Linux kernels with the ASoC meson driver should check their versions; affected versions are not specified.