ALSA: ctl: Fix copy of updated id with element read/write
PATCH 1/1 ALSA: ctl: Fix copy of updated id with element read/write
When control_compat.c:copy_ctl_value_to_user() is used, by ctl_elem_read_user() & ctl_elem_write_user(), it must also copy back the snd_ctl_elem_id value that may have been updated (filled in) by the call to snd_ctl_elem_read/snd_ctl_elem_write().
This matches the functionality provided by snd_ctl_elem_read_user() and snd_ctl_elem_write_user(), via snd_ctl_build_ioff().
Without this, and without making additional calls to snd_ctl_info() which are unnecessary when using the non-compat calls, a userspace application will not know the numid value for the element and consequently will not be able to use the poll/read interface on the control file to determine which elements have updates.
--- sound/core/control_compat.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/control_compat.c +3 -0
@@ -264,6 +264,7 @@ static int copy_ctl_value_to_user(void __user *userdata,struct snd_ctl_elem_value *data, int type, int count) { + struct snd_ctl_elem_value32 __user *data32 = userdata;int i, size; if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
@@ -280,6 +281,8 @@ static int copy_ctl_value_to_user(void __user *userdata,if (copy_to_user (valuep, data->value.bytes.data, size))return -EFAULT ; } +if (copy_to_user (&data32->id, &data->id,sizeof (data32->id))) +return -EFAULT ;return 0 ; }
Signature · 1 line
2.25.1
Takashi Iwai
AppliedQuoted 9 lines · Alan Young
When control_compat.c:copy_ctl_value_to_user() is used, by
ctl_elem_read_user()&ctl_elem_write_user(), it must also copy back thesnd_ctl_elem_idvalue that may have been updated (filled in) by the call to snd_ctl_elem_read/snd_ctl_elem_write().This matches the functionality provided by
snd_ctl_elem_read_user()andsnd_ctl_elem_write_user(), viasnd_ctl_build_ioff().
Quoted 7 lines
Without this, and without making additional calls to
snd_ctl_info()which are unnecessary when using the non-compat calls, a userspace application will not know the numid value for the element and consequently will not be able to use the poll/read interface on the control file to determine which elements have updates.Signed-off-by Alan Young <[email protected]>
Thanks, applied (with Cc to stable).
Takashi