[PATCH v2] hung_task : check the value of "sysctl_hung_task_timeout_sec"

From: Liu Hua
Date: Sun Mar 23 2014 - 04:04:17 EST


As sysctl_hung_task_timeout_sec is unsigned long, when this value is
larger then LONG_MAX/HZ, the function schedule_timeout_interruptible in
watchdog will return immediately without sleep and with print :

[ 205.452934] schedule_timeout: wrong timeout value ffffffffffffff83

and then the funtion watchdog will call schedule_timeout_interruptible again
and again. The screen will be filled with
"schedule_timeout: wrong timeout value ffffffffffffff83"

This patch does some check and correction in timeout_jiffies, to let the
function schedule_timeout_interruptible allways get the valid parameter.

Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Liu Hua <sdu.liu@xxxxxxxxxx>
---
kernel/hung_task.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 6df6149..f992286 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -174,8 +174,12 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)

static unsigned long timeout_jiffies(unsigned long timeout)
{
- /* timeout of 0 will disable the watchdog */
- return timeout ? timeout * HZ : MAX_SCHEDULE_TIMEOUT;
+ /* timeout of 0 or >= LONG_MAX/HZ will disable the watchdog */
+ if ((timeout == 0) || (timeout > MAX_SCHEDULE_TIMEOUT))
+ return MAX_SCHEDULE_TIMEOUT;
+
+ return (timeout * HZ) < MAX_SCHEDULE_TIMEOUT ?
+ timeout * HZ : MAX_SCHEDULE_TIMEOUT;
}

/*
--
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/