Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3775431pxb; Mon, 4 Oct 2021 09:19:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+AFyEPZ2lFN1xO0YUIIk0NbS0e87URNzgDKiGz2LrhH7UHOWOLbUyXoJqvy+rg6hlYaf6 X-Received: by 2002:a50:ccc4:: with SMTP id b4mr19436558edj.83.1633364380665; Mon, 04 Oct 2021 09:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633364380; cv=none; d=google.com; s=arc-20160816; b=G+Qp/fOA556fBIeeILwdnVthir9PTVA4de7M1MS8fm6CT8J1X2klqROsFLlOA6OUtE ryaiJPaxEmIwwLMDjDixlgKIbyWgFTo7PNaMM381WTzysWu8HoC69E1n9fjioIfrGmA3 VjdTqEf+Q64lxFk3Y4qJVH/SbjRZz8655WGiuhCLTWHL8ZjbYsxZoxv46a6YvOVl0meg BYJuY5oSqQOoYmSVj2bLCghzQY59gN1xCMweaLVMZdxgfWuTn0SqbZTjPcClrP0kiuAo FP3hYLGo0UeCgjqCus1gd98F9kB0gePMZpeyTnX3IbycX0GT9lXM89SE9jYt/j4csj1t Rrgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4964fhfceruLJjPXb7vxjuKGeBQHl7eKmVKB7b9pqOg=; b=ARFKQSYmsu/MEWELbb/+8qe/bpAJB3RhH9z7sSKDQyNCYWT+nOcJrzujFnKFnUOsEM ZFvCTyP7pTKcai5cbWFN4M5emUmis7LzDs79GONZRNt+mXe7XWWqk8tYfrh9qMvJARFQ BieuPaypmk1NYhwKFEjyOxx1/16mXabn6ZeDT06EfZ/b2qsAaDqrvmVrjsVI987CeWLX QBMrL5bsQ/ubKa7p3MrVY1O/0cd0DxZIZJTWiVOEml9M6qWMXsAC9FMn5Q318d7n5JD5 CuP+iferKrtPe4vRXyZUasHjMB+cLf9eIeADboYH7gmxw3Gkb4LK6/LXKJoLzs90NDrW B/Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UbdPgt5G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si19439898ejm.383.2021.10.04.09.19.13; Mon, 04 Oct 2021 09:19:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UbdPgt5G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236879AbhJDNbo (ORCPT + 99 others); Mon, 4 Oct 2021 09:31:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:42998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237075AbhJDN3y (ORCPT ); Mon, 4 Oct 2021 09:29:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A317F63217; Mon, 4 Oct 2021 13:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353200; bh=rpLhAIABTnDAQ3XCCglWj+vsyjstCqUg+9CzjH/sCG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UbdPgt5GR7HsHNRZGEeGwicr9rQOER2ScDRy31QrD5TwPErmG0c4c3Aef377ou1xN GkjVtM8y94izh6YJU8YOXBnsnXVMR0VA6Y/CJBzpn7eqMIa0A/7O/b9M06jPP4PW1j UsSZfJW+2g+gAFoo4KJ5luAum4VvH5ZovXt/FKDk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Henningsson , Jaroslav Kysela , Takashi Iwai Subject: [PATCH 5.14 035/172] ALSA: rawmidi: introduce SNDRV_RAWMIDI_IOCTL_USER_PVERSION Date: Mon, 4 Oct 2021 14:51:25 +0200 Message-Id: <20211004125046.106750937@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jaroslav Kysela commit 09d23174402da0f10e98da2c61bb5ac8e7d79fdd upstream. 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 Cc: Fixes: 08fdced60ca0 ("ALSA: rawmidi: Add framing mode") BugLink: https://github.com/alsa-project/alsa-lib/issues/178 Signed-off-by: Jaroslav Kysela Link: https://lore.kernel.org/r/20210920171850.154186-1-perex@perex.cz Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- include/sound/rawmidi.h | 1 + include/uapi/sound/asound.h | 1 + sound/core/rawmidi.c | 9 +++++++++ 3 files changed, 11 insertions(+) --- a/include/sound/rawmidi.h +++ b/include/sound/rawmidi.h @@ -98,6 +98,7 @@ struct snd_rawmidi_file { struct snd_rawmidi *rmidi; struct snd_rawmidi_substream *input; struct snd_rawmidi_substream *output; + unsigned int user_pversion; /* supported protocol version */ }; struct snd_rawmidi_str { --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -783,6 +783,7 @@ struct snd_rawmidi_status { #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) +#define SNDRV_RAWMIDI_IOCTL_USER_PVERSION _IOW('W', 0x02, int) #define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params) #define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status) #define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int) --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -873,12 +873,21 @@ static long snd_rawmidi_ioctl(struct fil return -EINVAL; } } + case SNDRV_RAWMIDI_IOCTL_USER_PVERSION: + if (get_user(rfile->user_pversion, (unsigned int __user *)arg)) + return -EFAULT; + return 0; + case SNDRV_RAWMIDI_IOCTL_PARAMS: { struct snd_rawmidi_params params; if (copy_from_user(¶ms, argp, sizeof(struct snd_rawmidi_params))) return -EFAULT; + if (rfile->user_pversion < SNDRV_PROTOCOL_VERSION(2, 0, 2)) { + params.mode = 0; + memset(params.reserved, 0, sizeof(params.reserved)); + } switch (params.stream) { case SNDRV_RAWMIDI_STREAM_OUTPUT: if (rfile->output == NULL)