linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cgroup: limit max copied char length for cgroup file name
@ 2017-12-09  5:47 Ma Shimiao
  2017-12-11 15:05 ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Ma Shimiao @ 2017-12-09  5:47 UTC (permalink / raw)
  To: tj, lizefan; +Cc: cgroups, linux-kernel, Ma Shimiao

the result of cgroup_file_name will be used by kernfs_remove_name,
and then by kernfs_remove_by_name_ns().
If reached the max length, may have problem printed by WARN() in
kernfs_remove_by_name_ns().

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..7f588d1617c5 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1397,7 +1397,7 @@ static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft,
 			 cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name,
 			 cft->name);
 	else
-		strncpy(buf, cft->name, CGROUP_FILE_NAME_MAX);
+		strncpy(buf, cft->name, CGROUP_FILE_NAME_MAX - 1);
 	return buf;
 }
 
-- 
2.13.6

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-09  5:47 [PATCH] cgroup: limit max copied char length for cgroup file name Ma Shimiao
2017-12-11 15:05 ` Tejun Heo
2017-12-12  1:19   ` Ma Shimiao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).