Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9176702pxu; Mon, 28 Dec 2020 08:29:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8xTICH1dC8/SrWq75IHsDoP2vMmjIHzhFjTHxmC4uVNdQW6lDc5eqsz5WYZ7DxvAlmCWg X-Received: by 2002:aa7:c3c2:: with SMTP id l2mr42090027edr.15.1609172960377; Mon, 28 Dec 2020 08:29:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172960; cv=none; d=google.com; s=arc-20160816; b=YBRK4WoRlE9lFu6BO7ZxBPz4Ayw8hWelztskjoYMdJC4vdR6x5+P6ZUtGatCubbgis nGargAeBbXKrOX1U5q5czPpc8/QsDnwgah1JthgSzaHrBWv3cUHGFoIvy13VFDLUGlRl 4XY7xrXMg6X3siIlZfJfDcaaLRSEpjm2wUdocyic/7ZeqMAS4SXHMXyqyv7iWlf3kF3f lPvn0Gw27k5jK/+uhn3Zh4Snmmga+OU4ssPVTvChhDcKvv7k3rWV1XH9eEM6cwMBU8Bw rtKArxtWabHewpNC9rOjapYb80EV7wfMfZFQmxFv8aQ7+RQPQsk1bLjcfF+HyzWqLq9J sEYw== 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=pVNw54b49RtDElY57MxWmxunLHVAKdS38zLIxS6NpxA=; b=p4N5rM9n724Sl8bMWRNhsgQMva2DGX95+QU8rY7G+GJgj1RIAYlyLJiFUt9VQQ98+Z idAL7lBWXV82uJOygKaj48NcD1/KB8rge7FhHuusL7akIWlbklUwU9rfPXsh1Iyr3Eqe WSZspc8TjsON5WFrPXGASrt4JXXnACGePcmopzINMpJo0k35Se+K0k+Nq38t7XqMb+mA S3beAQ4jIq6JSB/1l6XvDE168TJmEV0m4qYVVpUuDFQDXI2LJmCIOKv4wG5R8QlPXanN 7L0dK7DwAKaKS5JO11Z8zXZDfR5NVRG1xea/5krD3U9+trA+P7HFzOHd2tq6DkVbcHdI SCug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NZmJZoU4; 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 s16si19347097ejz.97.2020.12.28.08.28.57; Mon, 28 Dec 2020 08:29:20 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NZmJZoU4; 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 S1730931AbgL1Q1W (ORCPT + 99 others); Mon, 28 Dec 2020 11:27:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:35728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730914AbgL1NIW (ORCPT ); Mon, 28 Dec 2020 08:08:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A2B520776; Mon, 28 Dec 2020 13:08:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160886; bh=i4mlgf1ETnynvb/IiFRi9wV8TT8jHuPnzxerrq2DIbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NZmJZoU4iAFk/PcVL4MkOJvSrLwsmARiRdULdp9rha1ucoY0x0Pgd4w5fBdIl7Zik vaFkB2x+QCsPt2z8i1CfX7fE0NqcOp3528SdLh1N4bQeKh8Mm/pTsX5z5PQAL7PfAU +3/MwQXy/eYBY2qO/sCEanpxu77aqfpzlMB76HSo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.14 028/242] ALSA: usb-audio: Fix control access overflow errors from chmap Date: Mon, 28 Dec 2020 13:47:13 +0100 Message-Id: <20201228124906.051463137@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 @@ -185,16 +185,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; }