Skip to contentSkip to conversation

FAILED: patch "[PATCH] PM / devfreq: Fix buffer overflow in trans_stat_show" failed to apply to 5.15-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 5.15-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-5.15.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 '2024012633-cornhusk-gusto-e970@gregkh' --subject-prefix 'PATCH 5.15.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")

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