Skip to contentSkip to conversation

FAILED: patch "[PATCH] PM / devfreq: Fix buffer overflow in trans_stat_show" failed to apply to 4.19-stable tree

PATCH [email protected] 1 participant 1 message Jan 26, 2024

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.19.y
git checkout FETCH_HEAD
git cherry-pick -x 08e23d05fa6dc4fc13da0ccf09defdd4bbc92ff4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024012637-creation-woven-808c@gregkh' --subject-prefix 'PATCH 4.19.y' HEAD^..

Possible dependencies:

08e23d05fa6d ("PM / devfreq: Fix buffer overflow in trans_stat_show") b5d281f6c16d ("PM / devfreq: Rework freq_table to be local to devfreq struct") 05723e71234b ("PM / devfreq: passive: Reduce duplicate code when passive_devfreq case") 8c37d01e1a86 ("PM / devfreq: passive: Fix get_target_freq when not using required-opp") 86ad9a24f21e ("PM / devfreq: Add required OPPs support to passive governor") 5f1a9066fcb2 ("PM / devfreq: Add governor attribute flag for specifc sysfs nodes") 0dd25a0d12a1 ("PM / devfreq: Add governor feature flag")
0c309ed17c50 ("PM / devfreq: Add timer type to devfreq_summary debugfs") 27a69714450f ("PM / devfreq: Fix the wrong end with semicolon") 0aae11bcdefb ("PM / devfreq: Fix indentaion of devfreq_summary debugfs node") 483d557ee9a3 ("PM / devfreq: Clean up the devfreq instance name in sysfs attr") 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode") 3bb5ee9aaa34 ("PM / devfreq: Fix a typo in a comment")
3a1ec2e8d8a9 ("PM / devfreq: Change to DEVFREQ_GOV_UPDATE_INTERVAL event name") 6d7434931ac3 ("PM / devfreq: Remove unneeded extern keyword") 490a421bc575 ("PM / devfreq: Add debugfs support with devfreq_summary file") 1ebd0bc0e8ad ("PM / devfreq: Move statistics to separate struct devfreq_stats") 14a343968199 ("PM / devfreq: Add clearing transitions stats") b76b3479dab9 ("PM / devfreq: Change time stats to 64-bit")
2fee1a7cc6b1 ("PM / devfreq: Add new name attribute for sysfs")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 08e23d05fa6dc4fc13da0ccf09defdd4bbc92ff4 Mon Sep 17 00:00:00 2001
From: Christian Marangi <[email protected]>
Date: Tue, 24 Oct 2023 20:30:15 +0200
Subject: [PATCH] PM / devfreq: Fix buffer overflow in trans_stat_show

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.

Fixes e552bbaf5b98 ("PM / devfreq: Add sysfs node for representing frequency transition information.")
Documentation/ABI/testing/sysfs-class-devfreq +3 -0
index 5e6b74f30406..1e7e0bb4c14e 100644
@@ -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 +39 -18

84 lines not on this page · raw message