Skip to content

Commit 8d42877

Browse files
committed
fs: only copy to userspace on success in listmount()
Avoid copying when we failed to, or didn't have any mounts to list. Fixes: cb54ef4 ("fs: don't copy to userspace under namespace semaphore") # mainline only Signed-off-by: Christian Brauner <[email protected]>
1 parent 682d121 commit 8d42877

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/namespace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5401,6 +5401,8 @@ SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req,
54015401
scoped_guard(rwsem_read, &namespace_sem)
54025402
ret = do_listmount(ns, kreq.mnt_id, kreq.param, kmnt_ids,
54035403
nr_mnt_ids, (flags & LISTMOUNT_REVERSE));
5404+
if (ret <= 0)
5405+
return ret;
54045406

54055407
if (copy_to_user(mnt_ids, kmnt_ids, ret * sizeof(*mnt_ids)))
54065408
return -EFAULT;

0 commit comments

Comments
 (0)