From: Pierre-Louis Bossart Subject: Re: [PATCH v2] ASoC: dapm: fix out-of-bounds accesses to DAPM lookup tables Date: Mon, 4 Feb 2019 09:08:41 -0600 Message-ID: References: <20190204135914.7413-1-pierre-louis.bossart@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by alsa0.perex.cz (Postfix) with ESMTP id 6451B2674C0 for ; Mon, 4 Feb 2019 16:08:43 +0100 (CET) In-Reply-To: Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Takashi Iwai Cc: liam.r.girdwood@linux.intel.com, alsa-devel@alsa-project.org, broonie@kernel.org, vkoul@kernel.org List-Id: alsa-devel@alsa-project.org > This patch itself looks fine, but maybe a safer implementation would > be to define snd_soc_dapm_max, and define dapm_up_seq[] as > dapm_up_seq[snd_soc_dapm_max]. Yes I thought about this but didn't know why the array was declared with an implicit length. > Also, another worthy change would be to set the priority non-zero, and > trigger WARN_ON() if it hits a zero, i.e. undefined entry. Unfortunately the zero is a legit value today, so we'd have to move all existing values by one. Not sure if it's worth it. Maybe an alternate way to fix this is to define snd_soc_dapm_max and check if the ARRAY_SIZE of dapm_up_seq and dapm_down_seq match. That would trap any changes in the enum that isn't reflected in the _seq look-up tables.