mbox series

[v3,0/2] OPP: fix buffer overflow in indexed freq and bandwidth reads

Message ID 20241203-topic-opp-fix-assert-index-check-v3-0-1d4f6f763138@linaro.org
Headers show
Series OPP: fix buffer overflow in indexed freq and bandwidth reads | expand

Message

Neil Armstrong Dec. 3, 2024, 8:12 a.m. UTC
While fixing a crash when calling dev_pm_opp_find_bw_ceil()
because the bandwdith table wasn't initialized, it happens
the index is not checked aswell for indexed freq finds.

In order to properly fix that, pass the index to the assert
function and add a specialized assert function for freq
and bandwidth.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
Changes in v3:
- Use unsigned int for index on assert callback
- Link to v2: https://lore.kernel.org/r/20241129-topic-opp-fix-assert-index-check-v2-0-386b2dcbb9a6@linaro.org

Changes in v2:
- keep existing check for non indexed find functions
- use assert_clk_index only for indexed find functions
- fixup commit messages
- Link to v1: https://lore.kernel.org/r/20241128-topic-opp-fix-assert-index-check-v1-0-cb8bd4c0370e@linaro.org

---
Neil Armstrong (2):
      OPP: add index check to assert to avoid buffer overflow in _read_freq()
      OPP: fix dev_pm_opp_find_bw_*() when bandwidth table not initialized

 drivers/opp/core.c | 57 ++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 40 insertions(+), 17 deletions(-)
---
base-commit: d5557b27fefccf1942ae0f4a5734aba6751b03bc
change-id: 20241128-topic-opp-fix-assert-index-check-f46fe5c3c7ba

Best regards,

Comments

Viresh Kumar Dec. 4, 2024, 5:34 a.m. UTC | #1
On 03-12-24, 09:12, Neil Armstrong wrote:
> While fixing a crash when calling dev_pm_opp_find_bw_ceil()
> because the bandwdith table wasn't initialized, it happens
> the index is not checked aswell for indexed freq finds.
> 
> In order to properly fix that, pass the index to the assert
> function and add a specialized assert function for freq
> and bandwidth.
> 
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
> Changes in v3:
> - Use unsigned int for index on assert callback
> - Link to v2: https://lore.kernel.org/r/20241129-topic-opp-fix-assert-index-check-v2-0-386b2dcbb9a6@linaro.org

Applied. Thanks.