diff options
author | David Sterba <dsterba@suse.cz> | 2013-04-26 11:20:23 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-05-06 15:55:25 -0400 |
commit | 55793c0d0381176e727389325d9a47f7f0b5387f (patch) | |
tree | 580c9b7f5562e314bf13a8cdb92b342bc17db75a /fs/btrfs | |
parent | f7a52a40cabea38b99b5053bc4f7cf45f4997603 (diff) |
btrfs: read entire device info under lock
There's a theoretical possibility of reading stale (or even more
theoretically, freed) data from DEV_INFO ioctl when the device would
disappear between an early mutex unlock and data being copied from the
device structure.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ioctl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 3aa37508bf23..0de4a2fcfb24 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -2432,7 +2432,6 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) | |||
2432 | 2432 | ||
2433 | mutex_lock(&fs_devices->device_list_mutex); | 2433 | mutex_lock(&fs_devices->device_list_mutex); |
2434 | dev = btrfs_find_device(root->fs_info, di_args->devid, s_uuid, NULL); | 2434 | dev = btrfs_find_device(root->fs_info, di_args->devid, s_uuid, NULL); |
2435 | mutex_unlock(&fs_devices->device_list_mutex); | ||
2436 | 2435 | ||
2437 | if (!dev) { | 2436 | if (!dev) { |
2438 | ret = -ENODEV; | 2437 | ret = -ENODEV; |
@@ -2456,6 +2455,7 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) | |||
2456 | } | 2455 | } |
2457 | 2456 | ||
2458 | out: | 2457 | out: |
2458 | mutex_unlock(&fs_devices->device_list_mutex); | ||
2459 | if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args))) | 2459 | if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args))) |
2460 | ret = -EFAULT; | 2460 | ret = -EFAULT; |
2461 | 2461 | ||