Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1358878
| From | Jiri Slaby <jslaby@suse.cz> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 3.12 23/58] ALSA: ctl: Fix ioctls for X32 ABI |
| Date | 2016-03-16 12:20 +0100 |
| Message-ID | <rdhEC-8cQ-27@gated-at.bofh.it> (permalink) |
| References | <rdhlg-7Px-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Takashi Iwai <tiwai@suse.de>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 6236d8bb2afcfe71b88ecea554e0dc638090a45f upstream.
The X32 ABI takes the same alignment like x86-64, and this may result
in the incompatible struct size from ia32. Unfortunately, we hit this
in some control ABI: struct snd_ctl_elem_value differs between them
due to the position of 64bit variable array. This ends up with the
unknown ioctl (ENOTTY) error.
The fix is to add the compat entries for the new aligned struct.
Reported-and-tested-by: Steven Newbury <steve@snewbury.org.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
sound/core/control_compat.c | 90 +++++++++++++++++++++++++++++++++++++--------
1 file changed, 74 insertions(+), 16 deletions(-)
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 2bb95a7a8809..c14565bde887 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -170,6 +170,19 @@ struct snd_ctl_elem_value32 {
unsigned char reserved[128];
};
+#ifdef CONFIG_X86_X32
+/* x32 has a different alignment for 64bit values from ia32 */
+struct snd_ctl_elem_value_x32 {
+ struct snd_ctl_elem_id id;
+ unsigned int indirect; /* bit-field causes misalignment */
+ union {
+ s32 integer[128];
+ unsigned char data[512];
+ s64 integer64[64];
+ } value;
+ unsigned char reserved[128];
+};
+#endif /* CONFIG_X86_X32 */
/* get the value type and count of the control */
static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
@@ -219,9 +232,11 @@ static int get_elem_size(int type, int count)
static int copy_ctl_value_from_user(struct snd_card *card,
struct snd_ctl_elem_value *data,
- struct snd_ctl_elem_value32 __user *data32,
+ void __user *userdata,
+ void __user *valuep,
int *typep, int *countp)
{
+ struct snd_ctl_elem_value32 __user *data32 = userdata;
int i, type, size;
int uninitialized_var(count);
unsigned int indirect;
@@ -239,8 +254,9 @@ static int copy_ctl_value_from_user(struct snd_card *card,
if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
for (i = 0; i < count; i++) {
+ s32 __user *intp = valuep;
int val;
- if (get_user(val, &data32->value.integer[i]))
+ if (get_user(val, &intp[i]))
return -EFAULT;
data->value.integer.value[i] = val;
}
@@ -250,8 +266,7 @@ static int copy_ctl_value_from_user(struct snd_card *card,
printk(KERN_ERR "snd_ioctl32_ctl_elem_value: unknown type %d\n", type);
return -EINVAL;
}
- if (copy_from_user(data->value.bytes.data,
- data32->value.data, size))
+ if (copy_from_user(data->value.bytes.data, valuep, size))
return -EFAULT;
}
@@ -261,7 +276,8 @@ static int copy_ctl_value_from_user(struct snd_card *card,
}
/* restore the value to 32bit */
-static int copy_ctl_value_to_user(struct snd_ctl_elem_value32 __user *data32,
+static int copy_ctl_value_to_user(void __user *userdata,
+ void __user *valuep,
struct snd_ctl_elem_value *data,
int type, int count)
{
@@ -270,22 +286,22 @@ static int copy_ctl_value_to_user(struct snd_ctl_elem_value32 __user *data32,
if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
for (i = 0; i < count; i++) {
+ s32 __user *intp = valuep;
int val;
val = data->value.integer.value[i];
- if (put_user(val, &data32->value.integer[i]))
+ if (put_user(val, &intp[i]))
return -EFAULT;
}
} else {
size = get_elem_size(type, count);
- if (copy_to_user(data32->value.data,
- data->value.bytes.data, size))
+ if (copy_to_user(valuep, data->value.bytes.data, size))
return -EFAULT;
}
return 0;
}
-static int snd_ctl_elem_read_user_compat(struct snd_card *card,
- struct snd_ctl_elem_value32 __user *data32)
+static int ctl_elem_read_user(struct snd_card *card,
+ void __user *userdata, void __user *valuep)
{
struct snd_ctl_elem_value *data;
int err, type, count;
@@ -294,7 +310,9 @@ static int snd_ctl_elem_read_user_compat(struct snd_card *card,
if (data == NULL)
return -ENOMEM;
- if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0)
+ err = copy_ctl_value_from_user(card, data, userdata, valuep,
+ &type, &count);
+ if (err < 0)
goto error;
snd_power_lock(card);
@@ -303,14 +321,15 @@ static int snd_ctl_elem_read_user_compat(struct snd_card *card,
err = snd_ctl_elem_read(card, data);
snd_power_unlock(card);
if (err >= 0)
- err = copy_ctl_value_to_user(data32, data, type, count);
+ err = copy_ctl_value_to_user(userdata, valuep, data,
+ type, count);
error:
kfree(data);
return err;
}
-static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
- struct snd_ctl_elem_value32 __user *data32)
+static int ctl_elem_write_user(struct snd_ctl_file *file,
+ void __user *userdata, void __user *valuep)
{
struct snd_ctl_elem_value *data;
struct snd_card *card = file->card;
@@ -320,7 +339,9 @@ static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
if (data == NULL)
return -ENOMEM;
- if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0)
+ err = copy_ctl_value_from_user(card, data, userdata, valuep,
+ &type, &count);
+ if (err < 0)
goto error;
snd_power_lock(card);
@@ -329,12 +350,39 @@ static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
err = snd_ctl_elem_write(card, file, data);
snd_power_unlock(card);
if (err >= 0)
- err = copy_ctl_value_to_user(data32, data, type, count);
+ err = copy_ctl_value_to_user(userdata, valuep, data,
+ type, count);
error:
kfree(data);
return err;
}
+static int snd_ctl_elem_read_user_compat(struct snd_card *card,
+ struct snd_ctl_elem_value32 __user *data32)
+{
+ return ctl_elem_read_user(card, data32, &data32->value);
+}
+
+static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
+ struct snd_ctl_elem_value32 __user *data32)
+{
+ return ctl_elem_write_user(file, data32, &data32->value);
+}
+
+#ifdef CONFIG_X86_X32
+static int snd_ctl_elem_read_user_x32(struct snd_card *card,
+ struct snd_ctl_elem_value_x32 __user *data32)
+{
+ return ctl_elem_read_user(card, data32, &data32->value);
+}
+
+static int snd_ctl_elem_write_user_x32(struct snd_ctl_file *file,
+ struct snd_ctl_elem_value_x32 __user *data32)
+{
+ return ctl_elem_write_user(file, data32, &data32->value);
+}
+#endif /* CONFIG_X86_X32 */
+
/* add or replace a user control */
static int snd_ctl_elem_add_compat(struct snd_ctl_file *file,
struct snd_ctl_elem_info32 __user *data32,
@@ -393,6 +441,10 @@ enum {
SNDRV_CTL_IOCTL_ELEM_WRITE32 = _IOWR('U', 0x13, struct snd_ctl_elem_value32),
SNDRV_CTL_IOCTL_ELEM_ADD32 = _IOWR('U', 0x17, struct snd_ctl_elem_info32),
SNDRV_CTL_IOCTL_ELEM_REPLACE32 = _IOWR('U', 0x18, struct snd_ctl_elem_info32),
+#ifdef CONFIG_X86_X32
+ SNDRV_CTL_IOCTL_ELEM_READ_X32 = _IOWR('U', 0x12, struct snd_ctl_elem_value_x32),
+ SNDRV_CTL_IOCTL_ELEM_WRITE_X32 = _IOWR('U', 0x13, struct snd_ctl_elem_value_x32),
+#endif /* CONFIG_X86_X32 */
};
static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
@@ -431,6 +483,12 @@ static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, uns
return snd_ctl_elem_add_compat(ctl, argp, 0);
case SNDRV_CTL_IOCTL_ELEM_REPLACE32:
return snd_ctl_elem_add_compat(ctl, argp, 1);
+#ifdef CONFIG_X86_X32
+ case SNDRV_CTL_IOCTL_ELEM_READ_X32:
+ return snd_ctl_elem_read_user_x32(ctl->card, argp);
+ case SNDRV_CTL_IOCTL_ELEM_WRITE_X32:
+ return snd_ctl_elem_write_user_x32(ctl, argp);
+#endif /* CONFIG_X86_X32 */
}
down_read(&snd_ioctl_rwsem);
--
2.7.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 3.12 00/58] 3.12.57-stable review Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:00 +0100
[PATCH 3.12 01/58] nfsd: fix problem with setting ACL on directories Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:00 +0100
[PATCH 3.12 44/58] KVM: x86: move steal time initialization to vcpu entry time Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 48/58] efi: Make our variable validation list include the guid Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 15/58] x86/entry/compat: Add missing CLAC to entry_INT80_32 Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 34/58] MIPS: traps: Fix SIGFPE information leak from `do_ov' and `do_trap_or_bp' Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 29/58] ALSA: hdspm: Fix zero-division Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 43/58] powerpc: Fix dedotify for binutils >= 2.26 Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 40/58] ASoC: wm8958: Fix enum ctl accesses in a wrong type Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 37/58] KVM: VMX: disable PEBS before a guest entry Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 42/58] mac80211: minstrel_ht: set default tx aggregation timeout to 0 Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 47/58] efi: Do variable name validation tests in utf8 Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 33/58] USB: serial: option: add support for Quectel UC20 Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 57/58] xen/pciback: Don't allow MSI-X ops if PCI_COMMAND_MEMORY is not set. Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 27/58] ALSA: hdspm: Fix wrong boolean ctl value accesses Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 13/58] CIFS: Fix SMB2+ interim response processing for read requests Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 46/58] efi: Use ucs2_as_utf8 in efivarfs instead of open coding a bad version Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 20/58] Revert "jffs2: Fix lock acquisition order bug in jffs2_write_begin" Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 45/58] lib/ucs2_string: Add ucs2 -> utf8 helper functions Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 38/58] tracing: Fix check for cpu online when event is disabled Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 12/58] cifs: fix out-of-bounds access in lease parsing Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 28/58] ALSA: hdsp: Fix wrong boolean ctl value accesses Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 36/58] Revert "drm/radeon: hold reference to fences in radeon_sa_bo_new" Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
Re: [PATCH 3.12 36/58] Revert "drm/radeon: hold reference to fences in radeon_sa_bo_new" Nicolai Hähnle <nicolai.haehnle@amd.com> - 2016-03-16 20:50 +0100
[PATCH 3.12 53/58] xen/pciback: Return error on XEN_PCI_OP_enable_msi when device has MSI or MSI-X enabled Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 56/58] xen/pciback: For XEN_PCI_OP_disable_msi[|x] only disable if device has MSI(X) enabled. Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 39/58] ASoC: wm8994: Fix enum ctl accesses in a wrong type Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 50/58] efi: Add pstore variables to the deletion whitelist Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 58/58] xen/pciback: Check PF instead of VF for PCI_COMMAND_MEMORY Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 55/58] xen/pciback: Do not install an IRQ handler for MSI interrupts. Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 32/58] USB: serial: option: add support for Telit LE922 PID 0x1045 Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 35/58] ubi: Fix out of bounds write in volume update code Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 41/58] wext: fix message delay/ordering Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 49/58] efi: Make efivarfs entries immutable by default Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 31/58] USB: cp210x: Add ID for Parrot NMEA GPS Flight Recorder Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 54/58] xen/pciback: Return error on XEN_PCI_OP_enable_msix when device has MSI or MSI-X enabled Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 52/58] modules: fix longstanding /proc/kallsyms vs module insertion race. Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 51/58] lib/ucs2_string: Correct ucs2 -> utf8 conversion Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:10 +0100
[PATCH 3.12 16/58] drm/ast: Fix incorrect register check for DRAM width Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 21/58] jffs2: Fix page lock / f->sem deadlock Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 07/58] [media] usbvision fix overflow of interfaces array Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 04/58] USB: cp210x: flush device queues at close Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 18/58] libata: Align ata_device's id on a cacheline Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 11/58] genksyms: Handle string literals with spaces in reference files Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 17/58] libata: fix HDIO_GET_32BIT ioctl Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 09/58] ixgbe: use correct FCoE DDP max check Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 10/58] ixgbe: fix broken PFC with X550 Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 26/58] ALSA: seq: oss: Don't drain at closing a client Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 23/58] ALSA: ctl: Fix ioctls for X32 ABI Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 02/58] unix: properly account for FDs passed over unix sockets Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 25/58] ALSA: timer: Fix ioctls for X32 ABI Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 05/58] USB: cp210x: relocate private data from USB interface to port Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 19/58] PM / sleep / x86: Fix crash on graph trace through x86 suspend Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 24/58] ALSA: rawmidi: Fix ioctls X32 ABI Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 14/58] iommu/amd: Fix boot warning when device 00:00.0 is not iommu covered Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 22/58] Fix directory hardlinks from deleted directories Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 30/58] ALSA: timer: Fix broken compat timer user status ioctl Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 06/58] USB: cp210x: work around cp2108 GET_LINE_CTL bug Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
[PATCH 3.12 08/58] usb: Add connected retry on resume for non SS devices Jiri Slaby <jslaby@suse.cz> - 2016-03-16 12:20 +0100
Re: [PATCH 3.12 01/58] nfsd: fix problem with setting ACL on directories Sergio Gelato <Sergio.Gelato@astro.su.se> - 2016-03-16 13:40 +0100
Re: [PATCH 3.12 00/58] 3.12.57-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2016-03-16 16:50 +0100
Re: [PATCH 3.12 00/58] 3.12.57-stable review Guenter Roeck <linux@roeck-us.net> - 2016-03-16 19:00 +0100
Re: [PATCH 3.12 00/58] 3.12.57-stable review Jiri Slaby <jslaby@suse.cz> - 2016-03-16 19:20 +0100
Re: [PATCH 3.12 00/58] 3.12.57-stable review Guenter Roeck <linux@roeck-us.net> - 2016-03-17 04:30 +0100
csiph-web