ALSA: Fix compat_ioctl handling for OSS emulations
authorTakashi Iwai <tiwai@suse.de>
Thu, 3 Dec 2015 16:19:31 +0000 (17:19 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 3 Dec 2015 16:40:21 +0000 (17:40 +0100)
The ALSA PCM, mixer and sequencer OSS emulations provide the 32bit
compatible ioctl, but they just call the 64bit native ioctl as is.
Although this works in most cases, passing the argument value as-is
isn't guaranteed to work on all architectures.  We need to convert it
via compat_ptr() instead.

This patch addresses the missing conversions.  Since all relevant
ioctls in these functions take the argument as a pointer, we do the
pointer conversion in each compat_ioctl and pass it as a 64bit value
to the native ioctl.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/oss/mixer_oss.c
sound/core/oss/pcm_oss.c
sound/core/seq/oss/seq_oss.c

index 7a8c79dd9734039d2e14ae1a7f23763e7d6fc519..2ff9c12d664a8a5e568f37a7b6564c0fcd86e6a1 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/time.h>
 #include <linux/string.h>
 #include <linux/module.h>
+#include <linux/compat.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/control.h>
@@ -397,7 +398,12 @@ int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned l
 
 #ifdef CONFIG_COMPAT
 /* all compatible */
-#define snd_mixer_oss_ioctl_compat     snd_mixer_oss_ioctl
+static long snd_mixer_oss_ioctl_compat(struct file *file, unsigned int cmd,
+                                      unsigned long arg)
+{
+       return snd_mixer_oss_ioctl1(file->private_data, cmd,
+                                   (unsigned long)compat_ptr(arg));
+}
 #else
 #define snd_mixer_oss_ioctl_compat     NULL
 #endif
index 58550cc93f2805aa8627f9e3e4588c2838281926..e557dbe469f4691d05031c0c0a4b322d17f1db32 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <linux/math64.h>
 #include <linux/string.h>
+#include <linux/compat.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/pcm.h>
@@ -2648,7 +2649,11 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long
 
 #ifdef CONFIG_COMPAT
 /* all compatible */
-#define snd_pcm_oss_ioctl_compat       snd_pcm_oss_ioctl
+static long snd_pcm_oss_ioctl_compat(struct file *file, unsigned int cmd,
+                                    unsigned long arg)
+{
+       return snd_pcm_oss_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+}
 #else
 #define snd_pcm_oss_ioctl_compat       NULL
 #endif
index 7354b8bed86099072227fba427a355acf868cba8..8db156b207f187dfc821160cf39d92a8a5521085 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/compat.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/initval.h>
@@ -189,7 +190,11 @@ odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 }
 
 #ifdef CONFIG_COMPAT
-#define odev_ioctl_compat      odev_ioctl
+static long odev_ioctl_compat(struct file *file, unsigned int cmd,
+                             unsigned long arg)
+{
+       return odev_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+}
 #else
 #define odev_ioctl_compat      NULL
 #endif