fix: verify device identity before mounting - #1457
Open
lukasmetzner wants to merge 2 commits into
Open
Conversation
The `/dev/disk/by-id` symlinks are maintained asynchronously by udev, so after an attach that reuses a device name, the symlink of one volume can still resolve to the block device of another. The resolved device is now checked against the volume ID taken from the by-id path by reading its SCSI serial from VPD page 0x80 in `/sys/class/block/<device>/device/vpd_pg80`. A mismatch is retried through the existing `waitDeviceReady` backoff, which is where a symlink udev has not caught up with yet becomes correct. The check is fail-closed: if the serial cannot be read, the volume is not published rather than published unverified, because mounting the wrong device destroys data while refusing to mount does not. Devices that do not expose `vpd_pg80` are therefore no longer published. Fixes #1346
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1457 +/- ##
==========================================
+ Coverage 72.13% 72.88% +0.74%
==========================================
Files 17 19 +2
Lines 1529 1582 +53
==========================================
+ Hits 1103 1153 +50
- Misses 337 341 +4
+ Partials 89 88 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
/dev/disk/by-idsymlinks are maintained asynchronously by udev, soafter an attach that reuses a device name, the symlink of one volume can
still resolve to the block device of another.
The resolved device is now checked against the volume ID taken from the
by-id path by reading its SCSI serial from VPD page 0x80 in
/sys/class/block/<device>/device/vpd_pg80. A mismatch is retriedthrough the existing
waitDeviceReadybackoff, which is where a symlinkudev has not caught up with yet becomes correct.
The check is fail-closed: if the serial cannot be read, the volume is
not published rather than published unverified, because mounting the
wrong device destroys data while refusing to mount does not. Devices
that do not expose
vpd_pg80are therefore no longer published.Fixes #1346