Skip to content

fix: verify device identity before mounting - #1457

Open
lukasmetzner wants to merge 5 commits into
mainfrom
fix/device-identity-verification
Open

fix: verify device identity before mounting#1457
lukasmetzner wants to merge 5 commits into
mainfrom
fix/device-identity-verification

Conversation

@lukasmetzner

Copy link
Copy Markdown
Contributor

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

@lukasmetzner
lukasmetzner requested a review from a team as a code owner August 12, 2026 09:23
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.01299% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.51%. Comparing base (b9a310c) to head (8255783).

Files with missing lines Patch % Lines
internal/volumes/deviceidentity.go 83.72% 6 Missing and 1 partial ⚠️
internal/volumes/mount.go 90.62% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1457      +/-   ##
==========================================
+ Coverage   72.59%   73.51%   +0.92%     
==========================================
  Files          17       18       +1     
  Lines        1529     1586      +57     
==========================================
+ Hits         1110     1166      +56     
  Misses        329      329              
- Partials       90       91       +1     
Flag Coverage Δ
e2e-controller 57.18% <64.93%> (+0.54%) ⬆️
e2e-node 57.18% <64.93%> (+0.54%) ⬆️
integration 3.02% <0.00%> (-0.16%) ⬇️
unit 45.90% <85.71%> (+3.71%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
@lukasmetzner
lukasmetzner force-pushed the fix/device-identity-verification branch from 5be4e77 to 8255783 Compare September 8, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Volume data destroyed — blkid incorrectly reports formatted ext4 volume as unformatted after node migration, triggering mkfs

1 participant