From: Francesco Fusco Date: Wed, 24 Jul 2013 08:39:07 +0000 (+0200) Subject: sysctl: range checking in do_proc_dointvec_ms_jiffies_conv X-Git-Tag: v3.11-rc4~22^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d738ce8fdc05ebf5b1475f8ae26d908c8c50970b;p=profile%2Fivi%2Fkernel-x86-ivi.git 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 CC: Andrew Morton CC: linux-kernel@vger.kernel.org Signed-off-by: David S. Miller --- diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ac09d98..07f6fc4 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;