CVE-2025-37832: cpufreq: sun50i: prevent out-of-bounds access
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
cpufreq: sun50i: prevent out-of-bounds access
A KASAN enabled kernel reports an out-of-bounds access when handling the nvmem cell in the sun50i cpufreq driver:
==================================================================
BUG: KASAN: slab-out-of-bounds in sun50i_cpufreq_nvmem_probe+0x180/0x3d4 Read of size 4 at addr ffff000006bf31e0 by task kworker/u16:1/38
This is because the DT specifies the nvmem cell as covering only two bytes, but we use a u32 pointer to read the value. DTs for other SoCs indeed specify 4 bytes, so we cannot just shorten the variable to a u16.
Fortunately nvmem_cell_read() allows to return the length of the nvmem cell, in bytes, so we can use that information to only access the valid portion of the data.
To cover multiple cell sizes, use memcpy() to copy the information into a zeroed u32 buffer, then also make sure we always read the data in little endian fashion, as this is how the data is stored in the SID efuses.
The Linux kernel CVE team has assigned CVE-2025-37832 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.10 with commit 6cc4bcceff9af0e6be9738096d95e4ba75e75123 and fixed in 6.12.26 with commit 40bf7f560ca4c2468d518cebf14561bc864f58f8 Issue introduced in 6.10 with commit 6cc4bcceff9af0e6be9738096d95e4ba75e75123 and fixed in 6.14.5 with commit dba5a1f963cf781c0b60f4b7f07465a6c687c27e Issue introduced in 6.10 with commit 6cc4bcceff9af0e6be9738096d95e4ba75e75123 and fixed in 6.15-rc4 with commit 14c8a418159e541d70dbf8fc71225d1623beaf0f
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2025-37832
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/cpufreq/sun50i-cpufreq-nvmem.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/40bf7f560ca4c2468d518cebf14561bc864f58f8 https://git.kernel.org/stable/c/dba5a1f963cf781c0b60f4b7f07465a6c687c27e https://git.kernel.org/stable/c/14c8a418159e541d70dbf8fc71225d1623beaf0f
Quoted 3 lines · Greg Kroah-Hartman
A KASAN enabled kernel reports an out-of-bounds access when handling the nvmem cell in the sun50i cpufreq driver:
[...]
The invalid data that may be read comes from a ROM in the SoC, programmed by the vendor, and is only used to configure CPU frequency and voltage in the cpufreq framework.
Even assuming that improper frequency/voltage settings constitute a security risk, writing to the ROM in question is at least a privileged operation, and may require physical access to the SoC.
I don't think this qualifies as vulnerability.
Giovanni
Quoted 5 lines · Giovanni Gherdovich
Quoted 3 lines · Greg Kroah-Hartman
A KASAN enabled kernel reports an out-of-bounds access when handling the nvmem cell in the sun50i cpufreq driver:
[...]
Quoted 7 lines
The invalid data that may be read comes from a ROM in the SoC, programmed by the vendor, and is only used to configure CPU frequency and voltage in the cpufreq framework.
Even assuming that improper frequency/voltage settings constitute a security risk, writing to the ROM in question is at least a privileged operation, and may require physical access to the SoC.
Obviously there are systems out there that have this issue, with device trees that can trigger this issue, this isn't a matter of "malicious ROM doing bad things" type of issue, it's a "the DT can't express this properly, so we might have taken data from the hardware and handled it in the wrong way" type of issue.
Quoted 1 line
I don't think this qualifies as vulnerability.
I don't see how this is a ROM configuration issue, but rather just a kernel bug in how the hardware is accessed on different types of systems where we previously could not handle such accesses correctly.
thanks,
greg k-h
Quoted 20 lines · Greg KH
Quoted 5 lines · Giovanni Gherdovich
Quoted 3 lines · Greg Kroah-Hartman
A KASAN enabled kernel reports an out-of-bounds access when handling the nvmem cell in the sun50i cpufreq driver:
[...]Quoted 7 lines
The invalid data that may be read comes from a ROM in the SoC, programmed by the vendor, and is only used to configure CPU frequency and voltage in the cpufreq framework.
Even assuming that improper frequency/voltage settings constitute a security risk, writing to the ROM in question is at least a privileged operation, and may require physical access to the SoC.
Obviously there are systems out there that have this issue, with device trees that can trigger this issue, this isn't a matter of "malicious ROM doing bad things" type of issue, it's a "the DT can't express this properly, so we might have taken data from the hardware and handled it in the wrong way" type of issue.
Quoted 5 lines
Quoted 1 line
I don't think this qualifies as vulnerability.
I don't see how this is a ROM configuration issue, but rather just a kernel bug in how the hardware is accessed on different types of systems where we previously could not handle such accesses correctly.
Note, if the maintainer or the developer of the change in question here disagrees with me, great, we'll be glad to revoke this CVE, as we defer to them. But for some reason you didn't include them in this thread :(
thanks,
greg k-h
Quoted 21 lines · Greg KH
Quoted 20 lines · Greg KH
Quoted 5 lines · Giovanni Gherdovich
Quoted 3 lines · Greg Kroah-Hartman
A KASAN enabled kernel reports an out-of-bounds access when handling the nvmem cell in the sun50i cpufreq driver:
[...]Quoted 7 lines
The invalid data that may be read comes from a ROM in the SoC, programmed by the vendor, and is only used to configure CPU frequency and voltage in the cpufreq framework.
Even assuming that improper frequency/voltage settings constitute a security risk, writing to the ROM in question is at least a privileged operation, and may require physical access to the SoC.
Obviously there are systems out there that have this issue, with device trees that can trigger this issue, this isn't a matter of "malicious ROM doing bad things" type of issue, it's a "the DT can't express this properly, so we might have taken data from the hardware and handled it in the wrong way" type of issue.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
I don't think this qualifies as vulnerability.
I don't see how this is a ROM configuration issue, but rather just a kernel bug in how the hardware is accessed on different types of systems where we previously could not handle such accesses correctly.
Thanks for clarifying this aspect. I'll move to a different objection, which is that the incorrect power management configuration that may result from this bug doesn't constitute a security vulnerability. It seems to me the CPU won't run at the intended clock, which is definitely a bug but not a CVE.
I'm CC'ing the change author and the subsystem maintainers to hear their opinion.
Quoted 3 lines
Note, if the maintainer or the developer of the change in question here disagrees with me, great, we'll be glad to revoke this CVE, as we defer to them. But for some reason you didn't include them in this thread :(
Sure, you're right, I forgot to include them, fixed now.
Yangtao Li, Rafael, Viresh, Andre:
I'm asking Greg and the kernel CNA to reconsider the assignment of CVE status to the bug fixed by 14c8a418159e541d70dbf8fc71225d1623beaf0f ("cpufreq: sun50i: prevent out-of-bounds access").
You can find the CVE announcement email at
https://lore.kernel.org/linux-cve-announce/2025050824-CVE-2025-37832-e235@gregkh/
If any of you thinks the status of CVE is well justified in this case, I'd appreciated if you could reply here, so I can make a mental note for similar future cases.
Thanks,
Giovanni
On Fri, 30 May 2025 20:00:37 +0200
Giovanni Gherdovich <[email protected]> wrote:
Hi,
I don't think this qualifies as a CVE, the issue was more theoretical. But I don't have much experience with what deserves a CVE and what not, so I can just present some insights:
Quoted 11 lines · Greg KH
Quoted 10 lines · Greg KH
Quoted 9 lines · Giovanni Gherdovich
Quoted 8 lines · Greg Kroah-Hartman
Quoted 3 lines
A KASAN enabled kernel reports an out-of-bounds access when handling the nvmem cell in the sun50i cpufreq driver:
[...]The invalid data that may be read comes from a ROM in the SoC, programmed by the vendor, and is only used to configure CPU frequency and voltage in the cpufreq framework.
So "potentially invalid data read from the ROM" is an issue the we have regardless, this patch doesn't change that. And you cannot put arbitrary voltages or frequencies in the OTP fuses, the value read is just used to select one of the OPPs defined in the DT. If you want to attack the system by heavily overclocking or baking it with a high voltage, you can just change the limits in the DT. Not sure if that's easier or harder than accessing the hardware, though.
But more importantly, looking at this particular patch: This effectively limits the access size of the value we read from the SID OTP driver, from always 4 bytes to what the DT says, typically 2 bytes. But we actually mask the value in the code anyway later at the moment, so the upper 16 bits are always discarded.
Which means that as it stands at the moment, there is no real change in what values are used. I just did the change as it was clearly incorrect, and I wanted to prevent any issues, in case of code changes later.
Hope that helps!
Cheers,
Andre
Quoted 45 lines
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Even assuming that improper frequency/voltage settings constitute a security risk, writing to the ROM in question is at least a privileged operation, and may require physical access to the SoC.
Obviously there are systems out there that have this issue, with device trees that can trigger this issue, this isn't a matter of "malicious ROM doing bad things" type of issue, it's a "the DT can't express this properly, so we might have taken data from the hardware and handled it in the wrong way" type of issue.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
I don't think this qualifies as vulnerability.
I don't see how this is a ROM configuration issue, but rather just a kernel bug in how the hardware is accessed on different types of systems where we previously could not handle such accesses correctly.
Thanks for clarifying this aspect. I'll move to a different objection, which is that the incorrect power management configuration that may result from this bug doesn't constitute a security vulnerability. It seems to me the CPU won't run at the intended clock, which is definitely a bug but not a CVE.
I'm CC'ing the change author and the subsystem maintainers to hear their opinion.
Quoted 3 lines
Note, if the maintainer or the developer of the change in question here disagrees with me, great, we'll be glad to revoke this CVE, as we defer to them. But for some reason you didn't include them in this thread :(
Sure, you're right, I forgot to include them, fixed now.
Yangtao Li, Rafael, Viresh, Andre:
I'm asking Greg and the kernel CNA to reconsider the assignment of CVE status to the bug fixed by14c8a418159e541d70dbf8fc71225d1623beaf0f("cpufreq: sun50i: prevent out-of-bounds access").
You can find the CVE announcement email at
https://lore.kernel.org/linux-cve-announce/2025050824-CVE-2025-37832-e235@gregkh/If any of you thinks the status of CVE is well justified in this case, I'd appreciated if you could reply here, so I can make a mental note for similar future cases.
Thanks,
Giovanni
Hello,
Quoted 17 lines · Andre Przywara
Hi,
I don't think this qualifies as a CVE, the issue was more theoretical. But I don't have much experience with what deserves a CVE and what not, so I can just present some insights:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines · Giovanni Gherdovich
Quoted 8 lines · Greg Kroah-Hartman
Quoted 3 lines
A KASAN enabled kernel reports an out-of-bounds access when handling the nvmem cell in the sun50i cpufreq driver:
[...]The invalid data that may be read comes from a ROM in the SoC, programmed by the vendor, and is only used to configure CPU frequency and voltage in the cpufreq framework.
Quoted 7 lines
So "potentially invalid data read from the ROM" is an issue the we have regardless, this patch doesn't change that. And you cannot put arbitrary voltages or frequencies in the OTP fuses, the value read is just used to select one of the OPPs defined in the DT. If you want to attack the system by heavily overclocking or baking it with a high voltage, you can just change the limits in the DT. Not sure if that's easier or harder than accessing the hardware, though.
I see. Right, my initial comment regarding the ROM content was missing the core of the problem.
Quoted 8 lines
But more importantly, looking at this particular patch: This effectively limits the access size of the value we read from the SID OTP driver, from always 4 bytes to what the DT says, typically 2 bytes. But we actually mask the value in the code anyway later at the moment, so the upper 16 bits are always discarded.
Which means that as it stands at the moment, there is no real change in what values are used. I just did the change as it was clearly incorrect, and I wanted to prevent any issues, in case of code changes later.
Ok, thanks for clarifying that in the present form, the code behaves the same before and after the fix (the upper 16 bits discarded anyway). Your fix improves the code and makes it future-proof.
Greg:
given this information, and Andre (developer of the change) saying at the beginning of his message that he thinks the bug shouldn't be a CVE, do you think the CVE can be revoked?
Thanks,
Giovanni
Quoted 44 lines · Giovanni Gherdovich
Hello,
Quoted 17 lines · Andre Przywara
Hi,
I don't think this qualifies as a CVE, the issue was more theoretical. But I don't have much experience with what deserves a CVE and what not, so I can just present some insights:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines · Giovanni Gherdovich
Quoted 8 lines · Greg Kroah-Hartman
Quoted 3 lines
A KASAN enabled kernel reports an out-of-bounds access when handling the nvmem cell in the sun50i cpufreq driver:
[...]The invalid data that may be read comes from a ROM in the SoC, programmed by the vendor, and is only used to configure CPU frequency and voltage in the cpufreq framework.
Quoted 7 lines
So "potentially invalid data read from the ROM" is an issue the we have regardless, this patch doesn't change that. And you cannot put arbitrary voltages or frequencies in the OTP fuses, the value read is just used to select one of the OPPs defined in the DT. If you want to attack the system by heavily overclocking or baking it with a high voltage, you can just change the limits in the DT. Not sure if that's easier or harder than accessing the hardware, though.
I see. Right, my initial comment regarding the ROM content was missing the core of the problem.
Quoted 8 lines
But more importantly, looking at this particular patch: This effectively limits the access size of the value we read from the SID OTP driver, from always 4 bytes to what the DT says, typically 2 bytes. But we actually mask the value in the code anyway later at the moment, so the upper 16 bits are always discarded.
Which means that as it stands at the moment, there is no real change in what values are used. I just did the change as it was clearly incorrect, and I wanted to prevent any issues, in case of code changes later.Ok, thanks for clarifying that in the present form, the code behaves the same before and after the fix (the upper 16 bits discarded anyway). Your fix improves the code and makes it future-proof.
Quoted 5 lines
Greg:
given this information, and Andre (developer of the change) saying at the beginning of his message that he thinks the bug shouldn't be a CVE, do you think the CVE can be revoked?
Now revoked, thanks!
greg k-h