瀏覽代碼

sound: snd_ctl_remove_user_ctl: prevent removal of kernel controls

Ensure that userspace can remove only user controls.  Controls created
by kernel drivers must not be removed because they might be referenced
in calls to snd_ctl_notify().

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Clemens Ladisch 16 年之前
父節點
當前提交
18dd0aa5af
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      sound/core/control.c

+ 4 - 0
sound/core/control.c

@@ -436,6 +436,10 @@ static int snd_ctl_remove_user_ctl(struct snd_ctl_file * file,
 		ret = -ENOENT;
 		goto error;
 	}
+	if (!(kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_USER)) {
+		ret = -EINVAL;
+		goto error;
+	}
 	for (idx = 0; idx < kctl->count; idx++)
 		if (kctl->vd[idx].owner != NULL && kctl->vd[idx].owner != file) {
 			ret = -EBUSY;