* [PATCH 1/3] Mark strstrip() as must_check
@ 2009-10-02 8:37 KOSAKI Motohiro
2009-10-02 8:39 ` [PATCH 2/3] Fix strstrip() abuse in elv_iosched_store() KOSAKI Motohiro
2009-10-02 8:41 ` [PATCH 3/3] cgroup: fix strstrip() abuse KOSAKI Motohiro
0 siblings, 2 replies; 6+ messages in thread
From: KOSAKI Motohiro @ 2009-10-02 8:37 UTC (permalink / raw)
To: LKML, linux-mm, Andrew Morton; +Cc: kosaki.motohiro
In few weeks ago discussion, Andrew Morton pointed out strstrip()
should be must_check, because it was often abused.
This patch does that.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
include/linux/string.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/string.h b/include/linux/string.h
index 489019e..b850886 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -62,7 +62,7 @@ extern char * strnchr(const char *, size_t, int);
#ifndef __HAVE_ARCH_STRRCHR
extern char * strrchr(const char *,int);
#endif
-extern char * strstrip(char *);
+extern char * __must_check strstrip(char *);
#ifndef __HAVE_ARCH_STRSTR
extern char * strstr(const char *,const char *);
#endif
--
1.6.0.GIT
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] Fix strstrip() abuse in elv_iosched_store()
2009-10-02 8:37 [PATCH 1/3] Mark strstrip() as must_check KOSAKI Motohiro
@ 2009-10-02 8:39 ` KOSAKI Motohiro
2009-10-02 8:41 ` [PATCH 3/3] cgroup: fix strstrip() abuse KOSAKI Motohiro
1 sibling, 0 replies; 6+ messages in thread
From: KOSAKI Motohiro @ 2009-10-02 8:39 UTC (permalink / raw)
To: LKML; +Cc: kosaki.motohiro, linux-mm, Andrew Morton, Li Zefan, Jens Axboe
elv_iosched_store() ignore the return value of strstrip().
it makes small inconsistent behavior.
This patch fixes it.
<before>
====================================
# cd /sys/block/{blockdev}/queue
case1:
# echo "anticipatory" > scheduler
# cat scheduler
noop [anticipatory] deadline cfq
case2:
# echo "anticipatory " > scheduler
# cat scheduler
noop [anticipatory] deadline cfq
case3:
# echo " anticipatory" > scheduler
bash: echo: write error: Invalid argument
<after>
====================================
# cd /sys/block/{blockdev}/queue
case1:
# echo "anticipatory" > scheduler
# cat scheduler
noop [anticipatory] deadline cfq
case2:
# echo "anticipatory " > scheduler
# cat scheduler
noop [anticipatory] deadline cfq
case3:
# echo " anticipatory" > scheduler
noop [anticipatory] deadline cfq
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
block/elevator.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
Index: b/block/elevator.c
===================================================================
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -1059,9 +1059,7 @@ ssize_t elv_iosched_store(struct request
return count;
strlcpy(elevator_name, name, sizeof(elevator_name));
- strstrip(elevator_name);
-
- e = elevator_get(elevator_name);
+ e = elevator_get(strstrip(elevator_name));
if (!e) {
printk(KERN_ERR "elevator: type %s not found\n", elevator_name);
return -EINVAL;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] cgroup: fix strstrip() abuse
2009-10-02 8:37 [PATCH 1/3] Mark strstrip() as must_check KOSAKI Motohiro
2009-10-02 8:39 ` [PATCH 2/3] Fix strstrip() abuse in elv_iosched_store() KOSAKI Motohiro
@ 2009-10-02 8:41 ` KOSAKI Motohiro
2009-10-02 22:01 ` Paul Menage
1 sibling, 1 reply; 6+ messages in thread
From: KOSAKI Motohiro @ 2009-10-02 8:41 UTC (permalink / raw)
To: LKML; +Cc: kosaki.motohiro, linux-mm, Andrew Morton, Li Zefan, Paul Menage
cgroup_write_X64() and cgroup_write_string() ignore the return
value of strstrip().
it makes small inconsistent behavior.
example:
=========================
# cd /mnt/cgroup/hoge
# cat memory.swappiness
60
# echo "59 " > memory.swappiness
# cat memory.swappiness
59
# echo " 58" > memory.swappiness
bash: echo: write error: Invalid argument
This patch fixes it.
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
kernel/cgroup.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
Index: b/kernel/cgroup.c
===================================================================
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1710,14 +1710,13 @@ static ssize_t cgroup_write_X64(struct c
return -EFAULT;
buffer[nbytes] = 0; /* nul-terminate */
- strstrip(buffer);
if (cft->write_u64) {
- u64 val = simple_strtoull(buffer, &end, 0);
+ u64 val = simple_strtoull(strstrip(buffer), &end, 0);
if (*end)
return -EINVAL;
retval = cft->write_u64(cgrp, cft, val);
} else {
- s64 val = simple_strtoll(buffer, &end, 0);
+ s64 val = simple_strtoll(strstrip(buffer), &end, 0);
if (*end)
return -EINVAL;
retval = cft->write_s64(cgrp, cft, val);
@@ -1753,8 +1752,7 @@ static ssize_t cgroup_write_string(struc
}
buffer[nbytes] = 0; /* nul-terminate */
- strstrip(buffer);
- retval = cft->write_string(cgrp, cft, buffer);
+ retval = cft->write_string(cgrp, cft, strstrip(buffer));
if (!retval)
retval = nbytes;
out:
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] cgroup: fix strstrip() abuse
2009-10-02 8:41 ` [PATCH 3/3] cgroup: fix strstrip() abuse KOSAKI Motohiro
@ 2009-10-02 22:01 ` Paul Menage
2009-10-03 12:05 ` KOSAKI Motohiro
0 siblings, 1 reply; 6+ messages in thread
From: Paul Menage @ 2009-10-02 22:01 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: LKML, linux-mm, Andrew Morton, Li Zefan
On Fri, Oct 2, 2009 at 1:41 AM, KOSAKI Motohiro
<kosaki.motohiro@jp.fujitsu.com> wrote:
> cgroup_write_X64() and cgroup_write_string() ignore the return
> value of strstrip().
> it makes small inconsistent behavior.
>
> example:
> =========================
> # cd /mnt/cgroup/hoge
> # cat memory.swappiness
> 60
> # echo "59 " > memory.swappiness
> # cat memory.swappiness
> 59
> # echo " 58" > memory.swappiness
> bash: echo: write error: Invalid argument
>
>
> This patch fixes it.
>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Paul Menage <menage@google.com>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Paul Menage <menage@google.com>
Thanks - although I think I'd s/abuse/misuse/ in the description.
> ---
> kernel/cgroup.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> Index: b/kernel/cgroup.c
> ===================================================================
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1710,14 +1710,13 @@ static ssize_t cgroup_write_X64(struct c
> return -EFAULT;
>
> buffer[nbytes] = 0; /* nul-terminate */
> - strstrip(buffer);
> if (cft->write_u64) {
> - u64 val = simple_strtoull(buffer, &end, 0);
> + u64 val = simple_strtoull(strstrip(buffer), &end, 0);
> if (*end)
> return -EINVAL;
> retval = cft->write_u64(cgrp, cft, val);
> } else {
> - s64 val = simple_strtoll(buffer, &end, 0);
> + s64 val = simple_strtoll(strstrip(buffer), &end, 0);
> if (*end)
> return -EINVAL;
> retval = cft->write_s64(cgrp, cft, val);
> @@ -1753,8 +1752,7 @@ static ssize_t cgroup_write_string(struc
> }
>
> buffer[nbytes] = 0; /* nul-terminate */
> - strstrip(buffer);
> - retval = cft->write_string(cgrp, cft, buffer);
> + retval = cft->write_string(cgrp, cft, strstrip(buffer));
> if (!retval)
> retval = nbytes;
> out:
>
>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] cgroup: fix strstrip() abuse
2009-10-02 22:01 ` Paul Menage
@ 2009-10-03 12:05 ` KOSAKI Motohiro
2009-10-03 19:15 ` Paul Menage
0 siblings, 1 reply; 6+ messages in thread
From: KOSAKI Motohiro @ 2009-10-03 12:05 UTC (permalink / raw)
To: Paul Menage; +Cc: LKML, linux-mm, Andrew Morton, Li Zefan
>> cgroup_write_X64() and cgroup_write_string() ignore the return
>> value of strstrip().
>> it makes small inconsistent behavior.
>>
>> example:
>> =========================
>> # cd /mnt/cgroup/hoge
>> # cat memory.swappiness
>> 60
>> # echo "59 " > memory.swappiness
>> # cat memory.swappiness
>> 59
>> # echo " 58" > memory.swappiness
>> bash: echo: write error: Invalid argument
>>
>>
>> This patch fixes it.
>>
>> Cc: Li Zefan <lizf@cn.fujitsu.com>
>> Cc: Paul Menage <menage@google.com>
>> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>
> Acked-by: Paul Menage <menage@google.com>
>
> Thanks - although I think I'd s/abuse/misuse/ in the description.
I don't know what's different between them. My dictionary is slightly quiet ;)
Is this X-rated word? if so, I'll resend it soon.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] cgroup: fix strstrip() abuse
2009-10-03 12:05 ` KOSAKI Motohiro
@ 2009-10-03 19:15 ` Paul Menage
0 siblings, 0 replies; 6+ messages in thread
From: Paul Menage @ 2009-10-03 19:15 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: LKML, linux-mm, Andrew Morton, Li Zefan
On Sat, Oct 3, 2009 at 5:05 AM, KOSAKI Motohiro
<kosaki.motohiro@jp.fujitsu.com> wrote:
>> Thanks - although I think I'd s/abuse/misuse/ in the description.
>
> I don't know what's different between them. My dictionary is slightly quiet ;)
> Is this X-rated word? if so, I'll resend it soon.
Certainly not X-rated :-)
Generally "abuse" carries a connotation of intent (or perhaps
deliberate hackiness) whereas "misuse" simply indicates that the
previous code was wrong.
Paul
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-10-03 19:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-02 8:37 [PATCH 1/3] Mark strstrip() as must_check KOSAKI Motohiro
2009-10-02 8:39 ` [PATCH 2/3] Fix strstrip() abuse in elv_iosched_store() KOSAKI Motohiro
2009-10-02 8:41 ` [PATCH 3/3] cgroup: fix strstrip() abuse KOSAKI Motohiro
2009-10-02 22:01 ` Paul Menage
2009-10-03 12:05 ` KOSAKI Motohiro
2009-10-03 19:15 ` Paul Menage
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox