Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1493477

[PATCH cgroup/for-4.6] cgroup: fix error handling regressions in proc_cgroup_show() and cgroup_release_agent()

From Tejun Heo <tj@kernel.org>
Newsgroups linux.kernel
Subject [PATCH cgroup/for-4.6] cgroup: fix error handling regressions in proc_cgroup_show() and cgroup_release_agent()
Date 2016-09-29 16:00 +0200
Message-ID <smK2y-4NO-13@gated-at.bofh.it> (permalink)
References <smGid-2kN-9@gated-at.bofh.it> <smGid-2kN-7@gated-at.bofh.it> <smJzr-4DI-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4c737b41de7f ("cgroup: make cgroup_path() and friends behave in the
style of strlcpy()") broke error handling in proc_cgroup_show() and
cgroup_release_agent() by not handling negative return values from
cgroup_path_ns_locked().  Fix it.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/cgroup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 5e2e81a..a7f9fb4 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5781,10 +5781,10 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
 		if (cgroup_on_dfl(cgrp) || !(tsk->flags & PF_EXITING)) {
 			retval = cgroup_path_ns_locked(cgrp, buf, PATH_MAX,
 						current->nsproxy->cgroup_ns);
-			if (retval >= PATH_MAX) {
+			if (retval >= PATH_MAX)
 				retval = -ENAMETOOLONG;
+			if (retval < 0)
 				goto out_unlock;
-			}
 
 			seq_puts(m, buf);
 		} else {
@@ -6069,7 +6069,7 @@ static void cgroup_release_agent(struct work_struct *work)
 	spin_lock_irq(&css_set_lock);
 	ret = cgroup_path_ns_locked(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns);
 	spin_unlock_irq(&css_set_lock);
-	if (ret >= PATH_MAX)
+	if (ret < 0 || ret >= PATH_MAX)
 		goto out;
 
 	argv[0] = agentbuf;
-- 
2.7.4

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH cgroup/for-4.9] cpuset: fix error error handling regression  in proc_cpuset_show() Tejun Heo <tj@kernel.org> - 2016-09-29 12:00 +0200
  Re: [PATCH cgroup/for-4.9] cpuset: fix error error handling  regression in proc_cpuset_show() Dan Carpenter <dan.carpenter@oracle.com> - 2016-09-29 15:30 +0200
    [PATCH cgroup/for-4.6] cgroup: fix error handling regressions in  proc_cgroup_show() and cgroup_release_agent() Tejun Heo <tj@kernel.org> - 2016-09-29 16:00 +0200

csiph-web