From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29DF547012C; Tue, 21 Jul 2026 19:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663402; cv=none; b=X2vbgbTORnFcQrvnCydZr3fbP1LE0FSCo3R3q+zKqd3wiVq+enNbVrveOZIhmAOVQFCDcx2pHvYmsqjIHMemz150pEYQCAA9ZO4mFn0fl0h8Gh05Y++aCPyaxhbeoaOZgk8r6aFJI96aBleYKb0Zv+ynTf8GjHaewvFSMPEiVyI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663402; c=relaxed/simple; bh=Xmz1Egt+InC9Y26mm/9XGBz7/msnosakY3NvTRSqx68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RahhuwfVeKeKlnqM1yoR5IS4apnTTjwZ/XKaPbtRfGL1Nt35dhPDMoFw3bakUfwpwFYZUSqGc9dTuZgocwtEuQC3Xzkcegp7K83wGDrzUNbW0u0kT+kE94gnjkHofqr3emrYYgrwmb/Vjs2Bx0E/ol3VeIAjNiG/gHPPm7T/fS8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cYAUCYQX; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="cYAUCYQX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6FA71F000E9; Tue, 21 Jul 2026 19:50:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663401; bh=K/EmlUPdOhvFOB3/ORB3j1jC/Jd/H5G/nLTTkBZs86w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cYAUCYQXw6pJmKDdBBZY6Q2sp6/k1d6hqQTs+4KaX2L8ARfPz4CLcPmRiNlkQE49J vCzLAsnp34Ac64LT/tBziQbelitFbB2BNMYVVjNtB7EcugUVXtVhAx3XA3u40q/WtM JhjK2d1njYzhSKEOCN2WsJWLpVYQWMlGCcuwUFQk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Peter Ujfalusi , Liam Girdwood , Bard Liao , Mark Brown Subject: [PATCH 6.12 0809/1276] ASoC: SOF: ipc4-control: Fix TOCTOU in sof_ipc4_bytes_put Date: Tue, 21 Jul 2026 17:20:52 +0200 Message-ID: <20260721152504.172356117@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Ujfalusi commit 3ad673e7139cf214afd24321a829aad6575f4163 upstream. In sof_ipc4_bytes_put(), the copy size is derived from the old data->size in the buffer rather than the incoming new data's size field from ucontrol. If the new data has a different size, the copy uses the wrong length: it may truncate valid data or copy stale bytes. Fix by validating and using the incoming data's sof_abi_hdr.size from ucontrol before copying. Fixes: a062c8899fed ("ASoC: SOF: ipc4-control: Add support for bytes control get and put") Cc: stable@vger.kernel.org Signed-off-by: Peter Ujfalusi Reviewed-by: Liam Girdwood Reviewed-by: Bard Liao Link: https://patch.msgid.link/20260609083458.31193-2-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/sof/ipc4-control.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/sound/soc/sof/ipc4-control.c +++ b/sound/soc/sof/ipc4-control.c @@ -455,6 +455,8 @@ static int sof_ipc4_bytes_put(struct snd struct snd_soc_component *scomp = scontrol->scomp; struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct sof_abi_hdr *data = cdata->data; + const struct sof_abi_hdr *new_hdr = + (const struct sof_abi_hdr *)ucontrol->value.bytes.data; size_t size; int ret; @@ -465,15 +467,16 @@ static int sof_ipc4_bytes_put(struct snd return -EINVAL; } - /* scontrol->max_size has been verified to be >= sizeof(struct sof_abi_hdr) */ - if (data->size > scontrol->max_size - sizeof(*data)) { + /* Validate the new data's size, not the old one */ + if (new_hdr->size > scontrol->max_size - sizeof(*new_hdr)) { dev_err_ratelimited(scomp->dev, "data size too big %u bytes max is %zu\n", - data->size, scontrol->max_size - sizeof(*data)); + new_hdr->size, + scontrol->max_size - sizeof(*new_hdr)); return -EINVAL; } - size = data->size + sizeof(*data); + size = new_hdr->size + sizeof(*new_hdr); /* copy from kcontrol */ memcpy(data, ucontrol->value.bytes.data, size);