mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
cgroup: Replace all non-returning strlcpy with strscpy
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] https://github.com/KSPP/linux/issues/89 Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
6588880509
commit
c33080cdc0
1 changed files with 2 additions and 2 deletions
|
@ -563,7 +563,7 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of,
|
|||
if (!cgrp)
|
||||
return -ENODEV;
|
||||
spin_lock(&release_agent_path_lock);
|
||||
strlcpy(cgrp->root->release_agent_path, strstrip(buf),
|
||||
strscpy(cgrp->root->release_agent_path, strstrip(buf),
|
||||
sizeof(cgrp->root->release_agent_path));
|
||||
spin_unlock(&release_agent_path_lock);
|
||||
cgroup_kn_unlock(of->kn);
|
||||
|
@ -797,7 +797,7 @@ void cgroup1_release_agent(struct work_struct *work)
|
|||
goto out_free;
|
||||
|
||||
spin_lock(&release_agent_path_lock);
|
||||
strlcpy(agentbuf, cgrp->root->release_agent_path, PATH_MAX);
|
||||
strscpy(agentbuf, cgrp->root->release_agent_path, PATH_MAX);
|
||||
spin_unlock(&release_agent_path_lock);
|
||||
if (!agentbuf[0])
|
||||
goto out_free;
|
||||
|
|
Loading…
Reference in a new issue