Skip to content

Commit 964e01f

Browse files
pvts-matPlaidCat
authored andcommitted
arm64: cacheinfo: Avoid out-of-bounds write to cacheinfo array
jira VULN-54125 cve CVE-2025-21785 commit-author Radu Rendec <[email protected]> commit 875d742 The loop that detects/populates cache information already has a bounds check on the array size but does not account for cache levels with separate data/instructions cache. Fix this by incrementing the index for any populated leaf (instead of any populated level). Fixes: 5d425c1 ("arm64: kernel: add support for cpu cache information") Signed-off-by: Radu Rendec <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]> (cherry picked from commit 875d742) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent 00366e2 commit 964e01f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/arm64/kernel/cacheinfo.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,18 @@ static int __populate_cache_leaves(unsigned int cpu)
9494
unsigned int level, idx;
9595
enum cache_type type;
9696
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
97-
struct cacheinfo *this_leaf = this_cpu_ci->info_list;
97+
struct cacheinfo *infos = this_cpu_ci->info_list;
9898

9999
for (idx = 0, level = 1; level <= this_cpu_ci->num_levels &&
100-
idx < this_cpu_ci->num_leaves; idx++, level++) {
100+
idx < this_cpu_ci->num_leaves; level++) {
101101
type = get_cache_type(level);
102102
if (type == CACHE_TYPE_SEPARATE) {
103-
ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level);
104-
ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level);
103+
if (idx + 1 >= this_cpu_ci->num_leaves)
104+
break;
105+
ci_leaf_init(&infos[idx++], CACHE_TYPE_DATA, level);
106+
ci_leaf_init(&infos[idx++], CACHE_TYPE_INST, level);
105107
} else {
106-
ci_leaf_init(this_leaf++, type, level);
108+
ci_leaf_init(&infos[idx++], type, level);
107109
}
108110
}
109111
return 0;

0 commit comments

Comments
 (0)