From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387063; b=XkBYw8NJbm7z8Edavugset1ppe3NbyrGD5isT0zTkBQzgYoihPA5h/pR7TMGBJAfR7UY K2pu/Gw0zDpPdQDEf9Y7lZW/0Uvz1oU8LBdazbRQibpFwNanWT1ZwTymfAXo8bMB5M65T 1Ye6eJagDDKwiF3Y23+J7kAuwkeXmRlfad0ikSAqCirdgRP+Zeq+nBTY0F3OD771T8pcV 4KbcBmrSaF3xLhIYhGPFuvAKijdL3FZJC9LJkMn56QAb3477aDL9KzON4aqss0TPxfO9+ YczXOfIhoqOGd7q1C1+i7uf3Ku/ouknHQ9kR8+4yvMSSsqxGRxZ8JmdZUTKZYmVEYJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387063; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=eD13hTUtPSiM8JhxOMsZYFUuNW/oe8wWxnBeB8/zq9Y=; b=0eKdn8gzOIHeQTKiQ+cMXFazSB8SgL1vCTwUAXE1GLxS5X4WHoI6luhBqo1FSGJxLIM/ iw6tq9JTzGt+mLQ5jBi0P06HANvHwGlZw7sGExvqYl93Pour9W5EqY9Csz2syAXSCrOvU NA0YT8OQXk+L4JTZoQwr39Mqaeynk8JNpnmpsPqktdPilHiMNNzc3zDzVn3Wuz3zvK0FY i/VtL2yyq6Z4dWTWNEuEsE/vt8Wqh5DaAY2di/EP54A0lCsn9NtE3VxBnHTD+OfNz4ViA 4i5cQDD/Xp2UBCWicCUJ9EGzvX1hHdmd9FAfUKNLigbHk7Y6ZeJr4AEqEH6N0gBUs4w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qwo58wej; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9575606A322; Fri, 4 Dec 2026 12:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qwo58wej Received: by smtp.kernel.org (Postfix) with ESMTPSA id 219F01F000C2; Fri, 4 Dec 2026 12:24:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387063; bh=eD13hTUtPSiM8JhxOMsZYFUuNW/oe8wWxnBeB8/zq9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qwo58wejbgyjT9W2Jg5rTKul75GDd2guaGwQBDA1E5wwfQGXDTL9FTnu2ltfmCmbp ZAcEVy8ue/JQZuPoslyqGF4zYA24SlbN3yvbgktKnit4lZizIXqSCFFlppP5IdhiPE O3HTK6VJs5UOwxONRt3FV8MZmFcv8+HrGLXh7T4I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Richard Fitzgerald , Mark Brown , Sasha Levin Subject: [PATCH 6.1 0119/1059] ASoC: wm_adsp: Prevent negative string length in wm_adsp_control_add() Date: Fri, 4 Dec 2026 18:54:10 +0900 Message-ID: <20261204100647.303220304@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Richard Fitzgerald [ Upstream commit 4d07af76ca41cc1a03240cd3b5f44dc428856214 ] Check that avail does not become < 1 in wm_adsp_control_add(). This prevents overflows during subsequent operations. The main aim is to trap a negative value in avail, but a zero length would mean that the control ends up without a name, so 1 is the smallest valid value. Fixes: b7ede5af62ab6 ("ASoC: wm_adsp: Take prefix into account in control name length") Signed-off-by: Richard Fitzgerald Link: https://patch.msgid.link/20261104133322.1085061-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wm_adsp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index bc9798ea5a25e..74a9db5ecc8f2 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -42,6 +42,9 @@ #define adsp_dbg(_dsp, fmt, ...) \ dev_dbg(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__) +#define adsp_warn_once(_dsp, fmt, ...) \ + dev_warn_once(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__) + #define compr_err(_obj, fmt, ...) \ adsp_err(_obj->dsp, "%s: " fmt, _obj->name ? _obj->name : "legacy", \ ##__VA_ARGS__) @@ -630,6 +633,13 @@ static int wm_adsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl) if (dsp->component->name_prefix) avail -= strlen(dsp->component->name_prefix) + 1; + if (avail < 1) { + adsp_warn_once(dsp, + "%.*s: ALSA prefix too long: control not created\n", + cs_ctl->subname_len, cs_ctl->subname); + return -EINVAL; + } + /* Truncate the subname from the start if it is too long */ if (cs_ctl->subname_len > avail) skip = cs_ctl->subname_len - avail; -- 2.53.0