lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230324031611.98986-1-xiaoshoukui@gmail.com>
Date:   Thu, 23 Mar 2023 23:16:11 -0400
From:   xiaoshoukui <xiaoshoukui@...il.com>
To:     clm@...com, josef@...icpanda.com, dsterba@...e.com
Cc:     linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
        xiaoshoukui <xiaoshoukui@...il.com>,
        xiaoshoukui <xiaoshoukui@...jie.com.cn>
Subject: [PATCH] btrfs: ioctl: fix inaccurate determination of exclusive_operation

with fs_info->exclusive_operation == BTRFS_EXCLOP_DEV_ADD enter
btrfs_ioctl_add_dev function , exclusive_operation will be classified
as in paused balance operation. After return from btrfs_ioctl_add_dev,
exclusive_operation will be restore to BTRFS_EXCLOP_BALANCE_PAUSED which
is not its original state.

Signed-off-by: xiaoshoukui <xiaoshoukui@...jie.com.cn>
---
 fs/btrfs/ioctl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a0ef1a1784c7..aab5fdb9445c 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2629,7 +2629,7 @@ static long btrfs_ioctl_add_dev(struct btrfs_fs_info *fs_info, void __user *arg)
 	}
 
 	if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_DEV_ADD)) {
-		if (!btrfs_exclop_start_try_lock(fs_info, BTRFS_EXCLOP_DEV_ADD))
+		if (fs_info->exclusive_operation != BTRFS_EXCLOP_BALANCE_PAUSED)
 			return BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
 
 		/*
@@ -2637,8 +2637,9 @@ static long btrfs_ioctl_add_dev(struct btrfs_fs_info *fs_info, void __user *arg)
 		 * change the exclusive op type and remember we should bring
 		 * back the paused balance
 		 */
+		spin_lock(&fs_info->super_lock);
 		fs_info->exclusive_operation = BTRFS_EXCLOP_DEV_ADD;
-		btrfs_exclop_start_unlock(fs_info);
+		spin_unlock(&fs_info->super_lock);
 		restore_op = true;
 	}
 
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ