Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9236169pxu; Mon, 28 Dec 2020 10:04:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdzYzIK+1csHrZy3TAectb5Pd4bN9kjAED0e/kq4KD+4dMFzUviR9DiPjPl21qaGTSZYjD X-Received: by 2002:a17:906:f0cc:: with SMTP id dk12mr43480357ejb.480.1609178668139; Mon, 28 Dec 2020 10:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609178668; cv=none; d=google.com; s=arc-20160816; b=mk2ydQuei+S2B7nenqOLFPMIJsD+BDs5XM9FlPeclKrHWtNrIEV+hbxsvMQXWMfaCH xrOPH2c0pAtykEYlVJaHQ3TxdxRGjtPE1fsZ2Z8sCaDksnigjJ1W4GG2/sXU3+nWKoum ZyZByIYK4w52FEtom/2wQR5zQnc/80R0hYhyc9mX0EdRS4SWGc6YSgVDAcxL+OsepFWe kgLYMq79SldSKS89B2i8En+tbxfjQR+LJcIEayJZmVSUsZoGOtSoXn7/gDc9Mvtfy4iR rEYnV1K6n5Xt3Rgrq1PSu2OnjqitsWVya2Z0OESz4qiSduPLd7guHcOJr9lXAhi8PrBL Dsgg== 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=V5LlP8x0iMrejnhTo3AlqeUnLW+5DwDZGnNifsK+NFE=; b=qjLva8xe0v7b/XxmayLwJyHwDmcBU3+ufR4fGLo8Qw8K+/pcK4lOD1z0hlxbmvihID k8jJ1GFVaJMUK3Nyu6MDaaPu+qD+FBga9OV2OypdcltSob47oT83ekCf1VsohOuHHRX5 zuVByjHWXS3p1vy8lTE/Ks9qX6kRrEMkz1hTV86qYclQI7rGSlKpftnqkR/1Di/HqyOa yoC3gsgNPtsZYN4fmWVA3FCyTSiIxxICinBrA97f2h0w/w13EYmM1hKcTTSv/pxU9i11 5RXs8Wh1Td4w+D541zkkj3ej9z+Sw8w6x6h6JJfGX+dpG5lq8QfZtTcQah5tCOaIf+Wz EDoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WypNJues; 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 f11si19023203ejw.546.2020.12.28.10.04.06; Mon, 28 Dec 2020 10:04:28 -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=WypNJues; 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 S2388236AbgL1NWW (ORCPT + 99 others); Mon, 28 Dec 2020 08:22:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:50142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388095AbgL1NVg (ORCPT ); Mon, 28 Dec 2020 08:21:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EBA25208BA; Mon, 28 Dec 2020 13:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161655; bh=e+yxeZxMeAL9DiZyVGoWrKdVC3Kb41WnnxKacxxwxkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WypNJuessSf6+KcUVb3YJ8a79Jak6Ic6kdaaYi2E4ql1mgbekSRAR11BLifZ7jGK1 NjVR3m6R2oKQPLmtjVLvj/b+UJ/GcuaggkCjkckMxeqs+Y3uahWMxdO9Ehgl+h9Ay2 SSUgjIaP/0uzcoThmzLJOZVObwQOy3xvhfz34B7A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.19 042/346] ALSA: usb-audio: Fix control access overflow errors from chmap Date: Mon, 28 Dec 2020 13:46:01 +0100 Message-Id: <20201228124921.822780571@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124919.745526410@linuxfoundation.org> References: <20201228124919.745526410@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 @@ -198,16 +198,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; }