ALSA: hda/hdmi: clamp sad_count in ELD proc write handler
Subsystems (2)
PATCH 1/1 ALSA: hda/hdmi: clamp sad_count in ELD proc write handler
snd_hdmi_write_eld_info() parses a "sad_count N" line from the root-writable ELD proc interface and assigns N directly to e->sad_count with no upper bound, unlike the per-index "sadN_*" lines a few lines below which are already bounded to ELD_MAX_SAD.
snd_hdmi_eld_update_pcm_info() later iterates
"for (i = 0; i < e->sad_count; i++)" over the fixed e->sad[ELD_MAX_SAD] array, so an oversized sad_count read from the proc file causes it to walk past the array.
Reject sad_count values above ELD_MAX_SAD, matching the existing per-index guard.
--- sound/hda/codecs/hdmi/eld.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/hda/codecs/hdmi/eld.c +4 -2
@@ -155,9 +155,11 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld, e->aud_synch_delay = val; else if (!strcmp(name, "speakers")) e->spk_alloc = val; - else if (!strcmp(name, "sad_count")) + else if (!strcmp(name, "sad_count")) { +if (val >ELD_MAX_SAD ) +continue ; e->sad_count = val; - else if (!strncmp(name, "sad", 3)) { + } else if (!strncmp(name, "sad", 3)) { sname = name +4 ; n = name[3 ] -'0' ;if (name[4 ] >='0' && name[4 ] <='9' ) {
Signature · 1 line
2.56.0
Takashi Iwai
AppliedQuoted 11 lines · Peter Ujfalusi
snd_hdmi_write_eld_info()parses a "sad_countN" line from the root-writable ELD proc interface and assigns N directly toe->sad_countwith no upper bound, unlike the per-index "sadN_*" lines a few lines below which are already bounded toELD_MAX_SAD.
snd_hdmi_eld_update_pcm_info()later iterates
"for (i = 0; i <e->sad_count; i++)" over the fixed e->sad[ELD_MAX_SAD] array, so an oversizedsad_countread from the proc file causes it to walk past the array.
Quoted 6 lines
Reject
sad_countvalues aboveELD_MAX_SAD, matching the existing per-index guard.Fixes acb059938810 ("ALSA: hda - ELD proc interface write updates")Signed-off-by Peter Ujfalusi <[email protected]>
Applied to for-next branch. Thanks.
Takashi