Skip to contentSkip to conversation

sched/debug: Fix fair_server_period_max value

PATCH Applied Dan Carpenter 2 participants 2 messages Aug 1, 2024 – Aug 7, 2024 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/debug: Fix fair_server_period_max value

This code has an integer overflow or sign extension bug which was caught by gcc-13:

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 */

The result is that "fair_server_period_max" is set to 0xfffffffffa000000 (585 years) instead of instead of 0xfa000000 (4 seconds) that was intended.

Fix this by changing the type to shift from (1 << 22) to (1UL << 22).

---
 kernel/sched/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/debug.c +1 -1
index 0148bc65d39c..845b79238398 100644
@@ -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 = (1UL << 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.43.0
merge bot Applied
#1 lore raw
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     4ae0c2b91110dab6f4291c2c7f99dde60ecc97d8
Gitweb:        https://git.kernel.org/tip/4ae0c2b91110dab6f4291c2c7f99dde60ecc97d8
Author:        Dan Carpenter <[email protected]>
AuthorDate:    Thu, 01 Aug 2024 10:44:03 -05:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Wed, 07 Aug 2024 12:44:16 +02:00

sched/debug: Fix fair_server_period_max value

This code has an integer overflow or sign extension bug which was caught by gcc-13:

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 */

The result is that "fair_server_period_max" is set to 0xfffffffffa000000 (585 years) instead of instead of 0xfa000000 (4 seconds) that was intended.

Fix this by changing the type to shift from (1 << 22) to (1UL << 22).

---
 kernel/sched/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/debug.c +1 -1
index e75914e..831a77a 100644
@@ -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 = (1UL << 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,