summaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorWenwen Wang <wang6495@umn.edu>2018-05-05 13:38:03 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-25 10:54:54 +0200
commit8bfbeb811fa169e205169f3ae8985c3265511551 (patch)
tree8b589f92020cd8ba6b2c6118f064d3cc656cbfde /sound/core
parent4caf3f00f935ef51083b9ca8b90bc73292f73aac (diff)
downloadlinux-stable-8bfbeb811fa169e205169f3ae8985c3265511551.tar.gz
linux-stable-8bfbeb811fa169e205169f3ae8985c3265511551.tar.bz2
linux-stable-8bfbeb811fa169e205169f3ae8985c3265511551.zip
ALSA: control: fix a redundant-copy issue
commit 3f12888dfae2a48741c4caa9214885b3aaf350f9 upstream. In snd_ctl_elem_add_compat(), the fields of the struct 'data' need to be copied from the corresponding fields of the struct 'data32' in userspace. This is achieved by invoking copy_from_user() and get_user() functions. The problem here is that the 'type' field is copied twice. One is by copy_from_user() and one is by get_user(). Given that the 'type' field is not used between the two copies, the second copy is *completely* redundant and should be removed for better performance and cleanup. Also, these two copies can cause inconsistent data: as the struct 'data32' resides in userspace and a malicious userspace process can race to change the 'type' field between the two copies to cause inconsistent data. Depending on how the data is used in the future, such an inconsistency may cause potential security risks. For above reasons, we should take out the second copy. Signed-off-by: Wenwen Wang <wang6495@umn.edu> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/control_compat.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 0608f216f359..ac0a40b9ba1e 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -400,8 +400,7 @@ static int snd_ctl_elem_add_compat(struct snd_ctl_file *file,
if (copy_from_user(&data->id, &data32->id, sizeof(data->id)) ||
copy_from_user(&data->type, &data32->type, 3 * sizeof(u32)))
goto error;
- if (get_user(data->owner, &data32->owner) ||
- get_user(data->type, &data32->type))
+ if (get_user(data->owner, &data32->owner))
goto error;
switch (data->type) {
case SNDRV_CTL_ELEM_TYPE_BOOLEAN: