Skip to content

Commit cd64647

Browse files
lizf-osingomolnar
authored andcommitted
hung_task: Change sysctl_hung_task_check_count to 'int'
As 'sysctl_hung_task_check_count' is 'unsigned long' when this value is assigned to max_count in check_hung_uninterruptible_tasks(), it's truncated to 'int' type. This causes a minor artifact: if we write 2^32 to sysctl.hung_task_check_count, hung task detection will be effectively disabled. With this fix, it will still truncate the user input to 32 bits, but reading sysctl.hung_task_check_count reflects the actual truncated value. Signed-off-by: Li Zefan <lizefan@huawei.com> Acked-by: Ingo Molnar <mingo@kernel.org> Link: http://lkml.kernel.org/r/523FFF4E.9050401@huawei.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent d8524ae commit cd64647

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎include/linux/sched/sysctl.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define _SCHED_SYSCTL_H
33

44
#ifdef CONFIG_DETECT_HUNG_TASK
5+
extern int sysctl_hung_task_check_count;
56
extern unsigned int sysctl_hung_task_panic;
6-
extern unsigned long sysctl_hung_task_check_count;
77
extern unsigned long sysctl_hung_task_timeout_secs;
88
extern unsigned long sysctl_hung_task_warnings;
99
extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,

‎kernel/hung_task.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/*
2121
* The number of tasks checked:
2222
*/
23-
unsigned long __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;
23+
int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;
2424

2525
/*
2626
* Limit number of tasks checked in a batch.

‎kernel/sysctl.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,9 +962,10 @@ static struct ctl_table kern_table[] = {
962962
{
963963
.procname = "hung_task_check_count",
964964
.data = &sysctl_hung_task_check_count,
965-
.maxlen = sizeof(unsigned long),
965+
.maxlen = sizeof(int),
966966
.mode = 0644,
967-
.proc_handler = proc_doulongvec_minmax,
967+
.proc_handler = proc_dointvec_minmax,
968+
.extra1 = &zero,
968969
},
969970
{
970971
.procname = "hung_task_timeout_secs",

0 commit comments

Comments
 (0)