2009-06-17 09:12:29

by poornima nayak

[permalink] [raw]
Subject: [BUG] timer_migration interface accepts any number as input in 2.6.30-git9

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


2009-06-17 10:21:36

by Arun R Bharadwaj

[permalink] [raw]
Subject: Re: [BUG] timer_migration interface accepts any number as input in 2.6.30-git9

* poornima nayak <[email protected]> [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 <[email protected]>
---
kernel/sysctl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux.trees.git/kernel/sysctl.c
===================================================================
--- linux.trees.git.orig/kernel/sysctl.c
+++ linux.trees.git/kernel/sysctl.c
@@ -335,7 +335,10 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_timer_migration,
.maxlen = sizeof(unsigned int),
.mode = 0644,
- .proc_handler = &proc_dointvec,
+ .proc_handler = &proc_dointvec_minmax,
+ .strategy = &sysctl_intvec,
+ .extra1 = &zero,
+ .extra2 = &one,
},
#endif
{

2009-06-17 10:39:45

by Cong Wang

[permalink] [raw]
Subject: Re: [BUG] timer_migration interface accepts any number as input in 2.6.30-git9

On Wed, Jun 17, 2009 at 03:51:26PM +0530, Arun R Bharadwaj wrote:
>* poornima nayak <[email protected]> [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 <[email protected]>

Reviewed-by: WANG Cong <[email protected]>


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 <[email protected]>

-----
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)

2009-06-17 10:40:30

by Jaswinder Singh Rajput

[permalink] [raw]
Subject: Re: [BUG] timer_migration interface accepts any number as input in 2.6.30-git9

On Wed, 2009-06-17 at 14:42 +0530, poornima nayak wrote:
> 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
>

Is this patch fix your problem:

[PATCH] kernel/sysctl: fix timer migration interface

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

Reported-by: Poornima Nayak <[email protected]>
Signed-off-by: Jaswinder Singh Rajput <[email protected]>
---
kernel/sysctl.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ac57832..d0f65e4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -334,7 +334,10 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_timer_migration,
.maxlen = sizeof(unsigned int),
.mode = 0644,
- .proc_handler = &proc_dointvec,
+ .proc_handler = &proc_dointvec_minmax,
+ .strategy = &sysctl_intvec,
+ .extra1 = &zero,
+ .extra2 = &one,
},
#endif
{
--
1.6.0.6



2009-06-22 11:22:19

by poornima nayak

[permalink] [raw]
Subject: Re: [BUG] timer_migration interface accepts any number as input in 2.6.30-git9

Hi Arun,

Patch given by you fixes the reported bug.

Regds
Poornima
On Wed, 2009-06-17 at 15:51 +0530, Arun R Bharadwaj wrote:
> * poornima nayak <[email protected]> [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 <[email protected]>
> ---
> kernel/sysctl.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> Index: linux.trees.git/kernel/sysctl.c
> ===================================================================
> --- linux.trees.git.orig/kernel/sysctl.c
> +++ linux.trees.git/kernel/sysctl.c
> @@ -335,7 +335,10 @@ static struct ctl_table kern_table[] = {
> .data = &sysctl_timer_migration,
> .maxlen = sizeof(unsigned int),
> .mode = 0644,
> - .proc_handler = &proc_dointvec,
> + .proc_handler = &proc_dointvec_minmax,
> + .strategy = &sysctl_intvec,
> + .extra1 = &zero,
> + .extra2 = &one,
> },
> #endif
> {
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-06-23 04:31:35

by Arun R Bharadwaj

[permalink] [raw]
Subject: Re: [BUG] timer_migration interface accepts any number as input in 2.6.30-git9

* poornima nayak <[email protected]> [2009-06-22 16:52:08]:

> Hi Arun,
>
> Patch given by you fixes the reported bug.
>
> Regds
> Poornima

Hi Ingo,

Can you please include this minor interface bug fix for timer
migration?

thanks,

Signed-off-by: Arun R Bharadwaj <[email protected]>
Reported-by: Poornima Nayak <[email protected]>
Tested-by: Poornima Nayak <[email protected]>
---
kernel/sysctl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux.trees.git/kernel/sysctl.c
===================================================================
--- linux.trees.git.orig/kernel/sysctl.c
+++ linux.trees.git/kernel/sysctl.c
@@ -335,7 +335,10 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_timer_migration,
.maxlen = sizeof(unsigned int),
.mode = 0644,
- .proc_handler = &proc_dointvec,
+ .proc_handler = &proc_dointvec_minmax,
+ .strategy = &sysctl_intvec,
+ .extra1 = &zero,
+ .extra2 = &one,
},
#endif
{


> On Wed, 2009-06-17 at 15:51 +0530, Arun R Bharadwaj wrote:
> > * poornima nayak <[email protected]> [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 <[email protected]>
> > ---
> > kernel/sysctl.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > Index: linux.trees.git/kernel/sysctl.c
> > ===================================================================
> > --- linux.trees.git.orig/kernel/sysctl.c
> > +++ linux.trees.git/kernel/sysctl.c
> > @@ -335,7 +335,10 @@ static struct ctl_table kern_table[] = {
> > .data = &sysctl_timer_migration,
> > .maxlen = sizeof(unsigned int),
> > .mode = 0644,
> > - .proc_handler = &proc_dointvec,
> > + .proc_handler = &proc_dointvec_minmax,
> > + .strategy = &sysctl_intvec,
> > + .extra1 = &zero,
> > + .extra2 = &one,
> > },
> > #endif
> > {
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
>

2009-06-23 08:52:23

by Arun R Bharadwaj

[permalink] [raw]
Subject: [tip:timers/urgent] timers: Fix timer_migration interface which accepts any number as input

Commit-ID: bfdb4d9f0f611687d71cf6a460efc9e755f4a462
Gitweb: http://git.kernel.org/tip/bfdb4d9f0f611687d71cf6a460efc9e755f4a462
Author: Arun R Bharadwaj <[email protected]>
AuthorDate: Tue, 23 Jun 2009 10:00:58 +0530
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 23 Jun 2009 10:49:33 +0200

timers: Fix timer_migration interface which accepts any number as input

Poornima Nayek reported:

| 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

Restrict valid values to 0 and 1.

Reported-by: Poornima Nayak <[email protected]>
Tested-by: Poornima Nayak <[email protected]>
Signed-off-by: Arun R Bharadwaj <[email protected]>
Cc: poornima nayak <[email protected]>
Cc: Arun Bharadwaj <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>


---
kernel/sysctl.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 62e4ff9..c428ba1 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -335,7 +335,10 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_timer_migration,
.maxlen = sizeof(unsigned int),
.mode = 0644,
- .proc_handler = &proc_dointvec,
+ .proc_handler = &proc_dointvec_minmax,
+ .strategy = &sysctl_intvec,
+ .extra1 = &zero,
+ .extra2 = &one,
},
#endif
{