From d5aacbe1eda64ba8935e246ed9aec7a43cf2057d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 1 Sep 2021 12:28:30 +0200 Subject: [PATCH] 4.19-stable patches added patches: revert-floppy-reintroduce-o_ndelay-fix.patch --- ...vert-floppy-reintroduce-o_ndelay-fix.patch | 69 +++++++++++++++++++ queue-4.19/series | 1 + 2 files changed, 70 insertions(+) create mode 100644 queue-4.19/revert-floppy-reintroduce-o_ndelay-fix.patch diff --git a/queue-4.19/revert-floppy-reintroduce-o_ndelay-fix.patch b/queue-4.19/revert-floppy-reintroduce-o_ndelay-fix.patch new file mode 100644 index 00000000000..15d4d47ccdf --- /dev/null +++ b/queue-4.19/revert-floppy-reintroduce-o_ndelay-fix.patch @@ -0,0 +1,69 @@ +From c7e9d0020361f4308a70cdfd6d5335e273eb8717 Mon Sep 17 00:00:00 2001 +From: Denis Efremov +Date: Sat, 7 Aug 2021 10:37:02 +0300 +Subject: Revert "floppy: reintroduce O_NDELAY fix" + +From: Denis Efremov + +commit c7e9d0020361f4308a70cdfd6d5335e273eb8717 upstream. + +The patch breaks userspace implementations (e.g. fdutils) and introduces +regressions in behaviour. Previously, it was possible to O_NDELAY open a +floppy device with no media inserted or with write protected media without +an error. Some userspace tools use this particular behavior for probing. + +It's not the first time when we revert this patch. Previous revert is in +commit f2791e7eadf4 (Revert "floppy: refactor open() flags handling"). + +This reverts commit 8a0c014cd20516ade9654fc13b51345ec58e7be8. + +Link: https://lore.kernel.org/linux-block/de10cb47-34d1-5a88-7751-225ca380f735@compro.net/ +Reported-by: Mark Hounschell +Cc: Jiri Kosina +Cc: Wim Osterholt +Cc: Kurt Garloff +Cc: +Signed-off-by: Denis Efremov +Signed-off-by: Greg Kroah-Hartman +--- + drivers/block/floppy.c | 27 +++++++++++++-------------- + 1 file changed, 13 insertions(+), 14 deletions(-) + +--- a/drivers/block/floppy.c ++++ b/drivers/block/floppy.c +@@ -4074,22 +4074,21 @@ static int floppy_open(struct block_devi + if (UFDCS->rawcmd == 1) + UFDCS->rawcmd = 2; + +- if (mode & (FMODE_READ|FMODE_WRITE)) { +- UDRS->last_checked = 0; +- clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); +- check_disk_change(bdev); +- if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) +- goto out; +- if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) ++ if (!(mode & FMODE_NDELAY)) { ++ if (mode & (FMODE_READ|FMODE_WRITE)) { ++ UDRS->last_checked = 0; ++ clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); ++ check_disk_change(bdev); ++ if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) ++ goto out; ++ if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) ++ goto out; ++ } ++ res = -EROFS; ++ if ((mode & FMODE_WRITE) && ++ !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) + goto out; + } +- +- res = -EROFS; +- +- if ((mode & FMODE_WRITE) && +- !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) +- goto out; +- + mutex_unlock(&open_lock); + mutex_unlock(&floppy_mutex); + return 0; diff --git a/queue-4.19/series b/queue-4.19/series index 8d6b0ccc780..4cfd668559f 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -29,3 +29,4 @@ net-rds-dma_map_sg-is-entitled-to-merge-entries.patch vt_kdsetmode-extend-console-locking.patch fbmem-add-margin-check-to-fb_check_caps.patch kvm-x86-mmu-treat-nx-as-used-not-reserved-for-all-tdp-shadow-mmus.patch +revert-floppy-reintroduce-o_ndelay-fix.patch -- 2.47.3