]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Mar 2022 09:51:03 +0000 (10:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Mar 2022 09:51:03 +0000 (10:51 +0100)
added patches:
ext4-add-check-to-prevent-attempting-to-resize-an-fs-with-sparse_super2.patch

queue-5.10/ext4-add-check-to-prevent-attempting-to-resize-an-fs-with-sparse_super2.patch [new file with mode: 0644]
queue-5.10/series
queue-5.10/watch_queue-fix-filter-limit-check.patch

diff --git a/queue-5.10/ext4-add-check-to-prevent-attempting-to-resize-an-fs-with-sparse_super2.patch b/queue-5.10/ext4-add-check-to-prevent-attempting-to-resize-an-fs-with-sparse_super2.patch
new file mode 100644 (file)
index 0000000..ffb4952
--- /dev/null
@@ -0,0 +1,55 @@
+From b1489186cc8391e0c1e342f9fbc3eedf6b944c61 Mon Sep 17 00:00:00 2001
+From: Josh Triplett <josh@joshtriplett.org>
+Date: Mon, 7 Jun 2021 12:15:24 -0700
+Subject: ext4: add check to prevent attempting to resize an fs with sparse_super2
+
+From: Josh Triplett <josh@joshtriplett.org>
+
+commit b1489186cc8391e0c1e342f9fbc3eedf6b944c61 upstream.
+
+The in-kernel ext4 resize code doesn't support filesystem with the
+sparse_super2 feature. It fails with errors like this and doesn't finish
+the resize:
+EXT4-fs (loop0): resizing filesystem from 16640 to 7864320 blocks
+EXT4-fs warning (device loop0): verify_reserved_gdb:760: reserved GDT 2 missing grp 1 (32770)
+EXT4-fs warning (device loop0): ext4_resize_fs:2111: error (-22) occurred during file system resize
+EXT4-fs (loop0): resized filesystem to 2097152
+
+To reproduce:
+mkfs.ext4 -b 4096 -I 256 -J size=32 -E resize=$((256*1024*1024)) -O sparse_super2 ext4.img 65M
+truncate -s 30G ext4.img
+mount ext4.img /mnt
+python3 -c 'import fcntl, os, struct ; fd = os.open("/mnt", os.O_RDONLY | os.O_DIRECTORY) ; fcntl.ioctl(fd, 0x40086610, struct.pack("Q", 30 * 1024 * 1024 * 1024 // 4096), False) ; os.close(fd)'
+dmesg | tail
+e2fsck ext4.img
+
+The userspace resize2fs tool has a check for this case: it checks if the
+filesystem has sparse_super2 set and if the kernel provides
+/sys/fs/ext4/features/sparse_super2. However, the former check requires
+manually reading and parsing the filesystem superblock.
+
+Detect this case in ext4_resize_begin and error out early with a clear
+error message.
+
+Signed-off-by: Josh Triplett <josh@joshtriplett.org>
+Link: https://lore.kernel.org/r/74b8ae78405270211943cd7393e65586c5faeed1.1623093259.git.josh@joshtriplett.org
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/resize.c |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/fs/ext4/resize.c
++++ b/fs/ext4/resize.c
+@@ -74,6 +74,11 @@ int ext4_resize_begin(struct super_block
+               return -EPERM;
+       }
++      if (ext4_has_feature_sparse_super2(sb)) {
++              ext4_msg(sb, KERN_ERR, "Online resizing not supported with sparse_super2");
++              return -EOPNOTSUPP;
++      }
++
+       if (test_and_set_bit_lock(EXT4_FLAGS_RESIZING,
+                                 &EXT4_SB(sb)->s_ext4_flags))
+               ret = -EBUSY;
index 27478a32f2070fc21c4014e6fb68c34acccc0199..1b9e52db803735266dfe530a29355e296229ac54 100644 (file)
@@ -66,5 +66,6 @@ watch_queue-make-comment-about-setting-defunct-more-accurate.patch
 x86-boot-fix-memremap-of-setup_indirect-structures.patch
 x86-boot-add-setup_indirect-support-in-early_memremap_is_setup_data.patch
 x86-traps-mark-do_int3-nokprobe_symbol.patch
+ext4-add-check-to-prevent-attempting-to-resize-an-fs-with-sparse_super2.patch
 arm-fix-thumb2-regression-with-spectre-bhb.patch
 watch_queue-fix-filter-limit-check.patch
index 51ca005f3b7e1a97aac483c9d4e16497a66d8e73..14bd2a8c56d3409430aff01ac62d70bef757ea45 100644 (file)
@@ -81,7 +81,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
        struct watch_type_filter filters[];
 --- a/kernel/watch_queue.c
 +++ b/kernel/watch_queue.c
-@@ -320,7 +320,7 @@ long watch_queue_set_filter(struct pipe_
+@@ -322,7 +322,7 @@ long watch_queue_set_filter(struct pipe_
                    tf[i].info_mask & WATCH_INFO_LENGTH)
                        goto err_filter;
                /* Ignore any unknown types */
@@ -90,7 +90,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
                        continue;
                nr_filter++;
        }
-@@ -336,7 +336,7 @@ long watch_queue_set_filter(struct pipe_
+@@ -338,7 +338,7 @@ long watch_queue_set_filter(struct pipe_
  
        q = wfilter->filters;
        for (i = 0; i < filter.nr_filters; i++) {