Re: [PATCH 2/4] ASoC: meson: aiu: Validate written enum values

[email protected]
Newsgroups org.infradead.lists.linux-amlogic
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing bounds check on user-supplied `item[0]` index leads to an out-of-bounds heap read when evaluating `snd_soc_enum_item_to_val`.
--

commit 9a6f223d3a43c4d946f46b956e844cde37d09bef
Author: HyeongJun An <[email protected]>

ASoC: meson: aiu: Validate written enum values

This commit fixes missing bounds checking on user-supplied enumeration
values in the AIU HDMI and internal codec mux put callbacks before they
are passed to snd_soc_enum_item_to_val().

> diff --git a/sound/soc/meson/aiu-acodec-ctrl.c b/sound/soc/meson/aiu-acodec-ctrl.c
> index 483772ba69cd7..94c5d65335233 100644
> --- a/sound/soc/meson/aiu-acodec-ctrl.c
> +++ b/sound/soc/meson/aiu-acodec-ctrl.c
> @@ -36,6 +36,9 @@ static int aiu_acodec_ctrl_mux_put_enum(struct snd_kcontrol *kcontrol,
>  	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
>  	unsigned int mux, changed;
>  
> +	if (ucontrol->value.enumerated.item[0] >= e->items)
> +		return -EINVAL;
> +

[Severity: High]
This is a pre-existing issue, but while you are fixing missing enum
validations here, does sound/soc/sdca/sdca_asoc.c:ge_put_enum_double()
suffer from the exact same out-of-bounds read?

In ge_put_enum_double(), the user-supplied index item[0] is passed to
snd_soc_enum_item_to_val() without verifying if it is less than e->items:

ret = snd_soc_enum_item_to_val(e, item[0]);

Because e->values is dynamically allocated on the heap, an unchecked
large item[0] can read memory past the end of the values buffer. If this
out-of-bounds read hits an unmapped page, could it trigger a page fault
via the ALSA control interface?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.