Fix buffer overflow in trans_stat_show().
Convert simple snprintf to the more secure scnprintf with size of
PAGE_SIZE.
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.
Link: https://lore.kernel.org/all/20231024183016.14648-2-ansuelsmth@gmail.com/
Cc: stable@vger.kernel.org
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218041
Fixes: e552bbaf5b ("PM / devfreq: Add sysfs node for representing frequency transition information.")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CVE-2023-52614
(backported from commit 08e23d05fa6dc4fc13da0ccf09defdd4bbc92ff4)
[koichiroden: crafted a custom diff that suits our tree.
The key missing commits missing from our tree are as follows:
commit b5d281f6c16d ("PM / devfreq: Rework freq_table to be local to devfreq struct")
commit a03dacb0316f ("PM / devfreq: Add cpu based scaling support to passive governor")
commit 483d557ee9 ("PM / devfreq: Clean up the devfreq instance name in sysfs attr")
commit 1ebd0bc0e8 ("PM / devfreq: Move statistics to separate struct devfreq_stats")
commit 14a3439681 ("PM / devfreq: Add clearing transitions stats")
commit b76b3479da ("PM / devfreq: Change time stats to 64-bit")
commit 5c0f6c7959 ("PM / devfreq: Add new interrupt_driven flag for governors")]
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Acked-by: Thibault Ferrante <thibault.ferrante@canonical.com>
Acked-by: Mehmet Basaran <mehmet.basaran@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>