[alsa-devel] [PATCH] ALSA: compress: add support for 32bit calls in a 64bit kernel
Takashi Iwai
tiwai at suse.de
Thu Dec 3 16:28:39 CET 2015
On Thu, 03 Dec 2015 06:32:09 +0100,
Ravindra Lokhande wrote:
>
> Compress offload does not support ioctl calls from a 32bit userspace
> in a 64 bit kernel. This patch adds support for ioctls from a 32bit
> userspace in a 64bit kernel
>
> Signed-off-by: Ravindra Lokhande <rlokhande at nvidia.com>
> ---
> sound/core/compress_offload.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index b123c42..98f6b47 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -847,6 +847,15 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
> return retval;
> }
>
> +/* support of 32bit userspace on 64bit platforms */
> +#ifdef CONFIG_COMPAT
> +static long snd_compr_ioctl_compat(struct file *file, unsigned int cmd,
> + unsigned long arg)
> +{
> + return snd_compr_ioctl(file, cmd, arg);
> +}
> +#endif
This should work in most cases, but not perfectly. The arg passed
here is basically a 32bit address, and it should be converted to a
64bit pointer via compat_ptr() macro. Except for a very few
architectures, it's just a cast to 64bit, so it works in 99% cases.
A workaround would be like:
static long snd_compr_ioctl_compat(struct file *file, unsigned int cmd,
unsigned long arg)
{
return snd_compr_ioctl(file, cmd, (long)compat_ptr(arg));
}
I looked through the current tree and found even a few places in
sound/core/* doing similarly wrong. They need fixes...
thanks,
Takashi
> +
> static const struct file_operations snd_compr_file_ops = {
> .owner = THIS_MODULE,
> .open = snd_compr_open,
> @@ -854,6 +863,9 @@ static const struct file_operations snd_compr_file_ops = {
> .write = snd_compr_write,
> .read = snd_compr_read,
> .unlocked_ioctl = snd_compr_ioctl,
> +#ifdef CONFIG_COMPAT
> + .compat_ioctl = snd_compr_ioctl_compat,
> +#endif
> .mmap = snd_compr_mmap,
> .poll = snd_compr_poll,
> };
> --
> 2.1.4
>
>
More information about the Alsa-devel
mailing list