Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: rawmidi: introduce SNDRV_RAWMIDI_IOCTL_USER_PVERSION

The new framing mode causes the user space regression, because
the alsa-lib code does not initialize the reserved space in
the params structure when the device is opened.

This change adds SNDRV_RAWMIDI_IOCTL_USER_PVERSION like we
do for the PCM interface for the protocol acknowledgment.

Cc: David Henningsson <coding@diwic.se>
Cc: <stable@vger.kernel.org>
Fixes: 08fdced60ca0 ("ALSA: rawmidi: Add framing mode")
BugLink: https://github.com/alsa-project/alsa-lib/issues/178
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210920171850.154186-1-perex@perex.cz
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Jaroslav Kysela and committed by
Takashi Iwai
09d23174 cb1bcf5e

+11
+1
include/sound/rawmidi.h
··· 98 98 struct snd_rawmidi *rmidi; 99 99 struct snd_rawmidi_substream *input; 100 100 struct snd_rawmidi_substream *output; 101 + unsigned int user_pversion; /* supported protocol version */ 101 102 }; 102 103 103 104 struct snd_rawmidi_str {
+1
include/uapi/sound/asound.h
··· 784 784 785 785 #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) 786 786 #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) 787 + #define SNDRV_RAWMIDI_IOCTL_USER_PVERSION _IOW('W', 0x02, int) 787 788 #define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params) 788 789 #define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status) 789 790 #define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int)
+9
sound/core/rawmidi.c
··· 873 873 return -EINVAL; 874 874 } 875 875 } 876 + case SNDRV_RAWMIDI_IOCTL_USER_PVERSION: 877 + if (get_user(rfile->user_pversion, (unsigned int __user *)arg)) 878 + return -EFAULT; 879 + return 0; 880 + 876 881 case SNDRV_RAWMIDI_IOCTL_PARAMS: 877 882 { 878 883 struct snd_rawmidi_params params; 879 884 880 885 if (copy_from_user(&params, argp, sizeof(struct snd_rawmidi_params))) 881 886 return -EFAULT; 887 + if (rfile->user_pversion < SNDRV_PROTOCOL_VERSION(2, 0, 2)) { 888 + params.mode = 0; 889 + memset(params.reserved, 0, sizeof(params.reserved)); 890 + } 882 891 switch (params.stream) { 883 892 case SNDRV_RAWMIDI_STREAM_OUTPUT: 884 893 if (rfile->output == NULL)