summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorFrancesco Fusco <ffusco@redhat.com>2013-07-24 12:39:07 +0400
committerDavid S. Miller <davem@davemloft.net>2013-07-27 01:22:10 +0400
commitd738ce8fdc05ebf5b1475f8ae26d908c8c50970b (patch)
tree0ed3038b6f7950d826ca0bc24a7e98f033f88b44 /kernel
parent555445cd11803c6bc93b2be31968f3949ef7708b (diff)
downloadlinux-d738ce8fdc05ebf5b1475f8ae26d908c8c50970b.tar.xz
sysctl: range checking in do_proc_dointvec_ms_jiffies_conv
When (integer) sysctl values are expressed in ms and have to be represented internally as jiffies. The msecs_to_jiffies function returns an unsigned long, which gets assigned to the integer. This patch prevents the value to be assigned if bigger than INT_MAX, done in a similar way as in cba9f3 ("Range checking in do_proc_dointvec_(userhz_)jiffies_conv"). Signed-off-by: Francesco Fusco <ffusco@redhat.com> CC: Andrew Morton <akpm@linux-foundation.org> CC: linux-kernel@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sysctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ac09d98490aa..07f6fc468e17 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2346,7 +2346,11 @@ static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
int write, void *data)
{
if (write) {
- *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
+ unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
+
+ if (jif > INT_MAX)
+ return 1;
+ *valp = (int)jif;
} else {
int val = *valp;
unsigned long lval;