diff options
author | Gao Feng <fgao@ikuai8.com> | 2017-05-08 18:54:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-08 20:15:10 -0400 |
commit | 63259457a2eea54cc3b3a284b4bc7da52398a19a (patch) | |
tree | 8e559f0586a162ad6d07b42117254f26cf552824 /kernel/sysctl.c | |
parent | f245e1c17a702964ad552878d01a10e53cf0e8e5 (diff) |
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 <fgao@ikuai8.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r-- | kernel/sysctl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 21343d110296..4dfba1a76cc3 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, | |||
2576 | int write, void *data) | 2576 | int write, void *data) |
2577 | { | 2577 | { |
2578 | if (write) { | 2578 | if (write) { |
2579 | if (*lvalp > LONG_MAX / HZ) | 2579 | if (*lvalp > INT_MAX / HZ) |
2580 | return 1; | 2580 | return 1; |
2581 | *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); | 2581 | *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); |
2582 | } else { | 2582 | } else { |