Skip to content

fix: verify device identity before mounting - #1457

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

fix: verify device identity before mounting#1457
lukasmetzner wants to merge 2 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

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 93.44262% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.88%. Comparing base (e8812c3) to head (72fa2a4).

Files with missing lines Patch % Lines
internal/volumes/deviceidentity_integration.go 0.00% 3 Missing ⚠️
internal/volumes/mount.go 94.73% 1 Missing ⚠️
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     
Flag Coverage Δ
e2e-controller 56.17% <46.55%> (-0.53%) ⬇️
e2e-node 56.17% <46.55%> (-0.53%) ⬇️
integration 3.03% <0.00%> (-0.15%) ⬇️
unit 44.58% <91.37%> (+3.64%) ⬆️

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.

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