Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1605749
| From | fgao@ikuai8.com |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/1] proc/sysctl: Fix the int overflow for jiffies conversion |
| Date | 2017-03-21 16:50 +0100 |
| Message-ID | <tnucP-5iR-39@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
From: Gao Feng <fgao@ikuai8.com>
The function do_proc_dointvec_jiffies_conv uses LONG_MX/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.
Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
kernel/sysctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index acf0a5a..60474df 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2571,7 +2571,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 {
--
1.9.1
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 1/1] proc/sysctl: Fix the int overflow for jiffies conversion fgao@ikuai8.com - 2017-03-21 16:50 +0100
csiph-web