linux-stable/block/partitions
Christoph Hellwig 52f019d43c block: add a hard-readonly flag to struct gendisk
Commit 20bd1d026a ("scsi: sd: Keep disk read-only when re-reading
partition") addressed a long-standing problem with user read-only
policy being overridden as a result of a device-initiated revalidate.
The commit has since been reverted due to a regression that left some
USB devices read-only indefinitely.

To fix the underlying problems with revalidate we need to keep track
of hardware state and user policy separately.

The gendisk has been updated to reflect the current hardware state set
by the device driver. This is done to allow returning the device to
the hardware state once the user clears the BLKROSET flag.

The resulting semantics are as follows:

 - If BLKROSET sets a given partition read-only, that partition will
   remain read-only even if the underlying storage stack initiates a
   revalidate. However, the BLKRRPART ioctl will cause the partition
   table to be dropped and any user policy on partitions will be lost.

 - If BLKROSET has not been set, both the whole disk device and any
   partitions will reflect the current write-protect state of the
   underlying device.

Based on a patch from Martin K. Petersen <martin.petersen@oracle.com>.

Reported-by: Oleksii Kurochko <olkuroch@cisco.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201221
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-01-24 18:15:57 -07:00
..
acorn.c block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
aix.c block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
amiga.c block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
atari.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
atari.h block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
check.h block: move block layer internals out of include/linux/genhd.h 2020-03-25 09:50:08 -06:00
cmdline.c block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
core.c block: add a hard-readonly flag to struct gendisk 2021-01-24 18:15:57 -07:00
efi.c partitions/efi: Fix partition name parsing in GUID partition entry 2020-03-08 10:00:09 +01:00
efi.h Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-03-30 16:13:08 -07:00
ibm.c partitions/ibm: fix non-DASD devices 2020-10-07 07:55:35 -06:00
karma.c block: remove block/partitions/karma.h 2020-03-24 07:57:08 -06:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
ldm.c partitions/ldm: Replace uuid_copy() with import_uuid() where it makes sense 2020-06-18 09:17:54 -06:00
ldm.h block: Replace zero-length array with flexible-array 2020-06-15 23:08:32 -05:00
mac.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mac.h block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
Makefile block: merge partition-generic.c and check.c 2020-03-24 07:57:08 -06:00
msdos.c block: move the various x86 Unix label formats out of genhd.h 2020-03-24 07:57:08 -06:00
osf.c block: remove block/partitions/osf.h 2020-03-24 07:57:08 -06:00
sgi.c block: move the *_PARTITION enum out of genhd.h 2020-03-24 07:57:08 -06:00
sun.c block: move the *_PARTITION enum out of genhd.h 2020-03-24 07:57:08 -06:00
sysv68.c block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
ultrix.c block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00