public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: drop path before copying subvol info to userspace
@ 2022-11-08 13:53 Anand Jain
  2022-11-08 14:37 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Anand Jain @ 2022-11-08 13:53 UTC (permalink / raw)
  To: linux-btrfs

Similar to the commit
   btrfs: drop path before copying root refs to userspace

btrfs_ioctl_get_subvol_info() frees the search path after the userspace
copy from the temp buffer %subvol_info. Fix this by freeing the path
before we copy to userspace.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/ioctl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a64a71d882dc..4742dedd8fd5 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2214,13 +2214,15 @@ static int btrfs_ioctl_get_subvol_info(struct inode *inode, void __user *argp)
 		}
 	}
 
-	if (copy_to_user(argp, subvol_info, sizeof(*subvol_info)))
-		ret = -EFAULT;
-
 out:
 	btrfs_put_root(root);
 out_free:
 	btrfs_free_path(path);
+
+	if (!ret)
+		if (copy_to_user(argp, subvol_info, sizeof(*subvol_info)))
+			ret = -EFAULT;
+
 	kfree(subvol_info);
 	return ret;
 }
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-10  6:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-08 13:53 [PATCH] btrfs: drop path before copying subvol info to userspace Anand Jain
2022-11-08 14:37 ` David Sterba
2022-11-10  6:06   ` Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox