mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/isolation: avoid reading past string in isolcpus parser
@ 2026-03-06 22:59 Joseph Salisbury
  2026-03-09 14:05 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Salisbury @ 2026-03-06 22:59 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel

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")
Cc: stable@vger.kernel.org
Assisted-by: Codex:GPT-5.3
Signed-off-by: Joseph Salisbury <joseph.salisbury@oracle.com>
---
 kernel/sched/isolation.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index ef152d401fe2..4cf253fb6d75 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -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 */
-- 
2.47.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/isolation: avoid reading past string in isolcpus parser
  2026-03-06 22:59 [PATCH] sched/isolation: avoid reading past string in isolcpus parser Joseph Salisbury
@ 2026-03-09 14:05 ` Steven Rostedt
  2026-03-09 21:49   ` [External] : " Joseph Salisbury
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2026-03-09 14:05 UTC (permalink / raw)
  To: Joseph Salisbury
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Ben Segall, Mel Gorman, Valentin Schneider,
	linux-kernel

On Fri,  6 Mar 2026 14:59:08 -0800
Joseph Salisbury <joseph.salisbury@oracle.com> wrote:

> 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.

> 
> Fixes: 3662daf02350 ("sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:GPT-5.3
> Signed-off-by: Joseph Salisbury <joseph.salisbury@oracle.com>
> ---
>  kernel/sched/isolation.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index ef152d401fe2..4cf253fb6d75 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -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


>  	}
>  
>  	/* Default behaviour for isolcpus without flags */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [External] : Re: [PATCH] sched/isolation: avoid reading past string in isolcpus parser
  2026-03-09 14:05 ` Steven Rostedt
@ 2026-03-09 21:49   ` Joseph Salisbury
  0 siblings, 0 replies; 3+ messages in thread
From: Joseph Salisbury @ 2026-03-09 21:49 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Ben Segall, Mel Gorman, Valentin Schneider,
	linux-kernel



On 3/9/26 10:05 AM, Steven Rostedt wrote:
> On Fri,  6 Mar 2026 14:59:08 -0800
> Joseph Salisbury <joseph.salisbury@oracle.com> wrote:
>
>> 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.
>
>> Fixes: 3662daf02350 ("sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters")
>> Cc: stable@vger.kernel.org
>> Assisted-by: Codex:GPT-5.3
>> Signed-off-by: Joseph Salisbury <joseph.salisbury@oracle.com>
>> ---
>>   kernel/sched/isolation.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
>> index ef152d401fe2..4cf253fb6d75 100644
>> --- a/kernel/sched/isolation.c
>> +++ b/kernel/sched/isolation.c
>> @@ -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
Thanks for the feedback and suggestion, Steve!  I'll send a v2 with a 
test for a non-nul character.
>
>
>>   	}
>>   
>>   	/* Default behaviour for isolcpus without flags */


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-09 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-06 22:59 [PATCH] sched/isolation: avoid reading past string in isolcpus parser Joseph Salisbury
2026-03-09 14:05 ` Steven Rostedt
2026-03-09 21:49   ` [External] : " Joseph Salisbury

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®