mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
fs: only copy to userspace on success in listmount()
Avoid copying when we failed to, or didn't have any mounts to list.
Fixes: cb54ef4f05 ("fs: don't copy to userspace under namespace semaphore") # mainline only
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
682d12148c
commit
8d42877ad6
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user