From: Greg Kroah-Hartman Date: Mon, 3 Apr 2023 13:13:35 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.14.312~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d7f130e90c1cc378c0884857e7ead1b4a0ad752;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: btrfs-scan-device-in-non-exclusive-mode.patch s390-uaccess-add-missing-earlyclobber-annotations-to-__clear_user.patch zonefs-fix-error-message-in-zonefs_file_dio_append.patch --- diff --git a/queue-5.10/btrfs-scan-device-in-non-exclusive-mode.patch b/queue-5.10/btrfs-scan-device-in-non-exclusive-mode.patch new file mode 100644 index 00000000000..27b5beb799f --- /dev/null +++ b/queue-5.10/btrfs-scan-device-in-non-exclusive-mode.patch @@ -0,0 +1,87 @@ +From 50d281fc434cb8e2497f5e70a309ccca6b1a09f0 Mon Sep 17 00:00:00 2001 +From: Anand Jain +Date: Thu, 23 Mar 2023 15:56:48 +0800 +Subject: btrfs: scan device in non-exclusive mode + +From: Anand Jain + +commit 50d281fc434cb8e2497f5e70a309ccca6b1a09f0 upstream. + +This fixes mkfs/mount/check failures due to race with systemd-udevd +scan. + +During the device scan initiated by systemd-udevd, other user space +EXCL operations such as mkfs, mount, or check may get blocked and result +in a "Device or resource busy" error. This is because the device +scan process opens the device with the EXCL flag in the kernel. + +Two reports were received: + + - btrfs/179 test case, where the fsck command failed with the -EBUSY + error + + - LTP pwritev03 test case, where mkfs.vfs failed with + the -EBUSY error, when mkfs.vfs tried to overwrite old btrfs filesystem + on the device. + +In both cases, fsck and mkfs (respectively) were racing with a +systemd-udevd device scan, and systemd-udevd won, resulting in the +-EBUSY error for fsck and mkfs. + +Reproducing the problem has been difficult because there is a very +small window during which these userspace threads can race to +acquire the exclusive device open. Even on the system where the problem +was observed, the problem occurrences were anywhere between 10 to 400 +iterations and chances of reproducing decreases with debug printk()s. + +However, an exclusive device open is unnecessary for the scan process, +as there are no write operations on the device during scan. Furthermore, +during the mount process, the superblock is re-read in the below +function call chain: + + btrfs_mount_root + btrfs_open_devices + open_fs_devices + btrfs_open_one_device + btrfs_get_bdev_and_sb + +So, to fix this issue, removes the FMODE_EXCL flag from the scan +operation, and add a comment. + +The case where mkfs may still write to the device and a scan is running, +the btrfs signature is not written at that time so scan will not +recognize such device. + +Reported-by: Sherry Yang +Reported-by: kernel test robot +Link: https://lore.kernel.org/oe-lkp/202303170839.fdf23068-oliver.sang@intel.com +CC: stable@vger.kernel.org # 5.4+ +Signed-off-by: Anand Jain +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/volumes.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +--- a/fs/btrfs/volumes.c ++++ b/fs/btrfs/volumes.c +@@ -1411,8 +1411,17 @@ struct btrfs_device *btrfs_scan_one_devi + * later supers, using BTRFS_SUPER_MIRROR_MAX instead + */ + bytenr = btrfs_sb_offset(0); +- flags |= FMODE_EXCL; + ++ /* ++ * Avoid using flag |= FMODE_EXCL here, as the systemd-udev may ++ * initiate the device scan which may race with the user's mount ++ * or mkfs command, resulting in failure. ++ * Since the device scan is solely for reading purposes, there is ++ * no need for FMODE_EXCL. Additionally, the devices are read again ++ * during the mount process. It is ok to get some inconsistent ++ * values temporarily, as the device paths of the fsid are the only ++ * required information for assembling the volume. ++ */ + bdev = blkdev_get_by_path(path, flags, holder); + if (IS_ERR(bdev)) + return ERR_CAST(bdev); diff --git a/queue-5.10/s390-uaccess-add-missing-earlyclobber-annotations-to-__clear_user.patch b/queue-5.10/s390-uaccess-add-missing-earlyclobber-annotations-to-__clear_user.patch new file mode 100644 index 00000000000..09f104cb552 --- /dev/null +++ b/queue-5.10/s390-uaccess-add-missing-earlyclobber-annotations-to-__clear_user.patch @@ -0,0 +1,37 @@ +From 89aba4c26fae4e459f755a18912845c348ee48f3 Mon Sep 17 00:00:00 2001 +From: Heiko Carstens +Date: Thu, 23 Mar 2023 13:09:16 +0100 +Subject: s390/uaccess: add missing earlyclobber annotations to __clear_user() + +From: Heiko Carstens + +commit 89aba4c26fae4e459f755a18912845c348ee48f3 upstream. + +Add missing earlyclobber annotation to size, to, and tmp2 operands of the +__clear_user() inline assembly since they are modified or written to before +the last usage of all input operands. This can lead to incorrect register +allocation for the inline assembly. + +Fixes: 6c2a9e6df604 ("[S390] Use alternative user-copy operations for new hardware.") +Reported-by: Mark Rutland +Link: https://lore.kernel.org/all/20230321122514.1743889-3-mark.rutland@arm.com/ +Cc: stable@vger.kernel.org +Reviewed-by: Gerald Schaefer +Signed-off-by: Heiko Carstens +Signed-off-by: Vasily Gorbik +Signed-off-by: Greg Kroah-Hartman +--- + arch/s390/lib/uaccess.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/s390/lib/uaccess.c ++++ b/arch/s390/lib/uaccess.c +@@ -339,7 +339,7 @@ static inline unsigned long clear_user_m + "4: slgr %0,%0\n" + "5:\n" + EX_TABLE(0b,2b) EX_TABLE(3b,5b) +- : "+a" (size), "+a" (to), "+a" (tmp1), "=a" (tmp2) ++ : "+&a" (size), "+&a" (to), "+a" (tmp1), "=&a" (tmp2) + : "a" (empty_zero_page), "d" (reg0) : "cc", "memory"); + return size; + } diff --git a/queue-5.10/series b/queue-5.10/series index 69cd861f131..789436c3aa4 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -161,3 +161,6 @@ xtensa-fix-kasan-report-for-show_stack.patch rcu-fix-rcu_torture_read-ftrace-event.patch drm-etnaviv-fix-reference-leak-when-mmaping-imported-buffer.patch drm-amd-display-add-dsc-support-for-synaptics-cascaded-mst-hub.patch +s390-uaccess-add-missing-earlyclobber-annotations-to-__clear_user.patch +btrfs-scan-device-in-non-exclusive-mode.patch +zonefs-fix-error-message-in-zonefs_file_dio_append.patch diff --git a/queue-5.10/zonefs-fix-error-message-in-zonefs_file_dio_append.patch b/queue-5.10/zonefs-fix-error-message-in-zonefs_file_dio_append.patch new file mode 100644 index 00000000000..7b2a3b5c314 --- /dev/null +++ b/queue-5.10/zonefs-fix-error-message-in-zonefs_file_dio_append.patch @@ -0,0 +1,36 @@ +From 88b170088ad2c3e27086fe35769aa49f8a512564 Mon Sep 17 00:00:00 2001 +From: Damien Le Moal +Date: Mon, 20 Mar 2023 22:49:15 +0900 +Subject: zonefs: Fix error message in zonefs_file_dio_append() + +From: Damien Le Moal + +commit 88b170088ad2c3e27086fe35769aa49f8a512564 upstream. + +Since the expected write location in a sequential file is always at the +end of the file (append write), when an invalid write append location is +detected in zonefs_file_dio_append(), print the invalid written location +instead of the expected write location. + +Fixes: a608da3bd730 ("zonefs: Detect append writes at invalid locations") +Cc: stable@vger.kernel.org +Signed-off-by: Damien Le Moal +Reviewed-by: Christoph Hellwig +Reviewed-by: Johannes Thumshirn +Reviewed-by: Himanshu Madhani +Signed-off-by: Greg Kroah-Hartman +--- + fs/zonefs/super.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/zonefs/super.c ++++ b/fs/zonefs/super.c +@@ -789,7 +789,7 @@ static ssize_t zonefs_file_dio_append(st + if (bio->bi_iter.bi_sector != wpsector) { + zonefs_warn(inode->i_sb, + "Corrupted write pointer %llu for zone at %llu\n", +- wpsector, zi->i_zsector); ++ bio->bi_iter.bi_sector, zi->i_zsector); + ret = -EIO; + } + }