Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2879432pxu; Sat, 19 Dec 2020 05:08:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZJZXZZHx4Ze3WUQJUzTy67oQdfwHh8+1D4Ai1Dh9SFUoFKIWR2JWwzBhO1NCT9CiaUnEX X-Received: by 2002:a50:c3c5:: with SMTP id i5mr8727830edf.166.1608383290383; Sat, 19 Dec 2020 05:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608383290; cv=none; d=google.com; s=arc-20160816; b=rg9vuIweuj6IxN4revo9T2kz+Mchk1FnR038l1Mc3Z4Q+vmF8qVSzCXo6ry5YLrow2 8FqHZMYbEckGFa8xNnCmTwqHyvHg8bM1XathLwUHR6kuUlHS0SL+LavdvWCn9WJ6hY26 OJWhlvLfXDx4cta8hgrdB4a20/0iPga5aN9GTHSgEZODF0hP0HpmNhLQqGiyIwa4+YgY UXg6MZ9Fqfga9qif2EBDvNTlPVInJA3acDw6guviE9fN0Y6OeqlSeQvWgWfACKpmt11V ycyrTmZI7L7/XiN8L+ykmOuM+fPbUPDTJLk3xxScfm82rSBp+CByTbvLzFy/leMfsUUu d3NQ== 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; bh=7wS/3mFCS4aCPBPI1Oe7G3kqLR6T44f9pzkRkkIG4K0=; b=eYAmtE2hPqksNU7hJ/z5eNgCrFwVd6X7mWGUEYQA2JVoRkTCNjd++/ViQPanRxtFH3 UzgEvtunLt1NwRNSrXCeYKnOK5aCvk3ojTtSK0MpjBcc/agNoV5wOvZ0Z9QxchChNEgx eh73g+A+rxMOFtFM3a7mp/Di2ADkkr4SPLT45mSL+zfvfafaCOtcBJGUISUEEEK+rHxS 7xcPhnNCpoQuh2H92SbKZqnz+/W3oc/EbhS1h4mVahL+M3/9cdWT6p4OQd8JEdgSnlWy 59Xo3Nr2I5kIU/6oPPrwaWOIcqvQPWNNiwvLxBmX+X3qydC3uMlnlTh3my4q6+zcvkrF +tlg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 k2si8613387edf.160.2020.12.19.05.07.48; Sat, 19 Dec 2020 05:08:10 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbgLSNGg (ORCPT + 99 others); Sat, 19 Dec 2020 08:06:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:51090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728463AbgLSNDt (ORCPT ); Sat, 19 Dec 2020 08:03:49 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 5.4 23/34] ALSA: usb-audio: Fix control access overflow errors from chmap Date: Sat, 19 Dec 2020 14:03:20 +0100 Message-Id: <20201219125342.530100217@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201219125341.384025953@linuxfoundation.org> References: <20201219125341.384025953@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: Takashi Iwai commit c6dde8ffd071aea9d1ce64279178e470977b235c upstream. The current channel-map control implementation in USB-audio driver may lead to an error message like "control 3:0:0:Playback Channel Map:0: access overflow" when CONFIG_SND_CTL_VALIDATION is set. It's because the chmap get callback clears the whole array no matter which count is set, and rather the false-positive detection. This patch fixes the problem by clearing only the needed array range at usb_chmap_ctl_get(). Cc: Link: https://lore.kernel.org/r/20201211130048.6358-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/stream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -193,16 +193,16 @@ static int usb_chmap_ctl_get(struct snd_ struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); struct snd_usb_substream *subs = info->private_data; struct snd_pcm_chmap_elem *chmap = NULL; - int i; + int i = 0; - memset(ucontrol->value.integer.value, 0, - sizeof(ucontrol->value.integer.value)); if (subs->cur_audiofmt) chmap = subs->cur_audiofmt->chmap; if (chmap) { for (i = 0; i < chmap->channels; i++) ucontrol->value.integer.value[i] = chmap->map[i]; } + for (; i < subs->channels_max; i++) + ucontrol->value.integer.value[i] = 0; return 0; }