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 D893F288B9; Sat, 12 Sep 2026 16:35:10 +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=1789230912; cv=none; b=DSxpYARcgXLtC9Uashdlo6FTJKUMBp6I1i84oEcOL/dKP9yyrP4oc4TKBSm5ApcEgf4XcPZaz1bnxEBKC7MCQ/8uawtlC6Nju1eWh0qwBsSp4hB9iR3l88a+o7ieWdWrwiifu2GXFOJYji/ss1ImVkmx3shPHdrhQFIowjJDdGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789230912; c=relaxed/simple; bh=lVT2bemuV/n8h+kpHE1B2rhVJntJiVLe3PqOAwbDF0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QFxFnbzEiPFiXhM3sO0pf8/wFA6MUrK7KV4hcqCPllywI6L6LVypli3CSh0asnOiZzDmwbigIacjzCCv0nMhCdq9QaPWA7K7+/J7zj8izrsdXJAPywLA8X8fz7g9UiAMb3u+tnyj+CNa9UNamf1RMy5ARBVeXaUd0SQw8BzBdx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nIWd+2q/; 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="nIWd+2q/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDAFE1F000FF; Sat, 12 Sep 2026 16:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789230910; bh=VXRReDjfM731y0I6QMbmvvkWdIDHVOFkUOlrpSB9qvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nIWd+2q/eAt4AStDziGAL898YnbsTW5PGkQz61s3dcqof9twZTewZq2vm7PUAA4i/ EwwIa52GHWTt6tZrehuAzQXbpNE+hI6kBC9RLIrk7AW/qpC7oCQLD1l8bYxCRjn1d/ 0deVJOt6QTJahslbMQWepelcy6s9ULkkOeSDQELg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Karl Mehltretter , Viresh Kumar , Sasha Levin Subject: [PATCH 6.1 0892/1191] cpufreq: imx6q: fix out-of-bounds write when probed more than once Date: Sat, 12 Sep 2026 09:00:20 +0200 Message-ID: <20260912065608.274584854@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karl Mehltretter [ Upstream commit 8c3afcf27fa4582c1ab912503dc8a4ebb8dc0f82 ] imx6_soc_volt is allocated fresh on every probe, sized to the number of ARM OPPs: imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt), GFP_KERNEL); but it is filled through soc_opp_count, which has static storage and is never reset. A second bind after an unbind keeps indexing from where the first one stopped, and writes past the end of the new array. Unbinding and rebinding the driver on qemu's mcimx6ul-evk, under KASAN: BUG: KASAN: slab-out-of-bounds in imx6q_cpufreq_probe+0x3b0/0xa34 Write of size 4 at addr c5e90480 by task binder/73 imx6q_cpufreq_probe from platform_probe+0x88/0xe4 platform_probe from really_probe+0x108/0x384 bind_store from kernfs_fop_write_iter+0x1b4/0x28c The write lands one u32 past the end of the allocation. soc_opp_count is only read a few lines below the loop that fills it, so it never needed static storage. Make it a local. Fixes: b4573d1d657a ("cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed") Assisted-by: Claude:claude-opus-5 Signed-off-by: Karl Mehltretter Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin --- drivers/cpufreq/imx6q-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 7115f713ba6a1..7f5f1f5c1edbd 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -53,7 +53,6 @@ static unsigned int max_freq; static unsigned int transition_latency; static u32 *imx6_soc_volt; -static u32 soc_opp_count; static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) { @@ -346,6 +345,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) const struct property *prop; const __be32 *val; u32 nr, i, j; + u32 soc_opp_count = 0; cpu_dev = get_cpu_device(0); if (!cpu_dev) { -- 2.53.0