btrfs: Change bit number of BTRFS_FS_BALANCE_RUNNING
PATCH 1/1 btrfs: Change bit number of BTRFS_FS_BALANCE_RUNNING
Commit ddd93ef3b9d6 ("btrfs: track running balance in a simpler way") which introduced this bit assigned it number 17. Unfortunately this bit is already occupied by the BTRFS_FS_NEED_ASYNC_COMMIT bit. This was causing bit 17 to be cleared while __btrfs_balance was running which resulted in fs_info->balance_ctl being deleted while we have balance running. This manifested in an UAF crash. Fix it by putting the definition of the newly introduced balance bit after NEED_ASYNC_COMMIT and giving it number 18.
--- fs/btrfs/ctree.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/btrfs/ctree.h +6 -6
@@ -733,16 +733,16 @@ struct btrfs_delayed_root;*/ #define BTRFS_FS_EXCL_OP 16/* -* Indicate that balance has been set up from the ioctl and is in the main -* phase. The fs_info::balance_ctl is initialized. -*/ -#define BTRFS_FS_BALANCE_RUNNING 17 - -/* * To info transaction_kthread we need an immediate commit so it doesn't * need to wait for commit_interval */ #define BTRFS_FS_NEED_ASYNC_COMMIT 17 +/* +* Indicate that balance has been set up from the ioctl and is in the main +* phase. The fs_info::balance_ctl is initialized. +*/ +#define BTRFS_FS_BALANCE_RUNNING 18 +struct btrfs_fs_info {u8 fsid[BTRFS_FSID_SIZE ];
Signature · 1 line
2.7.4
Quoted 10 lines · Nikolay Borisov
Commit
ddd93ef3b9d6("btrfs: track running balance in a simpler way") which introduced this bit assigned it number 17. Unfortunately this bit is already occupied by theBTRFS_FS_NEED_ASYNC_COMMITbit. This was causing bit 17 to be cleared while__btrfs_balancewas running which resulted infs_info->balance_ctlbeing deleted while we have balance running. This manifested in an UAF crash. Fix it by putting the definition of the newly introduced balance bit afterNEED_ASYNC_COMMITand giving it number 18.Fixes ddd93ef3b9d6 ("btrfs: track running balance in a simpler way")
Uh, thanks for catching it. The bit was free when the volume mutex removal patchset was in development, but the number 17 got used by the recent qgroup patch and I did not adjust it afterwards.
Quoted 18 lines
Signed-off-by Nikolay Borisov <[email protected]>--- fs/btrfs/ctree.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/btrfs/ctree.h +0
-5@@ -733,16 +733,16 @@ struct btrfs_delayed_root;*/ #define BTRFS_FS_EXCL_OP 16/* -* Indicate that balance has been set up from the ioctl and is in the main -* phase. The fs_info::balance_ctl is initialized. -*/ -#define BTRFS_FS_BALANCE_RUNNING 17 -
fs/btrfs/ctree.h struct btrfs_delayed_root; · line 744
Quoted 10 lines
fs/btrfs/ctree.h +5
-1-/* * To info transaction_kthread we need an immediate commit so it doesn't * need to wait for commit_interval */ #define BTRFS_FS_NEED_ASYNC_COMMIT 17 +/* +* Indicate that balance has been set up from the ioctl and is in the main +* phase. The fs_info::balance_ctl is initialized. +*/ +#define BTRFS_FS_BALANCE_RUNNING 18
I'll fold the fix so we don't have an intermediate breakage in the history.
Quoted 9 lines · David Sterba
Quoted 8 lines · Nikolay Borisov
Commit
ddd93ef3b9d6("btrfs: track running balance in a simpler way") which introduced this bit assigned it number 17. Unfortunately this bit is already occupied by theBTRFS_FS_NEED_ASYNC_COMMITbit.This was
causing bit 17 to be cleared while__btrfs_balancewas running which resulted infs_info->balance_ctlbeing deleted
Any idea which thread deleted the fs_info::balance_ctl while balance was still running?
Thanks for catching.
-Anand
Quoted 47 lines
Quoted 6 lines
while we have balance
running. This manifested in an UAF crash. Fix it by putting the definition of the newly introduced balance bit afterNEED_ASYNC_COMMITand giving it number 18.Fixes ddd93ef3b9d6 ("btrfs: track running balance in a simpler way")Uh, thanks for catching it. The bit was free when the volume mutex removal patchset was in development, but the number 17 got used by the recent qgroup patch and I did not adjust it afterwards.
Quoted 18 lines
Signed-off-by Nikolay Borisov <[email protected]>--- fs/btrfs/ctree.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/btrfs/ctree.h +0
-5@@ -733,16 +733,16 @@ struct btrfs_delayed_root;*/ #define BTRFS_FS_EXCL_OP 16/* -* Indicate that balance has been set up from the ioctl and is in the main -* phase. The fs_info::balance_ctl is initialized. -*/ -#define BTRFS_FS_BALANCE_RUNNING 17 -fs/btrfs/ctree.h struct btrfs_delayed_root; · line 744
Quoted 10 lines
fs/btrfs/ctree.h +5
-1-/* * To info transaction_kthread we need an immediate commit so it doesn't * need to wait for commit_interval */ #define BTRFS_FS_NEED_ASYNC_COMMIT 17 +/* +* Indicate that balance has been set up from the ioctl and is in the main +* phase. The fs_info::balance_ctl is initialized. +*/ +#define BTRFS_FS_BALANCE_RUNNING 18I'll fold the fix so we don't have an intermediate breakage in the history.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Anand Jain
Quoted 4 lines · David Sterba
Quoted 3 lines · Nikolay Borisov
Commit
ddd93ef3b9d6("btrfs: track running balance in a simpler way") which introduced this bit assigned it number 17. Unfortunately this bit is already occupied by theBTRFS_FS_NEED_ASYNC_COMMITbit.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
This was
causing bit 17 to be cleared while__btrfs_balancewas running which resulted infs_info->balance_ctlbeing deletedAny idea which thread deleted the
fs_info::balance_ctlwhile balance was still running?
So what happened is that the test's btrfs balance stop ioctl was allowed to proceed while __btrfs_balance was running. And this was due to bit 17 being cleared by btrfs_commit_transaction.
Quoted 56 lines
Thanks for catching.
-AnandQuoted 50 lines
Quoted 6 lines
while we have balance
running. This manifested in an UAF crash. Fix it by putting the definition of the newly introduced balance bit afterNEED_ASYNC_COMMITand giving it number 18.Fixes ddd93ef3b9d6 ("btrfs: track running balance in a simpler way")Uh, thanks for catching it. The bit was free when the volume mutex removal patchset was in development, but the number 17 got used by the recent qgroup patch and I did not adjust it afterwards.
Quoted 23 lines
Signed-off-by Nikolay Borisov <[email protected]>---
fs/btrfs/ctree.h| 12 ++++++------1 file changed, 6 insertions(+), 6 deletions(-)fs/btrfs/ctree.h +0
-1@@ -733,16 +733,16 @@ struct btrfs_delayed_root;*/ #define BTRFS_FS_EXCL_OP 16 /* -* Indicate that balance has been set up from the ioctl and is in the main
- * phase. Thefs_info::balance_ctlis initialized.
- */fs/btrfs/ctree.h +0
-3-#define BTRFS_FS_BALANCE_RUNNING 17 - -/* * To info
transaction_kthreadwe need an immediate commit so it doesn't
* need to wait forcommit_intervalQuoted 8 lines
*/
#define BTRFS_FS_NEED_ASYNC_COMMIT 17
+/*
+ * Indicate that balance has been set up from the ioctl and is in the main
+ * phase. Thefs_info::balance_ctlis initialized.
+ */
+#define BTRFS_FS_BALANCE_RUNNING 18I'll fold the fix so we don't have an intermediate breakage in the history.
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html