From: Greg Kroah-Hartman Date: Sun, 18 Feb 2024 09:41:02 +0000 (+0100) Subject: 5.4-stable patches X-Git-Tag: v4.19.307~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fc26236839f4590a35b97292cba193a683506d8;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: btrfs-forbid-creating-subvol-qgroups.patch btrfs-forbid-deleting-live-subvol-qgroup.patch btrfs-send-return-eopnotsupp-on-unknown-flags.patch --- diff --git a/queue-5.4/btrfs-forbid-creating-subvol-qgroups.patch b/queue-5.4/btrfs-forbid-creating-subvol-qgroups.patch new file mode 100644 index 00000000000..a705d4724f9 --- /dev/null +++ b/queue-5.4/btrfs-forbid-creating-subvol-qgroups.patch @@ -0,0 +1,40 @@ +From 0c309d66dacddf8ce939b891d9ead4a8e21ad6f0 Mon Sep 17 00:00:00 2001 +From: Boris Burkov +Date: Wed, 10 Jan 2024 17:51:26 -0800 +Subject: btrfs: forbid creating subvol qgroups + +From: Boris Burkov + +commit 0c309d66dacddf8ce939b891d9ead4a8e21ad6f0 upstream. + +Creating a qgroup 0/subvolid leads to various races and it isn't +helpful, because you can't specify a subvol id when creating a subvol, +so you can't be sure it will be the right one. Any requirements on the +automatic subvol can be gratified by using a higher level qgroup and the +inheritance parameters of subvol creation. + +Fixes: cecbb533b5fc ("btrfs: record simple quota deltas in delayed refs") +CC: stable@vger.kernel.org # 4.14+ +Reviewed-by: Qu Wenruo +Signed-off-by: Boris Burkov +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/ioctl.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/fs/btrfs/ioctl.c ++++ b/fs/btrfs/ioctl.c +@@ -4974,6 +4974,11 @@ static long btrfs_ioctl_qgroup_create(st + goto out; + } + ++ if (sa->create && is_fstree(sa->qgroupid)) { ++ ret = -EINVAL; ++ goto out; ++ } ++ + trans = btrfs_join_transaction(root); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); diff --git a/queue-5.4/btrfs-forbid-deleting-live-subvol-qgroup.patch b/queue-5.4/btrfs-forbid-deleting-live-subvol-qgroup.patch new file mode 100644 index 00000000000..e8e2c2ead1c --- /dev/null +++ b/queue-5.4/btrfs-forbid-deleting-live-subvol-qgroup.patch @@ -0,0 +1,54 @@ +From a8df35619948bd8363d330c20a90c9a7fbff28c0 Mon Sep 17 00:00:00 2001 +From: Boris Burkov +Date: Wed, 10 Jan 2024 17:30:00 -0800 +Subject: btrfs: forbid deleting live subvol qgroup + +From: Boris Burkov + +commit a8df35619948bd8363d330c20a90c9a7fbff28c0 upstream. + +If a subvolume still exists, forbid deleting its qgroup 0/subvolid. +This behavior generally leads to incorrect behavior in squotas and +doesn't have a legitimate purpose. + +Fixes: cecbb533b5fc ("btrfs: record simple quota deltas in delayed refs") +CC: stable@vger.kernel.org # 5.4+ +Reviewed-by: Qu Wenruo +Signed-off-by: Boris Burkov +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/qgroup.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +--- a/fs/btrfs/qgroup.c ++++ b/fs/btrfs/qgroup.c +@@ -1561,6 +1561,15 @@ out: + return ret; + } + ++static bool qgroup_has_usage(struct btrfs_qgroup *qgroup) ++{ ++ return (qgroup->rfer > 0 || qgroup->rfer_cmpr > 0 || ++ qgroup->excl > 0 || qgroup->excl_cmpr > 0 || ++ qgroup->rsv.values[BTRFS_QGROUP_RSV_DATA] > 0 || ++ qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PREALLOC] > 0 || ++ qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PERTRANS] > 0); ++} ++ + int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid) + { + struct btrfs_fs_info *fs_info = trans->fs_info; +@@ -1580,6 +1589,11 @@ int btrfs_remove_qgroup(struct btrfs_tra + goto out; + } + ++ if (is_fstree(qgroupid) && qgroup_has_usage(qgroup)) { ++ ret = -EBUSY; ++ goto out; ++ } ++ + /* Check if there are no children of this qgroup */ + if (!list_empty(&qgroup->members)) { + ret = -EBUSY; diff --git a/queue-5.4/btrfs-send-return-eopnotsupp-on-unknown-flags.patch b/queue-5.4/btrfs-send-return-eopnotsupp-on-unknown-flags.patch new file mode 100644 index 00000000000..aab94b4f1e3 --- /dev/null +++ b/queue-5.4/btrfs-send-return-eopnotsupp-on-unknown-flags.patch @@ -0,0 +1,35 @@ +From f884a9f9e59206a2d41f265e7e403f080d10b493 Mon Sep 17 00:00:00 2001 +From: David Sterba +Date: Wed, 10 Jan 2024 17:48:44 +0100 +Subject: btrfs: send: return EOPNOTSUPP on unknown flags + +From: David Sterba + +commit f884a9f9e59206a2d41f265e7e403f080d10b493 upstream. + +When some ioctl flags are checked we return EOPNOTSUPP, like for +BTRFS_SCRUB_SUPPORTED_FLAGS, BTRFS_SUBVOL_CREATE_ARGS_MASK or fallocate +modes. The EINVAL is supposed to be for a supported but invalid +values or combination of options. Fix that when checking send flags so +it's consistent with the rest. + +CC: stable@vger.kernel.org # 4.14+ +Link: https://lore.kernel.org/linux-btrfs/CAL3q7H5rryOLzp3EKq8RTbjMHMHeaJubfpsVLF6H4qJnKCUR1w@mail.gmail.com/ +Reviewed-by: Filipe Manana +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/send.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/btrfs/send.c ++++ b/fs/btrfs/send.c +@@ -7363,7 +7363,7 @@ long btrfs_ioctl_send(struct file *mnt_f + } + + if (arg->flags & ~BTRFS_SEND_FLAG_MASK) { +- ret = -EINVAL; ++ ret = -EOPNOTSUPP; + goto out; + } + diff --git a/queue-5.4/series b/queue-5.4/series index 82c3b879c41..54dd5f8c445 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -201,3 +201,6 @@ vhost-use-kzalloc-instead-of-kmalloc-followed-by-memset.patch net-stmmac-xgmac-use-define-for-string-constants.patch net-stmmac-xgmac-fix-a-typo-of-register-name-in-dpp-safety-handling.patch netfilter-nft_set_rbtree-skip-end-interval-element-from-gc.patch +btrfs-forbid-creating-subvol-qgroups.patch +btrfs-forbid-deleting-live-subvol-qgroup.patch +btrfs-send-return-eopnotsupp-on-unknown-flags.patch