From: Francesco Fusco <ffusco@redhat.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 2/2] sysctl: range checking in do_proc_dointvec_ms_jiffies_conv
Date: Wed, 24 Jul 2013 10:39:07 +0200 [thread overview]
Message-ID: <de72e4265ab874b70b127011bb1ef8c2d27bfe63.1374654531.git.ffusco@redhat.com> (raw)
In-Reply-To: <cover.1374654531.git.ffusco@redhat.com>
In-Reply-To: <cover.1374654531.git.ffusco@redhat.com>
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
---
kernel/sysctl.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ac09d98..00813e5 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 = 0;
+ jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
+ if (jif > INT_MAX)
+ return 1;
+ *valp = (int)jif;
} else {
int val = *valp;
unsigned long lval;
--
1.8.3.1
next prev parent reply other threads:[~2013-07-24 8:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 8:39 [PATCH net-next 0/2] Fix overflow errors in /proc/sys/net/ipv4/neigh/ Francesco Fusco
2013-07-24 8:39 ` [PATCH net-next 1/2] neigh: prevent overflowing params " Francesco Fusco
2013-07-26 21:22 ` David Miller
2013-07-24 8:39 ` Francesco Fusco [this message]
2013-07-24 14:35 ` [PATCH net-next 2/2] sysctl: range checking in do_proc_dointvec_ms_jiffies_conv Sergei Shtylyov
2013-07-26 21:23 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=de72e4265ab874b70b127011bb1ef8c2d27bfe63.1374654531.git.ffusco@redhat.com \
--to=ffusco@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).