[PATCH] tick/sched: check skew_tick kernel parameter's validity

Sergey Shtylyov posted 1 patch 4 weeks ago
kernel/time/tick-sched.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] tick/sched: check skew_tick kernel parameter's validity
Posted by Sergey Shtylyov 4 weeks ago
In skew_tick(), the result of get_option() call is ignored, so even if a
value of the skew_tick kernel parameter was not specified (or specified
as a list or range), the kernel won't complain. Add the missing check...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>

---
The patch is against the timers/nohz branch of the tip.git repo...

 kernel/time/tick-sched.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index c1ee0b256445..34ceccdd49b5 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1483,7 +1483,8 @@ static int sched_skew_tick;
 
 static int __init skew_tick(char *str)
 {
-	get_option(&str, &sched_skew_tick);
+	if (get_option(&str, &sched_skew_tick) != 1)
+		return -EINVAL;
 
 	return 0;
 }
-- 
2.55.0
Re: [PATCH] tick/sched: check skew_tick kernel parameter's validity
Posted by Frederic Weisbecker 3 weeks, 4 days ago
Hi,

Le Sat, Aug 29, 2026 at 11:25:35PM +0300, Sergey Shtylyov a écrit :
> In skew_tick(), the result of get_option() call is ignored, so even if a
> value of the skew_tick kernel parameter was not specified (or specified
> as a list or range), the kernel won't complain. Add the missing check...
> 
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
> 
> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
> 
> ---
> The patch is against the timers/nohz branch of the tip.git repo...
> 
>  kernel/time/tick-sched.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> index c1ee0b256445..34ceccdd49b5 100644
> --- a/kernel/time/tick-sched.c
> +++ b/kernel/time/tick-sched.c
> @@ -1483,7 +1483,8 @@ static int sched_skew_tick;
>  
>  static int __init skew_tick(char *str)
>  {
> -	get_option(&str, &sched_skew_tick);
> +	if (get_option(&str, &sched_skew_tick) != 1)
> +		return -EINVAL;
>  
>  	return 0;

I'm not sure that matters. Initcall return values seem to be ignored on boot.
Looks like only modules do care.

Thanks.

>  }
> -- 
> 2.55.0

-- 
Frederic Weisbecker
SUSE Labs
Re: [PATCH] tick/sched: check skew_tick kernel parameter's validity
Posted by Sergey Shtylyov 3 weeks, 4 days ago
On 9/1/26 3:55 PM, Frederic Weisbecker wrote:
[...]

>> In skew_tick(), the result of get_option() call is ignored, so even if a
>> value of the skew_tick kernel parameter was not specified (or specified
>> as a list or range), the kernel won't complain. Add the missing check...
>>
>> Found by Linux Verification Center (linuxtesting.org) with the Svace static
>> analysis tool.
>>
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
>>
>> ---
>> The patch is against the timers/nohz branch of the tip.git repo...
>>
>>  kernel/time/tick-sched.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
>> index c1ee0b256445..34ceccdd49b5 100644
>> --- a/kernel/time/tick-sched.c
>> +++ b/kernel/time/tick-sched.c
>> @@ -1483,7 +1483,8 @@ static int sched_skew_tick;
>>
>>  static int __init skew_tick(char *str)
>>  {
>> -     get_option(&str, &sched_skew_tick);
>> +     if (get_option(&str, &sched_skew_tick) != 1)
>> +             return -EINVAL;
>>
>>       return 0;
> 
> I'm not sure that matters. Initcall return values seem to be ignored on boot.

   But that's not an initcall, IIUC.
   Looking at do_early_param(), the kernel would call pr_warn() if the setup
fucntion fails...

> Looks like only modules do care.

[...]

MBR, Sergey