From: Lars-Peter Clausen Date: Wed, 18 Jun 2014 11:32:35 +0000 (+0200) Subject: ALSA: control: Make sure that id->index does not overflow X-Git-Tag: TizenStudio_2.0_p2.3~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca20ace29fa536db3f208124e6e5f1556182a9e0;p=sdk%2Femulator%2Femulator-kernel.git ALSA: control: Make sure that id->index does not overflow The ALSA control code expects that the range of assigned indices to a control is continuous and does not overflow. Currently there are no checks to enforce this. If a control with a overflowing index range is created that control becomes effectively inaccessible and unremovable since snd_ctl_find_id() will not be able to find it. This patch adds a check that makes sure that controls with a overflowing index range can not be created. Change-Id: I9e2ba5869ea3bd692393b668a38a206611d8d93b Signed-off-by: Lars-Peter Clausen Acked-by: Jaroslav Kysela Cc: Signed-off-by: Takashi Iwai --- diff --git a/sound/core/control.c b/sound/core/control.c index d4a597fe86e4..0469ba695c4c 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -339,6 +339,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) if (snd_BUG_ON(!card || !kcontrol->info)) goto error; id = kcontrol->id; + if (id.index > UINT_MAX - kcontrol->count) + goto error; + down_write(&card->controls_rwsem); if (snd_ctl_find_id(card, &id)) { up_write(&card->controls_rwsem);