linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
To: <tj@kernel.org>, <lizefan@huawei.com>
Cc: <cgroups@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
Subject: [PATCH] cgroup: limit max copied char length for cgroup file name
Date: Sat, 9 Dec 2017 13:47:58 +0800	[thread overview]
Message-ID: <20171209054758.13870-1-mashimiao.fnst@cn.fujitsu.com> (raw)

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

             reply	other threads:[~2017-12-09  5:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-09  5:47 Ma Shimiao [this message]
2017-12-11 15:05 ` [PATCH] cgroup: limit max copied char length for cgroup file name Tejun Heo
2017-12-12  1:19   ` Ma Shimiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171209054758.13870-1-mashimiao.fnst@cn.fujitsu.com \
    --to=mashimiao.fnst@cn.fujitsu.com \
    --cc=cgroups@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).