block: Add config option to not allow writing to mounted devices
Status from this message: Applied to the vfs.super branch of the vfs/vfs.git tree.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest7 patches 15 repliesApplied
- v2 RFC6 patches 32 repliesSuperseded
- v11 patch 35 repliesSuperseded
Changes in v3 from the cover letter
* Rebased on top of current VFS tree
* Added missing conversion of bcachefs to new bdev opening API
* Added patch to drop old bdev opening API
* Dropped support for restricting writes to btrfs to avoid patch dependencies and unblock merging of the patches
Patches in v3 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | bcachefs: Convert to bdev_open_by_path()fs/ fs/ | +11 | 6 replies | |
| 2/7 | block: Remove blkdev_get_by_*() functionsblock/ include/ | +30 | 1 reply | |
| 3/7 | block: Add config option to not allow writing to mounted devicesblock/ block/ include/ +1 more | +84 | 5 replies | |
| 4/7 | btrfs: Do not restrict writes to btrfs devicesfs/ | +2 | 1 reply | |
| 5/7 | fs: Block writes to mounted block devicesinclude/ | +2 | 1 reply | |
| 6/7 | xfs: Block writes to log devicefs/ | +3 | 0 replies | |
| 7/7 | ext4: Block writes to journal devicefs/ | +3 | 0 replies |
Reviews trailers per patch
5 of 7 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Christoph Hellwig | Darrick J. Wong | Kent Overstreet | David Sterba | Christian Brauner | Jens Axboe |
|---|---|---|---|---|---|---|
| Series | R-b | |||||
| 1/7 | A-b | |||||
| 2/7 | A-b | R-b | ||||
| 3/7 | ||||||
| 4/7 | A-b | |||||
| 5/7 | R-b | |||||
| 6/7 | R-b | |||||
| 7/7 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.
Cover letter [PATCH 0/7 v3] block: Add config option to not allow writing to mounted devices
Hello!
This is the third version of the patches to add config option to not allow writing to mounted block devices. The new API for block device opening has been merged so hopefully this patchset can progress towards being merged. We face some issues with necessary btrfs changes (review bandwidth) so this series is modified to enable restricting of writes for all other filesystems. Once btrfs can merge necessary device scanning changes, enabling the support for restricting writes for it is trivial.
For motivation why restricting writes to mounted block devices is interesting see patch 3/7. I've been testing the patches more extensively and I've found couple of things that get broken by disallowing writes to mounted block devices:
1) "mount -o loop" gets broken because util-linux keeps the loop device open read-write when attempting to mount it. Hopefully fixable within util-linux.
2) resize2fs online resizing gets broken because it tries to open the block device read-write only to call resizing ioctl. Trivial to fix within e2fsprogs.
3) Online e2label will break because it directly writes to the ext2/3/4 superblock while the FS is mounted to set the new label. Ext4 driver will have to implement the SETFSLABEL ioctl() and e2label will have to use it, matching what happens for online labelling of btrfs and xfs.
Likely there will be other breakage I didn't find yet but overall the breakage looks minor enough that the option might be useful. Definitely good enough for syzbot fuzzing and likely good enough for hardening of systems with more tightened security.
This patch set is based on the VFS tree as of yesterday.
Changes since v2:
* Rebased on top of current VFS tree
* Added missing conversion of bcachefs to new bdev opening API
* Added patch to drop old bdev opening API
* Dropped support for restricting writes to btrfs to avoid patch dependencies and unblock merging of the patches
Changes since v1:
* Added kernel cmdline argument to toggle whether writing to mounted block devices is allowed or not
* Fixed handling of partitions
* Limit write blocking only to devices open with explicit BLK_OPEN_BLOCK_WRITES flag
Honza
Previous versions: