From 63259457a2eea54cc3b3a284b4bc7da52398a19a Mon Sep 17 00:00:00 2001 From: Gao Feng Date: Mon, 8 May 2017 15:54:58 -0700 Subject: proc/sysctl: fix the int overflow for jiffies conversion do_proc_dointvec_jiffies_conv() uses LONG_MAX/HZ as the max value to avoid overflow. But actually the *valp is int type, so it still causes overflow. For example, echo 2147483647 > ./sys/net/ipv4/tcp_keepalive_time Then, cat ./sys/net/ipv4/tcp_keepalive_time The output is "-1", it is not expected. Now use INT_MAX/HZ as the max value instead LONG_MAX/HZ to fix it. Link: http://lkml.kernel.org/r/1490109532-9228-1-git-send-email-fgao@ikuai8.com Signed-off-by: Gao Feng Cc: Arnaldo Carvalho de Melo Cc: Ingo Molnar Cc: Alexey Dobriyan Cc: Eric Dumazet Cc: Josh Poimboeuf Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 21343d1..4dfba1a 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2576,7 +2576,7 @@ static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, int write, void *data) { if (write) { - if (*lvalp > LONG_MAX / HZ) + if (*lvalp > INT_MAX / HZ) return 1; *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); } else { -- cgit v1.1