]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 18 Feb 2024 09:41:02 +0000 (10:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 18 Feb 2024 09:41:02 +0000 (10:41 +0100)
added patches:
btrfs-forbid-creating-subvol-qgroups.patch
btrfs-forbid-deleting-live-subvol-qgroup.patch
btrfs-send-return-eopnotsupp-on-unknown-flags.patch

queue-5.4/btrfs-forbid-creating-subvol-qgroups.patch [new file with mode: 0644]
queue-5.4/btrfs-forbid-deleting-live-subvol-qgroup.patch [new file with mode: 0644]
queue-5.4/btrfs-send-return-eopnotsupp-on-unknown-flags.patch [new file with mode: 0644]
queue-5.4/series

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 (file)
index 0000000..a705d47
--- /dev/null
@@ -0,0 +1,40 @@
+From 0c309d66dacddf8ce939b891d9ead4a8e21ad6f0 Mon Sep 17 00:00:00 2001
+From: Boris Burkov <boris@bur.io>
+Date: Wed, 10 Jan 2024 17:51:26 -0800
+Subject: btrfs: forbid creating subvol qgroups
+
+From: Boris Burkov <boris@bur.io>
+
+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 <wqu@suse.com>
+Signed-off-by: Boris Burkov <boris@bur.io>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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 (file)
index 0000000..e8e2c2e
--- /dev/null
@@ -0,0 +1,54 @@
+From a8df35619948bd8363d330c20a90c9a7fbff28c0 Mon Sep 17 00:00:00 2001
+From: Boris Burkov <boris@bur.io>
+Date: Wed, 10 Jan 2024 17:30:00 -0800
+Subject: btrfs: forbid deleting live subvol qgroup
+
+From: Boris Burkov <boris@bur.io>
+
+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 <wqu@suse.com>
+Signed-off-by: Boris Burkov <boris@bur.io>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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 (file)
index 0000000..aab94b4
--- /dev/null
@@ -0,0 +1,35 @@
+From f884a9f9e59206a2d41f265e7e403f080d10b493 Mon Sep 17 00:00:00 2001
+From: David Sterba <dsterba@suse.com>
+Date: Wed, 10 Jan 2024 17:48:44 +0100
+Subject: btrfs: send: return EOPNOTSUPP on unknown flags
+
+From: David Sterba <dsterba@suse.com>
+
+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 <fdmanana@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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;
+       }
index 82c3b879c4191a56918059dfa543dcaff19e1935..54dd5f8c4455c55a1b4e08f8c831c02251a48cb9 100644 (file)
@@ -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