sched/fair: avoid integer overflow warning for fair_server_period_max;
PATCH 1/1 sched/fair: avoid integer overflow warning for fair_server_period_max;
From: Arnd Bergmann <[email protected]>
The clalculation of fair_server_period_max includes an integer overflow:
In file included from kernel/sched/build_utility.c:72:kernel/sched/debug.c:341:57: error: integer overflow in expression of type 'long int' results in '-100663296' [-Werror=overflow]
341 | static unsigned long fair_server_period_max = (1 << 22) * NSEC_PER_USEC; /* ~4 seconds */
Avoids this by using an unsigned constant to start with.
--- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/debug.c +1 -1
@@ -338,7 +338,7 @@ enum dl_param { DL_PERIOD, }; -static unsigned long fair_server_period_max = (1 <<22 ) *NSEC_PER_USEC ;/* ~4 seconds */ +static unsigned long fair_server_period_max = (1u <<22 ) *NSEC_PER_USEC ;/* ~4 seconds */ static unsigned long fair_server_period_min = (100 ) *NSEC_PER_USEC ;/* 100 us */ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubuf,
Signature · 1 line
2.39.2
Vincent Guittot
maintainerHi Arnd
Quoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The clalculation of
fair_server_period_maxincludes an integer overflow:In file included from
kernel/sched/build_utility.c:72:kernel/sched/debug.c:341:57: error: integer overflow in expression of type 'long int' results in '-100663296' [-Werror=overflow]
341 | static unsigned longfair_server_period_max= (1 << 22) *NSEC_PER_USEC; /* ~4 seconds */Avoids this by using an unsigned constant to start with.
Dan sent something similar
https://lore.kernel.org/lkml/[email protected]/
Quoted 23 lines
Fixes d741f297bcea ("sched/fair: Fair server interface")Signed-off-by Arnd Bergmann <[email protected]>--- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/debug.c +1
-2@@ -338,7 +338,7 @@ enum dl_param { DL_PERIOD, }; -static unsigned long fair_server_period_max = (1 <<22 ) *NSEC_PER_USEC ;/* ~4 seconds */ +static unsigned long fair_server_period_max = (1u <<22 ) *NSEC_PER_USEC ;/* ~4 seconds */ static unsigned long fair_server_period_min = (100 ) *NSEC_PER_USEC ;/* 100 us */ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubuf, --2.39.2
Peter Zijlstra
maintainerQuoted 8 lines · Vincent Guittot
Hi Arnd
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The clalculation of
fair_server_period_maxincludes an integer overflow:
Quoted 8 lines
Quoted 5 lines
In file included from
kernel/sched/build_utility.c:72:kernel/sched/debug.c:341:57: error: integer overflow in expression of type 'long int' results in '-100663296' [-Werror=overflow]
341 | static unsigned longfair_server_period_max= (1 << 22) *NSEC_PER_USEC; /* ~4 seconds */Avoids this by using an unsigned constant to start with.
Dan sent something similar
https://lore.kernel.org/lkml/[email protected]/
Right, tglx also pointed me at a report for this. Let me go queue Dan's patch.
Quoted 23 lines
Quoted 23 lines
Fixes d741f297bcea ("sched/fair: Fair server interface")Signed-off-by Arnd Bergmann <[email protected]>--- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/debug.c +1
-2@@ -338,7 +338,7 @@ enum dl_param { DL_PERIOD, }; -static unsigned long fair_server_period_max = (1 <<22 ) *NSEC_PER_USEC ;/* ~4 seconds */ +static unsigned long fair_server_period_max = (1u <<22 ) *NSEC_PER_USEC ;/* ~4 seconds */ static unsigned long fair_server_period_min = (100 ) *NSEC_PER_USEC ;/* 100 us */ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubuf, --2.39.2