Skip to contentSkip to conversation

sched/isolation: avoid reading past string in isolcpus parser

PATCH Superseded Joseph Salisbury 2 participants 3 messages Mar 6 – Mar 9 Scheduler

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

Fixes 3662daf02350 ("sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters")
Assisted-by Codex:GPT-5.3
---
 kernel/sched/isolation.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/isolation.c +2 -1
index ef152d401fe2..4cf253fb6d75 100644
@@ -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
#1 lore raw
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 14 lines
Fixes 3662daf02350 ("sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters")
Assisted-by Codex:GPT-5.3
---
 kernel/sched/isolation.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/isolation.c +0 -0
index ef152d401fe2..4cf253fb6d75 100644

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 */
#2 lore raw

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.3
---
  kernel/sched/isolation.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/isolation.c +0 -0
index ef152d401fe2..4cf253fb6d75 100644

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.

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 */