-
Notifications
You must be signed in to change notification settings - Fork 263
Description
The upstream lvresize_fs_helper is a bash script, and cports contains a patch (https://github.com/chimera-linux/cports/blob/810f580f29da7b7e41fcc66ab8c8910807b479d3/main/lvm2/patches/0001-lvresize-use-POSIX-shell.patch, originally taken from Alpine Linux) to turn it into a POSIX sh script. Unfortunately, in the meantime more bashisms were introduced upstream (most in https://gitlab.com/lvmteam/lvm2/-/commit/93013c09be07b529f531d35983a49f66b2b1bc7b), which have not been caught as they are far enough from the original ones for the patch to still apply cleanly. The failure mode in https://gitlab.com/lvmteam/lvm2/-/commit/93013c09be07b529f531d35983a49f66b2b1bc7b#line_4f2f61957_A230 is particularly dangerous: when shrinking an LV containing a btrfs, the check wrongly fails due to [[ command not being found, leaving the filesystem with its original size but still shrinking the LV:
# lvresize -L500M --resizefs /dev/mapper/test-test
File system btrfs found on test/test mounted at /mnt.
Skipping check used device size for btrfs.
File system reduce is required using btrfs-progs.
Reducing file system btrfs to 500.00 MiB (524288000 bytes) on test/test...
/usr/libexec/lvresize_fs_helper: [[: not found
Reduced file system btrfs on test/test.
Size of logical volume test/test changed from 1000.00 MiB (250 extents) to 500.00 MiB (125 extents).
Logical volume test/test successfully resized.
If the user does not realize the danger of the situation, and the extra capacity is subsequently otherwise written to or discarded, the filesystem is destroyed irreversibly.
Of course a short term fix could be to revise the patch and remove the additional bashisms. However, in the long term it would be good if this situation could be prevented from arising again; either by accepting that this is a bash script or by checking for additional bashims at build time. I do not know what the best way forward is here.