tick/sched: check skew_tick kernel parameter's validity
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
@@ -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
Frederic Weisbecker
maintainerHi,
Quoted 20 lines · Sergey Shtylyov
In
skew_tick(), the result ofget_option()call is ignored, so even if a value of theskew_tickkernel 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 <[email protected]>---
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
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
On 9/1/26 3:55 PM, Frederic Weisbecker wrote:
[...]
Quoted 27 lines
Quoted 27 lines
In
skew_tick(), the result ofget_option()call is ignored, so even if a value of theskew_tickkernel 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 <[email protected]>---
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@@ -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
-0return 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
Thomas Gleixner
maintainerQuoted 20 lines · Sergey Shtylyov
In
skew_tick(), the result ofget_option()call is ignored, so even if a value of theskew_tickkernel 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 <[email protected]>---
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
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
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_tickkernel 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 <[email protected]>---
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@@ -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
-0return 0 ; }
sched_skew_tickshould 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_tickshould be annotated withro_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
Thomas Gleixner
maintainerQuoted 36 lines · Sergey Shtylyov
On 9/29/26 11:01 PM, Thomas Gleixner wrote:
[...]>> Inskew_tick(), the result ofget_option()call is ignored, so even if aQuoted 26 lines
Quoted 26 lines
value of the
skew_tickkernel 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 <[email protected]>---
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@@ -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
-0return 0 ; }
sched_skew_tickshould 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_tickshould be annotated withro_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
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_tickshould be annotated withro_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
On 9/30/26 10:01 PM, Sergey Shtylyov wrote:
[...]
Quoted 33 lines
Quoted 33 lines
Quoted 20 lines
In
skew_tick(), the result ofget_option()call is ignored, so even if a value of theskew_tickkernel 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 <[email protected]>---
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
-0kernel/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_tickshould 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
Thomas Gleixner
maintainerQuoted 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. :)