Commit 8d42877a authored by Christian Brauner's avatar Christian Brauner

fs: only copy to userspace on success in listmount()

Avoid copying when we failed to, or didn't have any mounts to list.

Fixes: cb54ef4f ("fs: don't copy to userspace under namespace semaphore") # mainline only
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 682d1214
......@@ -5401,6 +5401,8 @@ SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req,
scoped_guard(rwsem_read, &namespace_sem)
ret = do_listmount(ns, kreq.mnt_id, kreq.param, kmnt_ids,
nr_mnt_ids, (flags & LISTMOUNT_REVERSE));
if (ret <= 0)
return ret;
if (copy_to_user(mnt_ids, kmnt_ids, ret * sizeof(*mnt_ids)))
return -EFAULT;
......
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