6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner brauner@kernel.org
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 --- fs/namespace.c | 2 ++ 1 file changed, 2 insertions(+)
--- a/fs/namespace.c +++ b/fs/namespace.c @@ -5138,6 +5138,8 @@ SYSCALL_DEFINE4(listmount, const struct
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;