fs: only copy to userspace on success in listmount()
BugLink: https://bugs.launchpad.net/bugs/2085849 commit 8d42877ad65b02741c9099392a001b7209baa5d4 upstream. Avoid copying when we failed to, or didn't have any mounts to list. Fixes: cb54ef4f050e ("fs: don't copy to userspace under namespace semaphore") # mainline only Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
1249174448
commit
3eda1b2df9
@@ -5138,6 +5138,8 @@ SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req,
|
||||
|
||||
scoped_guard(rwsem_read, &namespace_sem)
|
||||
ret = do_listmount(kreq.mnt_id, kreq.param, kmnt_ids, nr_mnt_ids);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
|
||||
if (copy_to_user(mnt_ids, kmnt_ids, ret * sizeof(*mnt_ids)))
|
||||
return -EFAULT;
|
||||
|
||||
Reference in New Issue
Block a user