diff options
author | Tejun Heo <tj@kernel.org> | 2016-09-29 09:49:40 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2016-09-29 09:55:16 -0400 |
commit | e0223003e6e141533446d01a92784592a97a8552 (patch) | |
tree | 3d7ce11cc68859ebd05c0d8196419734eda26b21 | |
parent | 679a5e3f12830392d14f94b04bbe0f3cabdbd773 (diff) |
cgroup: fix error handling regressions in proc_cgroup_show() and cgroup_release_agent()
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>
-rw-r--r-- | kernel/cgroup.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 5e2e81ad9175..a7f9fb4e1fc7 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, | |||
5781 | if (cgroup_on_dfl(cgrp) || !(tsk->flags & PF_EXITING)) { | 5781 | if (cgroup_on_dfl(cgrp) || !(tsk->flags & PF_EXITING)) { |
5782 | retval = cgroup_path_ns_locked(cgrp, buf, PATH_MAX, | 5782 | retval = cgroup_path_ns_locked(cgrp, buf, PATH_MAX, |
5783 | current->nsproxy->cgroup_ns); | 5783 | current->nsproxy->cgroup_ns); |
5784 | if (retval >= PATH_MAX) { | 5784 | if (retval >= PATH_MAX) |
5785 | retval = -ENAMETOOLONG; | 5785 | retval = -ENAMETOOLONG; |
5786 | if (retval < 0) | ||
5786 | goto out_unlock; | 5787 | goto out_unlock; |
5787 | } | ||
5788 | 5788 | ||
5789 | seq_puts(m, buf); | 5789 | seq_puts(m, buf); |
5790 | } else { | 5790 | } else { |
@@ -6069,7 +6069,7 @@ static void cgroup_release_agent(struct work_struct *work) | |||
6069 | spin_lock_irq(&css_set_lock); | 6069 | spin_lock_irq(&css_set_lock); |
6070 | ret = cgroup_path_ns_locked(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns); | 6070 | ret = cgroup_path_ns_locked(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns); |
6071 | spin_unlock_irq(&css_set_lock); | 6071 | spin_unlock_irq(&css_set_lock); |
6072 | if (ret >= PATH_MAX) | 6072 | if (ret < 0 || ret >= PATH_MAX) |
6073 | goto out; | 6073 | goto out; |
6074 | 6074 | ||
6075 | argv[0] = agentbuf; | 6075 | argv[0] = agentbuf; |