* [PATCH] cgroup: limit max copied char length for cgroup file name
@ 2017-12-09 5:47 Ma Shimiao
[not found] ` <20171209054758.13870-1-mashimiao.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Ma Shimiao @ 2017-12-09 5:47 UTC (permalink / raw)
To: tj-DgEjT+Ai2ygdnm+yROfE0A, lizefan-hv44wF8Li93QT0dZR+AlfA
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, 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-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..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[parent not found: <20171209054758.13870-1-mashimiao.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>]
* Re: [PATCH] cgroup: limit max copied char length for cgroup file name [not found] ` <20171209054758.13870-1-mashimiao.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> @ 2017-12-11 15:05 ` Tejun Heo [not found] ` <20171211150551.GC2421075-4dN5La/x3IkLX0oZNxdnEQ2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Tejun Heo @ 2017-12-11 15:05 UTC (permalink / raw) To: Ma Shimiao Cc: lizefan-hv44wF8Li93QT0dZR+AlfA, cgroups-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA On Sat, Dec 09, 2017 at 01:47:58PM +0800, Ma Shimiao wrote: > 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-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> Can we use strscpy() instead? Thanks. -- tejun ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <20171211150551.GC2421075-4dN5La/x3IkLX0oZNxdnEQ2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org>]
* Re: [PATCH] cgroup: limit max copied char length for cgroup file name [not found] ` <20171211150551.GC2421075-4dN5La/x3IkLX0oZNxdnEQ2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org> @ 2017-12-12 1:19 ` Ma Shimiao 0 siblings, 0 replies; 3+ messages in thread From: Ma Shimiao @ 2017-12-12 1:19 UTC (permalink / raw) To: Tejun Heo Cc: lizefan-hv44wF8Li93QT0dZR+AlfA, cgroups-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA On 12/11/2017 11:05 PM, Tejun Heo wrote: > On Sat, Dec 09, 2017 at 01:47:58PM +0800, Ma Shimiao wrote: >> 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-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> > > Can we use strscpy() instead? OK, I will update the patch > > Thanks. > -- Ma Shimiao Development Dept.I Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST) ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-12 1:19 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
[not found] ` <20171209054758.13870-1-mashimiao.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2017-12-11 15:05 ` Tejun Heo
[not found] ` <20171211150551.GC2421075-4dN5La/x3IkLX0oZNxdnEQ2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org>
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