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 05BB235E1D5; Sat, 12 Sep 2026 19:48:18 +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=1789242500; cv=none; b=ON/zaA0zd96nuZ8LzJ7D8qcm7zXuCC6LwlEFnGrLu9dBF72CvEKb284mp0IWLJ0BMz7emugWZ2WchoYzLQekRikMg+B4G3PeJKlYNFhTubzh+X4dVH06BwSHvsRuoZa6MkPsr2vPfFqygNqrpMkJrqZWmgNenca0kwBz758Ir60= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789242500; c=relaxed/simple; bh=8Ji/TordrDKak8qPMaTY/0OEXvcE2p3GCl84Z4R1LXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HZtHJr/F6uepotD8A2DXGyQ4/6zUGT66kCDbvU45uzvRWOhjLuHZILGjS5vEeVgMPHSxoVbaXxMJurytiwt7N1nyJi3E38w6Ylxj8Y3mMf+U378xEMqYs9LGrvVsfHW7LjwGE36vT6cOzake1q+DCBR1FipihS59/Gfq0/oHAxg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=j8+V9Js3; 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="j8+V9Js3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EDF81F000FF; Sat, 12 Sep 2026 19:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789242498; bh=cFxJr0EyeHOl/IvoeWSIjiligfroaxoTIkyHyS/mQgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=j8+V9Js36YoRROLb8iFWwaMniV9/4XPuXBKqMobQ0+XRW8aIiKBz5YFUldUdwh4BQ ldJ+35K9jOl5fjIOOuDs+ieX89Bucg2C0tDiw0epTv/BKnvN74Xednrc5KnbNK6biS mBNfsrgkDc6UQZf6n97+OTCLBT5VneJXURpSoTYY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryam Vargas , Sasha Levin Subject: [PATCH 5.10 383/798] greybus: audio: bound the topology section sizes against the fetched size Date: Sat, 12 Sep 2026 09:00:11 +0200 Message-ID: <20260912065525.930991008@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065516.948645775@linuxfoundation.org> References: <20260912065516.948645775@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryam Vargas [ Upstream commit 33d8c7b794d2a30637c9d3fcb478f1d3222bef1e ] gb_audio_gb_get_topology() fetches a topology blob of a module-supplied size, and gbaudio_tplg_parse_data() then walks it by adding the module-supplied size_dais, size_controls and size_widgets fields to form the control, widget and route section offsets. Those le32 sizes are never checked against the fetched blob, so a module reporting a small topology size but large section sizes makes the offsets point past the allocation, and parsing reads out of bounds. Reject a topology whose section sizes do not fit within the fetched size before it is parsed. Fixes: 184992e305f1 ("greybus: audio: Add Greybus Audio Device Class Protocol helper routines") Signed-off-by: Bryam Vargas Link: https://patch.msgid.link/20260616-b4-disp-4352e8b0-v1-1-3e09f62e0ad5@proton.me Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/greybus/audio_gb.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/staging/greybus/audio_gb.c b/drivers/staging/greybus/audio_gb.c index 9d8994fdb41a2..144591f1a5128 100644 --- a/drivers/staging/greybus/audio_gb.c +++ b/drivers/staging/greybus/audio_gb.c @@ -37,6 +37,19 @@ int gb_audio_gb_get_topology(struct gb_connection *connection, return ret; } + /* + * The size_* fields are supplied by the module and are used by + * gbaudio_tplg_parse_data() to compute offsets into the blob; make + * sure the sections fit within the fetched topology, so walking it + * cannot read out of bounds. + */ + if ((u64)le32_to_cpu(topo->size_dais) + le32_to_cpu(topo->size_controls) + + le32_to_cpu(topo->size_widgets) + le32_to_cpu(topo->size_routes) > + size - sizeof(*topo)) { + kfree(topo); + return -EINVAL; + } + *topology = topo; return 0; -- 2.53.0