diff options
| author | Christian Brauner <brauner@kernel.org> | 2024-07-04 17:00:19 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2024-07-04 17:00:19 +0200 |
| commit | 8d42877ad65b02741c9099392a001b7209baa5d4 (patch) | |
| tree | 690f0b3cfca477c458e9955bb8ee067c2874d799 /fs | |
| parent | 682d12148c264484562f130f0c8584839ebc36fc (diff) | |
| download | linux-8d42877ad65b02741c9099392a001b7209baa5d4.tar.gz linux-8d42877ad65b02741c9099392a001b7209baa5d4.tar.bz2 linux-8d42877ad65b02741c9099392a001b7209baa5d4.zip | |
fs: only copy to userspace on success in listmount()
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>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/namespace.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index c53a0ee748c6..f44e5448c8a0 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -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; |
