diff mbox series

[BACKPORT,4.4.y,02/25] ALSA: compress: add support for 32bit calls in a 64bit kernel

Message ID 20190322154425.3852517-3-arnd@arndb.de (mailing list archive)
State New, archived
Headers show
Series candidates from spreadtrum 4.4 product kernel | expand

Commit Message

Arnd Bergmann March 22, 2019, 3:43 p.m. UTC
From: Ravindra Lokhande <rlokhande@nvidia.com>

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@nvidia.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit c10368897e104c008c610915a218f0fe5fa4ec96)
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/core/compress_offload.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Greg Kroah-Hartman March 26, 2019, 1:09 a.m. UTC | #1
On Fri, Mar 22, 2019 at 04:43:53PM +0100, Arnd Bergmann wrote:
> From: Ravindra Lokhande <rlokhande@nvidia.com>
> 
> 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@nvidia.com>
> Acked-by: Vinod Koul <vinod.koul@intel.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> (cherry picked from commit c10368897e104c008c610915a218f0fe5fa4ec96)
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  sound/core/compress_offload.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

How is this not a "new feature"?  What bug does this fix?  Has this ever
worked in the past?

thanks,

greg k-h
Arnd Bergmann March 26, 2019, 7:55 a.m. UTC | #2
On Tue, Mar 26, 2019 at 2:23 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Fri, Mar 22, 2019 at 04:43:53PM +0100, Arnd Bergmann wrote:
> > From: Ravindra Lokhande <rlokhande@nvidia.com>
> >
> > 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@nvidia.com>
> > Acked-by: Vinod Koul <vinod.koul@intel.com>
> > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> > (cherry picked from commit c10368897e104c008c610915a218f0fe5fa4ec96)
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  sound/core/compress_offload.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
>
> How is this not a "new feature"?  What bug does this fix?  Has this ever
> worked in the past?

It has never worked in the past, but I consider it a bug for the compat layer
to behave differently from native code. In this case, any 32-bit application
using the SNDRV_COMPRESS_* ioctls will just fail to do anything on
a 64-bit kernel at all without the trivial fix that should have been there when
the driver was originally merged.

     Arnd
Greg Kroah-Hartman March 30, 2019, 9:40 a.m. UTC | #3
On Tue, Mar 26, 2019 at 08:55:14AM +0100, Arnd Bergmann wrote:
> On Tue, Mar 26, 2019 at 2:23 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Mar 22, 2019 at 04:43:53PM +0100, Arnd Bergmann wrote:
> > > From: Ravindra Lokhande <rlokhande@nvidia.com>
> > >
> > > 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@nvidia.com>
> > > Acked-by: Vinod Koul <vinod.koul@intel.com>
> > > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> > > (cherry picked from commit c10368897e104c008c610915a218f0fe5fa4ec96)
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > > ---
> > >  sound/core/compress_offload.c | 13 +++++++++++++
> > >  1 file changed, 13 insertions(+)
> >
> > How is this not a "new feature"?  What bug does this fix?  Has this ever
> > worked in the past?
> 
> It has never worked in the past, but I consider it a bug for the compat layer
> to behave differently from native code. In this case, any 32-bit application
> using the SNDRV_COMPRESS_* ioctls will just fail to do anything on
> a 64-bit kernel at all without the trivial fix that should have been there when
> the driver was originally merged.

Ok, fair enough, now queued up.

greg k-h
diff mbox series

Patch

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 6163bf3e8177..33d40d6fa3f1 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -38,6 +38,7 @@ 
 #include <linux/uio.h>
 #include <linux/uaccess.h>
 #include <linux/module.h>
+#include <linux/compat.h>
 #include <sound/core.h>
 #include <sound/initval.h>
 #include <sound/compress_params.h>
@@ -858,6 +859,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, (unsigned long)compat_ptr(arg));
+}
+#endif
+
 static const struct file_operations snd_compr_file_ops = {
 		.owner =	THIS_MODULE,
 		.open =		snd_compr_open,
@@ -865,6 +875,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,
 };