cgroups: strcpy destination string overflow
cover cgroups: strcpy destination string overflow
Hi,
Here is patch which fixes minor bug in /kernel/cgroup.c file. Function "strcpy" is used without check for maximum allowed source string length and could cause destination string overflow.
Thanks,
Best Regards,
Evgeny
Evgeny Kuznetsov (1):
cgroups: strcpy destination string overflow
kernel/cgroup.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
A message that is not in the archive (sent off-list or not yet received): cover.1286193571.git.EXT-Eugeny.Kuznetsov-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org
PATCH 1/1 cgroups: strcpy destination string overflow
From: Evgeny Kuznetsov <[email protected]>
Function "strcpy" is used without check for maximum allowed source string length and could cause destination string overflow. Check for string length is added before using "strcpy". Function now is return error if source string length is more than a maximum.
--- kernel/cgroup.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/cgroup.c +2 -0
@@ -1883,6 +1883,8 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, const char *buffer) {BUILD_BUG_ON (sizeof (cgrp->root->release_agent_path) <PATH_MAX ); +if (strlen (buffer) >=PATH_MAX ) +return -EINVAL ;if (!cgroup_lock_live_group (cgrp))return -ENODEV ;strcpy (cgrp->root->release_agent_path, buffer);
Signature · 1 line
1.6.3.3
PATCH 1/1 cgroups: strcpy destination string overflow
In reply to Evgeny KuznetsovFrom: Evgeny Kuznetsov <[email protected]>
Function "strcpy" is used without check for maximum allowed source string length and could cause destination string overflow. Check for string length is added before using "strcpy". Function now is return error if source string length is more than a maximum.
--- kernel/cgroup.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/cgroup.c +2 -0
@@ -1883,6 +1883,8 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, const char *buffer) {BUILD_BUG_ON (sizeof (cgrp->root->release_agent_path) <PATH_MAX ); +if (strlen (buffer) >=PATH_MAX ) +return -EINVAL ;if (!cgroup_lock_live_group (cgrp))return -ENODEV ;strcpy (cgrp->root->release_agent_path, buffer);
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): 2acb25707f916de866aa520b1a9f04f0f48c949c.1286193571.git.EXT-Eugeny.Kuznetsov-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org
Quoted 18 lines · On Tue, 5 Oct 2010 12:38:05 +0400 Evgeny Kuznetsov…
From: Evgeny Kuznetsov <[email protected]>
Function "strcpy" is used without check for maximum allowed source string length and could cause destination string overflow. Check for string length is added before using "strcpy". Function now is return error if source string length is more than a maximum.
Signed-off-by Evgeny Kuznetsov <[email protected]>--- kernel/cgroup.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)kernel/cgroup.c +0
-0
kernel/cgroup.c static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, · line 1890
Quoted 8 lines
kernel/cgroup.c +2
-0@@ -1883,6 +1883,8 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, const char *buffer) {BUILD_BUG_ON (sizeof (cgrp->root->release_agent_path) <PATH_MAX ); +if (strlen (buffer) >=PATH_MAX ) +return -EINVAL ;if (!cgroup_lock_live_group (cgrp))return -ENODEV ;strcpy (cgrp->root->release_agent_path, buffer);
I don't think this can happen, because cftype.max_write_len is PATH_MAX.
But it's pretty unobvious if this is actually true, and the code is fragile against future changes.
Quoted 18 lines · On Tue, 5 Oct 2010 12:38:05 +0400 Evgeny Kuznetsov…
From: Evgeny Kuznetsov <[email protected]>
Function "strcpy" is used without check for maximum allowed source string length and could cause destination string overflow. Check for string length is added before using "strcpy". Function now is return error if source string length is more than a maximum.
Signed-off-by Evgeny Kuznetsov <[email protected]>--- kernel/cgroup.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)kernel/cgroup.c +0
-0
kernel/cgroup.c static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, · line 1890
Quoted 8 lines
kernel/cgroup.c +2
-0@@ -1883,6 +1883,8 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, const char *buffer) {BUILD_BUG_ON (sizeof (cgrp->root->release_agent_path) <PATH_MAX ); +if (strlen (buffer) >=PATH_MAX ) +return -EINVAL ;if (!cgroup_lock_live_group (cgrp))return -ENODEV ;strcpy (cgrp->root->release_agent_path, buffer);
I don't think this can happen, because cftype.max_write_len is PATH_MAX.
But it's pretty unobvious if this is actually true, and the code is fragile against future changes.
A message that is not in the archive (sent off-list or not yet received): 20101005124802.989f6214.akpm-de/[email protected]
Paul Menage
Acked-byQuoted 16 lines · Andrew Morton
Quoted 13 lines · On Tue, 5 Oct 2010 12:38:05 +0400 Evgeny Kuznetsov…
From: Evgeny Kuznetsov <[email protected]>
Function "strcpy" is used without check for maximum allowed source string length and could cause destination string overflow. Check for string length is added before using "strcpy". Function now is return error if source string length is more than a maximum.
Signed-off-by Evgeny Kuznetsov <[email protected]>---
kernel/cgroup.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 16 lines
kernel/cgroup.c static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, · line 1890
Quoted 13 lines
kernel/cgroup.c +2
-0@@ -1883,6 +1883,8 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, const char *buffer) { BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); + if (strlen(buffer) >= PATH_MAX) + return -EINVAL; if (!cgroup_lock_live_group(cgrp)) return -ENODEV; strcpy(cgrp->root->release_agent_path, buffer);I don't think this can happen, because cftype.max_write_len is
PATH_MAX.
Yes, it shouldn't be possible.
Quoted 3 lines
But it's pretty unobvious if this is actually true, and the code is fragile against future changes.
Fair enough - adding the check doesn't hurt anything.
Paul Menage
Acked-byQuoted 16 lines · Andrew Morton
Quoted 13 lines · On Tue, 5 Oct 2010 12:38:05 +0400 Evgeny Kuznetsov…
From: Evgeny Kuznetsov <[email protected]>
Function "strcpy" is used without check for maximum allowed source string length and could cause destination string overflow. Check for string length is added before using "strcpy". Function now is return error if source string length is more than a maximum.
Signed-off-by Evgeny Kuznetsov <[email protected]>---
kernel/cgroup.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 16 lines
kernel/cgroup.c static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, · line 1890
Quoted 13 lines
kernel/cgroup.c +2
-0@@ -1883,6 +1883,8 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, const char *buffer) { BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX); + if (strlen(buffer) >= PATH_MAX) + return -EINVAL; if (!cgroup_lock_live_group(cgrp)) return -ENODEV; strcpy(cgrp->root->release_agent_path, buffer);I don't think this can happen, because cftype.max_write_len is
PATH_MAX.
Yes, it shouldn't be possible.
Quoted 3 lines
But it's pretty unobvious if this is actually true, and the code is fragile against future changes.
Fair enough - adding the check doesn't hurt anything.