PM / devfreq: Fix buffer overflow in trans_stat_show
Subsystems (2)
PATCH v2 1/1 PM / devfreq: Fix buffer overflow in trans_stat_show
Fix buffer overflow in trans_stat_show().
Convert simple snprintf to the more secure sysfs_emit.
Add condition checking if we are exceeding PAGE_SIZE and exit early from loop. Also add at the end a warning that we exceeded PAGE_SIZE and that stats is disabled.
Return -EFBIG in the case where we don't have enough space to write the full transition table.
Also document in the ABI that this function can return -EFBIG error.
Fixes e552bbaf5b98 ("PM / devfreq: Add sysfs node for representing frequency transition information.")
Signed-off-by Christian Marangi <[email protected]>
---
Changes v2:
- Squash and use directly sysfs_emit
- Fix typo for df->freq_table[2]
- Reduce check of PAGE_SIZE to only at the start of for loops
Documentation/ABI/testing/sysfs-class-devfreq | 3 ++ drivers/devfreq/devfreq.c | 47 ++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-)
Documentation/ABI/testing/sysfs-class-devfreq +3 -0
@@ -52,6 +52,9 @@ Description: echo 0 > /sys/class/devfreq/.../trans_stat + If the transition table is bigger than PAGE_SIZE, reading + this will return an -EFBIG error. + What: /sys/class/devfreq/.../available_frequencies Date: October 2012 Contact: Nishanth Menon <[email protected]>
drivers/devfreq/devfreq.c +30 -17
75 lines not on this page · raw message
Signature · 1 line
2.43.0