All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup: avoid cgroup root name longer than max
@ 2017-12-08  8:47 ` Ma Shimiao
  0 siblings, 0 replies; 4+ messages in thread
From: Ma Shimiao @ 2017-12-08  8:47 UTC (permalink / raw)
  To: tj, lizefan; +Cc: cgroups, linux-kernel, Ma Shimiao

cgroup root name has max length limit, we should avoid copying
longer name than that to the name.

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
---
 kernel/cgroup/cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 0b1ffe147f24..3614a21ad6b8 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1866,7 +1866,7 @@ void init_cgroup_root(struct cgroup_root *root, struct cgroup_sb_opts *opts)
 	if (opts->release_agent)
 		strcpy(root->release_agent_path, opts->release_agent);
 	if (opts->name)
-		strcpy(root->name, opts->name);
+		strncpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN);
 	if (opts->cpuset_clone_children)
 		set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags);
 }
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] cgroup: avoid cgroup root name longer than max
@ 2017-12-08  8:47 ` Ma Shimiao
  0 siblings, 0 replies; 4+ messages in thread
From: Ma Shimiao @ 2017-12-08  8:47 UTC (permalink / raw)
  To: tj-DgEjT+Ai2ygdnm+yROfE0A, lizefan-hv44wF8Li93QT0dZR+AlfA
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Ma Shimiao

cgroup root name has max length limit, we should avoid copying
longer name than that to the name.

Signed-off-by: Ma Shimiao <mashimiao.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
 kernel/cgroup/cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 0b1ffe147f24..3614a21ad6b8 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1866,7 +1866,7 @@ void init_cgroup_root(struct cgroup_root *root, struct cgroup_sb_opts *opts)
 	if (opts->release_agent)
 		strcpy(root->release_agent_path, opts->release_agent);
 	if (opts->name)
-		strcpy(root->name, opts->name);
+		strncpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN);
 	if (opts->cpuset_clone_children)
 		set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags);
 }
-- 
2.13.6



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cgroup: avoid cgroup root name longer than max
@ 2017-12-11 15:12   ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2017-12-11 15:12 UTC (permalink / raw)
  To: Ma Shimiao; +Cc: lizefan, cgroups, linux-kernel

On Fri, Dec 08, 2017 at 04:47:46PM +0800, Ma Shimiao wrote:
> cgroup root name has max length limit, we should avoid copying
> longer name than that to the name.
> 
> Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
> ---
>  kernel/cgroup/cgroup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 0b1ffe147f24..3614a21ad6b8 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -1866,7 +1866,7 @@ void init_cgroup_root(struct cgroup_root *root, struct cgroup_sb_opts *opts)
>  	if (opts->release_agent)
>  		strcpy(root->release_agent_path, opts->release_agent);
>  	if (opts->name)
> -		strcpy(root->name, opts->name);
> +		strncpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN);

Ditto here, let's use strscpy().

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cgroup: avoid cgroup root name longer than max
@ 2017-12-11 15:12   ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2017-12-11 15:12 UTC (permalink / raw)
  To: Ma Shimiao
  Cc: lizefan-hv44wF8Li93QT0dZR+AlfA, cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Fri, Dec 08, 2017 at 04:47:46PM +0800, Ma Shimiao wrote:
> cgroup root name has max length limit, we should avoid copying
> longer name than that to the name.
> 
> Signed-off-by: Ma Shimiao <mashimiao.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
> ---
>  kernel/cgroup/cgroup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 0b1ffe147f24..3614a21ad6b8 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -1866,7 +1866,7 @@ void init_cgroup_root(struct cgroup_root *root, struct cgroup_sb_opts *opts)
>  	if (opts->release_agent)
>  		strcpy(root->release_agent_path, opts->release_agent);
>  	if (opts->name)
> -		strcpy(root->name, opts->name);
> +		strncpy(root->name, opts->name, MAX_CGROUP_ROOT_NAMELEN);

Ditto here, let's use strscpy().

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-11 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-08  8:47 [PATCH] cgroup: avoid cgroup root name longer than max Ma Shimiao
2017-12-08  8:47 ` Ma Shimiao
2017-12-11 15:12 ` Tejun Heo
2017-12-11 15:12   ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.