Skip to contentSkip to conversation

tick/sched: check skew_tick kernel parameter's validity

PATCH In review Sergey Shtylyov 3 participants 9 messages Aug 29 – Sep 30 Nohz, dynticks support

lore
Share & tools
lore
#0 lore raw

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

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.

---
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(-)
kernel/time/tick-sched.c +2 -1
index c1ee0b256445..34ceccdd49b5 100644
@@ -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;
 }
Signature · 1 line
2.55.0
#1 lore raw

Hi,

Quoted 20 lines · Sergey Shtylyov

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.

---
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(-)
kernel/time/tick-sched.c +0 -0
index c1ee0b256445..34ceccdd49b5 100644

kernel/time/tick-sched.c static int sched_skew_tick; · line 1489

Quoted 8 lines
kernel/time/tick-sched.c +2 -1
@@ -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.

Quoted 3 lines
kernel/time/tick-sched.c +0 -0
 }
Signature · 1 line
2.55.0
Signature · 2 lines
Frederic Weisbecker
SUSE Labs
#2 lore raw

On 9/1/26 3:55 PM, Frederic Weisbecker wrote:
[...]

Quoted 27 lines
Quoted 27 lines

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.

---
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(-)
kernel/time/tick-sched.c +2 -1
index c1ee0b256445..34ceccdd49b5 100644
@@ -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;
 
Quoted 3 lines

kernel/time/tick-sched.c static int sched_skew_tick; · line 1489

Quoted 1 line
kernel/time/tick-sched.c +0 -0
      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...

Quoted 1 line

Looks like only modules do care.

[...]

MBR, Sergey

maintainer
#3 lore raw
In reply to Sergey Shtylyov
Quoted 20 lines · Sergey Shtylyov

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.

---
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(-)
kernel/time/tick-sched.c +0 -0
index c1ee0b256445..34ceccdd49b5 100644

kernel/time/tick-sched.c static int sched_skew_tick; · line 1490

Quoted 9 lines
kernel/time/tick-sched.c +2 -1
@@ -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;
 }

sched_skew_tick should be converted to bool and this function should simply do:

       return kstrtobool(str, &sched_skew_tick);

And to make it complete, sched_skew_tick should be annotated with ro_after_init.

Thanks,

tglx

#4 lore raw

On 9/29/26 11:01 PM, Thomas Gleixner wrote:
[...]>> In skew_tick(), the result of get_option() call is ignored, so even if a

Quoted 26 lines
Quoted 26 lines

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.

---
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(-)
kernel/time/tick-sched.c +2 -1
index c1ee0b256445..34ceccdd49b5 100644
@@ -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;
 
Quoted 7 lines

kernel/time/tick-sched.c static int sched_skew_tick; · line 1490

Quoted 2 lines
kernel/time/tick-sched.c +0 -0
      return 0;
 }

sched_skew_tick should be converted to bool and this function should simply do:

       return kstrtobool(str, &sched_skew_tick);

Thanks for your comment!
OK, I'll do that (and add the Suggested-by: tag, of/c)...

Quoted 2 lines

And to make it complete, sched_skew_tick should be annotated with ro_after_init.

I guess you meant __ro_after_init? Would it then be OK adding it
in the same patch?

Quoted 3 lines

Thanks,

tglx

MBR, Sergey

maintainer
#5 lore raw
Quoted 36 lines · Sergey Shtylyov

On 9/29/26 11:01 PM, Thomas Gleixner wrote:
[...]>> In skew_tick(), the result of get_option() call is ignored, so even if a

Quoted 26 lines
Quoted 26 lines

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.

---
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(-)
kernel/time/tick-sched.c +2 -1
index c1ee0b256445..34ceccdd49b5 100644
@@ -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;
 
Quoted 7 lines

kernel/time/tick-sched.c static int sched_skew_tick; · line 1490

Quoted 2 lines
kernel/time/tick-sched.c +0 -0
      return 0;
 }

sched_skew_tick should be converted to bool and this function should simply do:

       return kstrtobool(str, &sched_skew_tick);
Quoted 8 lines

Thanks for your comment!
OK, I'll do that (and add the Suggested-by: tag, of/c)...

Quoted 2 lines

And to make it complete, sched_skew_tick should be annotated with ro_after_init.

I guess you meant __ro_after_init? Would it then be OK adding it
in the same patch?

As you change the data type of the variable anyway that's fine. Just mention it in the changelog.

Thanks,

tglx

#6 lore raw

On 9/30/26 10:36 PM, Thomas Gleixner wrote:

[...]

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

And to make it complete, sched_skew_tick should be annotated with ro_after_init.

I guess you meant __ro_after_init? Would it then be OK adding it
in the same patch?

As you change the data type of the variable anyway that's fine. Just mention it in the changelog.

Oh, I know the drill! :-)

Quoted 3 lines

Thanks,

tglx

MBR, Sergey

#7 lore raw
In reply to Sergey Shtylyov

On 9/30/26 10:01 PM, Sergey Shtylyov wrote:
[...]

Quoted 33 lines
Quoted 33 lines
Quoted 20 lines

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.

---
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(-)
kernel/time/tick-sched.c +0 -0
index c1ee0b256445..34ceccdd49b5 100644

kernel/time/tick-sched.c static int sched_skew_tick; · line 1490

Quoted 9 lines
kernel/time/tick-sched.c +2 -1
@@ -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;
 }

sched_skew_tick should be converted to bool and this function should simply do:

Quoted 4 lines
Quoted 1 line
       return kstrtobool(str, &sched_skew_tick);

Thanks for your comment!
OK, I'll do that (and add the Suggested-by: tag, of/c)...

One thing I did forget to ask: we still don't need the Fixes tag here?

[...]

Quoted 3 lines
Quoted 3 lines

Thanks,

tglx

MBR, Sergey

maintainer
#8 lore raw
Quoted 5 lines · Sergey Shtylyov
Quoted 2 lines · Sergey Shtylyov

Thanks for your comment!
OK, I'll do that (and add the Suggested-by: tag, of/c)...

One thing I did forget to ask: we still don't need the Fixes tag here?

I have no strong opinion about it, but it's not really fixing a real world problem aside of preventing a sysadmin to shoot himself itno the foot. :)