Commit e0223003 authored by Tejun Heo's avatar Tejun Heo

cgroup: fix error handling regressions in proc_cgroup_show() and cgroup_release_agent()

4c737b41 ("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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 679a5e3f
...@@ -5781,10 +5781,10 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns, ...@@ -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)) { if (cgroup_on_dfl(cgrp) || !(tsk->flags & PF_EXITING)) {
retval = cgroup_path_ns_locked(cgrp, buf, PATH_MAX, retval = cgroup_path_ns_locked(cgrp, buf, PATH_MAX,
current->nsproxy->cgroup_ns); current->nsproxy->cgroup_ns);
if (retval >= PATH_MAX) { if (retval >= PATH_MAX)
retval = -ENAMETOOLONG; retval = -ENAMETOOLONG;
if (retval < 0)
goto out_unlock; goto out_unlock;
}
seq_puts(m, buf); seq_puts(m, buf);
} else { } else {
...@@ -6069,7 +6069,7 @@ static void cgroup_release_agent(struct work_struct *work) ...@@ -6069,7 +6069,7 @@ static void cgroup_release_agent(struct work_struct *work)
spin_lock_irq(&css_set_lock); spin_lock_irq(&css_set_lock);
ret = cgroup_path_ns_locked(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns); ret = cgroup_path_ns_locked(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns);
spin_unlock_irq(&css_set_lock); spin_unlock_irq(&css_set_lock);
if (ret >= PATH_MAX) if (ret < 0 || ret >= PATH_MAX)
goto out; goto out;
argv[0] = agentbuf; argv[0] = agentbuf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment