From: Amerigo Wang <xiyou.wangcong@gmail.com>
To: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
Cc: poornima nayak <mpnayak@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [BUG] timer_migration interface accepts any number as input in 2.6.30-git9
Date: Wed, 17 Jun 2009 18:41:48 +0800 [thread overview]
Message-ID: <20090617104148.GC6167@cr0.nay.redhat.com> (raw)
In-Reply-To: <20090617102126.GA28647@linux.vnet.ibm.com>
On Wed, Jun 17, 2009 at 03:51:26PM +0530, Arun R Bharadwaj wrote:
>* poornima nayak <mpnayak@linux.vnet.ibm.com> [2009-06-17 14:42:16]:
>
>> Hi
>>
>> Timer migration interface /proc/sys/kernel/timer_migration in
>> 2.6.30-git9 accepts any numerical value as input.
>> Steps to reproduce
>> 1. echo -6666666 > /proc/sys/kernel/timer_migration
>> 2. cat /proc/sys/kernel/timer_migration
>> -6666666
>>
>> 1. echo 44444444444444444444444444444444444444444444444444444444444 > /proc/sys/kernel/timer_migration
>> 2. cat /proc/sys/kernel/timer_migration
>> -1357789412
>>
>> Expected behavior: Should 'echo: write error: Invalid argument' while
>> setting any value other then 0 & 1
>>
>> Regards
>> Poornima
>>
>
>Hi Poornima,
>
>Thanks for reporting the bug.
>Hope this patch removes the bug.
>The patch is based against the latest -tip/master.
>
>--arun
>
>
>Signed-off-by: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>
My fix goes further, the further part of it is shown below. :)
Mind to have a look?
Not tested yet.
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
-----
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ab462b9..bc27e00 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2331,7 +2331,8 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
if (*p < '0' || *p > '9')
break;
- lval = simple_strtoul(p, &p, 0);
+ if (strict_strtoul(p, 0, &lval))
+ return -EINVAL;
len = p-buf;
if ((len < left) && *p && !isspace(*p))
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 756ccaf..ff2ca5c 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -163,11 +163,14 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
char *tail;
unsigned long val;
size_t len;
+ char tmp[32];
*res = 0;
len = strlen(cp);
if (len == 0)
return -EINVAL;
+ if (len > snprintf(tmp, "%ld", ULONG_MAX))
+ return -EINVAL;
val = simple_strtoul(cp, &tail, base);
if (tail == cp)
next prev parent reply other threads:[~2009-06-17 10:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-17 9:12 [BUG] timer_migration interface accepts any number as input in 2.6.30-git9 poornima nayak
2009-06-17 10:21 ` Arun R Bharadwaj
2009-06-17 10:41 ` Amerigo Wang [this message]
2009-06-22 11:22 ` poornima nayak
2009-06-23 4:30 ` Arun R Bharadwaj
2009-06-23 8:51 ` [tip:timers/urgent] timers: Fix timer_migration interface which accepts any number as input tip-bot for Arun R Bharadwaj
2009-06-17 10:41 ` [BUG] timer_migration interface accepts any number as input in 2.6.30-git9 Jaswinder Singh Rajput
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=20090617104148.GC6167@cr0.nay.redhat.com \
--to=xiyou.wangcong@gmail.com \
--cc=arun@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpnayak@linux.vnet.ibm.com \
/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