FAILED: patch "[PATCH] cpu: hotplug: Bound hotplug states sysfs output" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-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.10.y
git checkout FETCH_HEAD
git cherry-pick -x 86f436567f2516a0083b210bedc933544826a2c3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072036-pentagon-armory-48cd@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 86f436567f2516a0083b210bedc933544826a2c3 Mon Sep 17 00:00:00 2001
From: Bradley Morgan <[email protected]>
Date: Fri, 19 Jun 2026 16:37:18 +0000
Subject: [PATCH] cpu: hotplug: Bound hotplug states sysfs output
states_show() adds CPU hotplug state names into a single sysfs buffer using sprintf(). With enough registered states, this can write past the end of the PAGE_SIZE buffer.
Use sysfs_emit_at() so output is bounded.
kernel/cpu.c +4 -8
@@ -2865,21 +2865,17 @@ static const struct attribute_group cpuhp_cpu_attr_group = { .name = "hotplug", }; -static ssize_t states_show (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t states_show (struct device *dev,struct device_attribute *attr,char *buf) { -ssize_t cur, res =0 ; +ssize_t res =0 ;int i;mutex_lock (&cpuhp_state_mutex);for (i =CPUHP_OFFLINE ; i <=CPUHP_ONLINE ; i++) {struct cpuhp_step *sp =cpuhp_get_step (i); -if (sp->name) { - cur =sprintf (buf,"%3d: %s\n" , i, sp->name); - buf += cur; - res += cur; - } +if (sp->name) + res +=sysfs_emit_at (buf, res,"%3d: %s\n" , i, sp->name); }mutex_unlock (&cpuhp_state_mutex);return res;
Thomas Gleixner
maintainerPATCH 1/1 cpu: hotplug: Bound hotplug states sysfs output
From: Bradley Morgan <[email protected]>
commit 86f436567f2516a0083b210bedc933544826a2c3 upstream.
states_show() adds CPU hotplug state names into a single sysfs buffer using sprintf(). With enough registered states, this can write past the end of the PAGE_SIZE buffer.
Use sysfs_emit_at() so output is bounded.
--- kernel/cpu.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
---
kernel/cpu.c +3 -6
@@ -2319,18 +2319,15 @@ static const struct attribute_group cpuhstatic ssize_t show_cpuhp_states (struct device *dev,struct device_attribute *attr,char *buf) { -ssize_t cur, res =0 ; +ssize_t res =0 ;int i;mutex_lock (&cpuhp_state_mutex);for (i =CPUHP_OFFLINE ; i <=CPUHP_ONLINE ; i++) {struct cpuhp_step *sp =cpuhp_get_step (i); -if (sp->name) { - cur =sprintf (buf,"%3d: %s\n" , i, sp->name); - buf += cur; - res += cur; - } +if (sp->name) + res +=sysfs_emit_at (buf, res,"%3d: %s\n" , i, sp->name); }mutex_unlock (&cpuhp_state_mutex);return res;
Re: [PATCH 5.10.y] cpu: hotplug: Bound hotplug states sysfs output
Quoted 34 lines · Thomas Gleixner
From: Bradley Morgan <[email protected]>
commit
86f436567f2516a0083b210bedc933544826a2c3upstream.
states_show()adds CPU hotplug state names into a single sysfs buffer usingsprintf(). With enough registered states, this can write past the end of thePAGE_SIZEbuffer.Use
sysfs_emit_at()so output is bounded.Fixes 98f8cdce1db5 ("cpu/hotplug: Add sysfs state interface")Signed-off-by Bradley Morgan <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>---
kernel/cpu.c| 9 +++------1 file changed, 3 insertions(+), 6 deletions(-)---
kernel/cpu.c +1
-1@@ -2319,18 +2319,15 @@ static const struct attribute_group cpuhstatic ssize_t show_cpuhp_states (struct device *dev,struct device_attribute *attr,char *buf) { -ssize_t cur, res =0 ; +ssize_t res =0 ;int i;mutex_lock (&cpuhp_state_mutex);for (i =CPUHP_OFFLINE ; i <=CPUHP_ONLINE ; i++) {struct cpuhp_step *sp =cpuhp_get_step (i);
kernel/cpu.c static const struct attribute_group cpuh · line 2333
Quoted 10 lines
kernel/cpu.c +2
-5-if (sp->name) { - cur =sprintf (buf,"%3d: %s\n" , i, sp->name); - buf += cur; - res += cur; - } +if (sp->name) + res +=sysfs_emit_at (buf, res,"%3d: %s\n" , i, sp->name); }mutex_unlock (&cpuhp_state_mutex);return res;
Cheers Thomas! :)
Thanks!
Re: [PATCH 5.10.y] cpu: hotplug: Bound hotplug states sysfs output
In reply to Thomas GleixnerQuoted 5 lines
states_show()adds CPU hotplug state names into a single sysfs buffer usingsprintf(). With enough registered states, this can write past the end of thePAGE_SIZEbuffer.Use
sysfs_emit_at()so output is bounded.
Queued for 5.10, thanks.
Signature · 2 lines
Thanks, Sasha