Skip to contentSkip to conversation

ALSA: emux: Avoid potential array out-of-bound in snd_emux_xg_control()

PATCH Applied Artemii Karasev 2 participants 2 messages Feb 7, 2023 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: emux: Avoid potential array out-of-bound in snd_emux_xg_control()

snd_emux_xg_control() can be called with an argument 'param' greater than size of 'control' array. It may lead to accessing 'control' array at a wrong index.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 sound/synth/emux/emux_nrpn.c | 3 +++
 1 file changed, 3 insertions(+)
sound/synth/emux/emux_nrpn.c +3 -0
index 8056422ed7c5..9e6414f78e4b 100644
@@ -349,6 +349,9 @@ int
 snd_emux_xg_control(struct snd_emux_port *port, struct snd_midi_channel *chan,
 		    int param)
 {
+	if (param >= ARRAY_SIZE(chan->control))
+		return -EINVAL;
+
 	return send_converted_effect(xg_effects, ARRAY_SIZE(xg_effects),
 				     port, chan, param,
 				     chan->control[param],
Signature · 1 line
2.34.1
Applied
#1 lore raw
Quoted 9 lines · Artemii Karasev

snd_emux_xg_control() can be called with an argument 'param' greater than size of 'control' array. It may lead to accessing 'control' array at a wrong index.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

Thanks, applied now.

Takashi