* [PATCH] ALSA: ctl: Fix copy of updated id with element read/write
@ 2021-12-02 15:06 Alan Young
2021-12-02 15:46 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Alan Young @ 2021-12-02 15:06 UTC (permalink / raw)
To: alsa-devel; +Cc: tiwai, 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 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.
Signed-off-by: Alan Young <consult.awy@gmail.com>
---
sound/core/control_compat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 470dabc60aa0..edff063e088d 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ALSA: ctl: Fix copy of updated id with element read/write
2021-12-02 15:06 [PATCH] ALSA: ctl: Fix copy of updated id with element read/write Alan Young
@ 2021-12-02 15:46 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2021-12-02 15:46 UTC (permalink / raw)
To: Alan Young; +Cc: alsa-devel
On Thu, 02 Dec 2021 16:06:07 +0100,
Alan Young wrote:
>
> 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.
>
> Signed-off-by: Alan Young <consult.awy@gmail.com>
Thanks, applied (with Cc to stable).
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ALSA: ctl: Fix copy of updated id with element read/write
@ 2021-12-02 14:49 Alan Young
0 siblings, 0 replies; 4+ messages in thread
From: Alan Young @ 2021-12-02 14:49 UTC (permalink / raw)
To: alsa-devel; +Cc: Takashi Iwai
[-- Attachment #1: Type: text/plain, Size: 1722 bytes --]
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.
Signed-off-by: Alan Young [1]<consult.awy@gmail.com>
---
sound/core/control_compat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 470dabc60aa0..edff063e088d 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -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;
}
--
2.25.1
References
1. mailto:consult.awy@gmail.com
[-- Attachment #2: 0001-ALSA-ctl-Fix-copy-of-updated-id-with-element-read-wr.patch --]
[-- Type: text/x-patch, Size: 1765 bytes --]
From 8dfd143c2e05405bc1f61107c5858eab9c5fc847 Mon Sep 17 00:00:00 2001
From: Alan Young <consult.awy@gmail.com>
Date: Mon, 8 Nov 2021 12:39:56 -0500
Subject: [PATCH] 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.
Signed-off-by: Alan Young <consult.awy@gmail.com>
---
sound/core/control_compat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 470dabc60aa0..edff063e088d 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ALSA: ctl: Fix copy of updated id with element read/write
@ 2021-11-09 15:53 Alan Young
0 siblings, 0 replies; 4+ messages in thread
From: Alan Young @ 2021-11-09 15:53 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-ALSA-ctl-Fix-copy-of-updated-id-with-element-read-wr.patch --]
[-- Type: text/x-patch, Size: 1764 bytes --]
From 8dfd143c2e05405bc1f61107c5858eab9c5fc847 Mon Sep 17 00:00:00 2001
From: Alan Young <consult.awy@gmail.com>
Date: Mon, 8 Nov 2021 12:39:56 -0500
Subject: [PATCH] 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.
Signed-off-by: Alan Young <consult.awy@gmail.com>
---
sound/core/control_compat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 470dabc60aa0..edff063e088d 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-02 15:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 15:06 [PATCH] ALSA: ctl: Fix copy of updated id with element read/write Alan Young
2021-12-02 15:46 ` Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2021-12-02 14:49 Alan Young
2021-11-09 15:53 Alan Young
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.