sched/isolation: avoid reading past string in isolcpus parser
PATCH 1/1 sched/isolation: avoid reading past string in isolcpus parser
The function housekeeping_isolcpus_setup() advanced the parser pointer unconditionally after unknown flags.
For an argument like 'isolcpus=unknownflag', with no trailing comma, this can move the pointer past the terminating NUL, and the next loop test reads out of bounds.
Advance only when the current character is a comma separator, preserving existing parsing semantics while avoiding the invalid read.
--- kernel/sched/isolation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/isolation.c +2 -1
@@ -355,7 +355,8 @@ static int __init housekeeping_isolcpus_setup(char *str) }pr_info ("isolcpus: Skipped unknown flag %.*s\n" , len, par); - str++; +if (*str ==',' ) + str++; }/* Default behaviour for isolcpus without flags */
Signature · 1 line
2.47.3
Steven Rostedt
reviewerQuoted 9 lines · On Fri, 6 Mar 2026 14:59:08 -0800 Joseph Salisbury…
The function
housekeeping_isolcpus_setup()advanced the parser pointer unconditionally after unknown flags.For an argument like 'isolcpus=unknownflag', with no trailing comma, this can move the pointer past the terminating NUL, and the next loop test reads out of bounds.
Advance only when the current character is a comma separator, preserving existing parsing semantics while avoiding the invalid read.
Nice catch.
Quoted 14 lines
Fixes 3662daf02350 ("sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters")Assisted-by Codex:GPT-5.3Signed-off-by Joseph Salisbury <[email protected]>--- kernel/sched/isolation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/sched/isolation.c +0
-0
kernel/sched/isolation.c static int __init housekeeping_isolcpus_setup(char *str) · line 359
Quoted 6 lines
kernel/sched/isolation.c +2
-1@@ -355,7 +355,8 @@ static int __init housekeeping_isolcpus_setup(char *str) }pr_info ("isolcpus: Skipped unknown flag %.*s\n" , len, par); - str++; +if (*str ==',' ) + str++;
Although it should only be a ',' here, I think it's more robust to just test against non-nul character. As the bug only triggers if str points to the nul character. No need to make this check depend on the rest of the algorithm.
if (*str) str++;
-- Steve
Quoted 3 lines
kernel/sched/isolation.c +0
-0}/* Default behaviour for isolcpus without flags */
Re: [External] : Re: [PATCH] sched/isolation: avoid reading past string in isolcpus parser
Quoted 38 lines · Steven Rostedt
Quoted 9 lines · On Fri, 6 Mar 2026 14:59:08 -0800 Joseph Salisbury…
The function
housekeeping_isolcpus_setup()advanced the parser pointer unconditionally after unknown flags.For an argument like 'isolcpus=unknownflag', with no trailing comma, this can move the pointer past the terminating NUL, and the next loop test reads out of bounds.
Advance only when the current character is a comma separator, preserving existing parsing semantics while avoiding the invalid read.
Nice catch.
Quoted 13 lines
Fixes 3662daf02350 ("sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters")Assisted-by Codex:GPT-5.3Signed-off-by Joseph Salisbury <[email protected]>--- kernel/sched/isolation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/sched/isolation.c +0
-0kernel/sched/isolation.c static int __init housekeeping_isolcpus_setup(char *str) · line 359
Quoted 6 lines
kernel/sched/isolation.c +2
-1@@ -355,7 +355,8 @@ static int __init housekeeping_isolcpus_setup(char *str) }pr_info ("isolcpus: Skipped unknown flag %.*s\n" , len, par); - str++; +if (*str ==',' ) + str++;Although it should only be a ',' here, I think it's more robust to just test against non-nul character. As the bug only triggers if str points to the nul character. No need to make this check depend on the rest of the algorithm.
Quoted 4 lines
if (*str) str++;-- Steve
Thanks for the feedback and suggestion, Steve! I'll send a v2 with a test for a non-nul character.
Quoted 5 lines
Quoted 5 lines
kernel/sched/isolation.c +0
-0}/* Default behaviour for isolcpus without flags */