Repository navigation
wdc, sandisk: read ext SMART cloud log counters unaligned - #4482
Merged
Merged
Conversation
The extended SMART cloud log printers in plugins/wdc/wdc-nvme.c and their copies in plugins/sandisk/sandisk-utils.c read four 8-byte counters (ext_smart_bunbc, ext_smart_pfc, ext_smart_efc, and ext_smart_bsnbc) by casting the byte arrays to uint16_t * and uint64_t *. Three of those fields sit at offsets 132, 140, and 218 in the packed log struct, which are not 8-byte aligned and trigger UBSan misaligned-load aborts in wdc vs-nand-stats, wdc vs-cloud-log, and sndk vs-smart-add-log: wdc-nvme.c:7107:16: runtime error: load of misaligned address 0x60d2eca62dd4 for type 'uint64_t', which requires 8 byte alignment Read all four counters with shr_get_unaligned_le16() and shr_get_unaligned_le64() before applying the 0xFFFFFFFFFFFF0000 mask, and add sndk vs-smart-add-log to SN820CLTest so both plugins are covered by the mock suite. Fixes: d2350f3 ("wdc: Updated field descriptions in vs-cloud-log command") Fixes: 01eb367 ("plugins/sandisk: port vs-smart-add-log from wdc") Signed-off-by: Sagar Narayan <113566055+sagaragas@users.noreply.github.com>
Contributor
|
@sagaragas Your changes look fine to me. Could you also update the SANDISK_PLUGIN_VERSION in sandisk-nvme.c? The current value is 3.1.7 and I'd recommend updating it to 3.3.0 to match the current main version. |
Bump SANDISK_PLUGIN_VERSION from 3.1.7 to 3.3.0 to match the current nvme-cli 3.3 version. Signed-off-by: Sagar Narayan <113566055+sagaragas@users.noreply.github.com>
brandon-paupore-sndk
left a comment
Contributor
There was a problem hiding this comment.
Just had one additional comment beyond Jeff's, otherwise the fixes for LE ordering seem good to me!
| 'wdc vs-cloud-log', | ||
| 'wdc vs-hw-rev-log', | ||
| 'wdc vs-device-waf', | ||
| 'sndk vs-smart-add-log', |
Contributor
There was a problem hiding this comment.
This should probably go under a separate (new) test file for the sndk plugin, rather than being tucked away in this file.
Contributor
Author
There was a problem hiding this comment.
Moved it to its own sndk test file in tests/cli/sandisk/sandisk_mock_test.py.
Move the SN820CL sndk vs-smart-add-log test out of tests/cli/wdc/wdc_mock_test.py into a dedicated sandisk plugin mock test under tests/cli/sandisk/, guarded by 'sandisk' in selected_plugins. Signed-off-by: Sagar Narayan <113566055+sagaragas@users.noreply.github.com>
Contributor
Author
|
Updated |
jeff-lien-sndk
approved these changes
Nov 30, 2026
brandon-paupore-sndk
approved these changes
Nov 30, 2026
Collaborator
|
Thanks everyone! |
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.
Under UBSan,
wdc vs-nand-stats,wdc vs-cloud-log, andsndk vs-smart-add-logabort on misaligneduint64_tloads in the extended SMART cloud log printers. Bothplugins/wdc/wdc-nvme.cand its copy inplugins/sandisk/sandisk-utils.chit this in normal and JSON output. Three of the four 8-byte counters (ext_smart_pfc,ext_smart_efc,ext_smart_bsnbc) sit at offsets 132, 140, and 218 in the packed struct.This switches all four counters in both plugins to
shr_get_unaligned_le16()andshr_get_unaligned_le64(), keeping the existing0xFFFFFFFFFFFF0000mask on the decoded value. I also added asndk vs-smart-add-logmock test intests/cli/sandisk/sandisk_mock_test.pyso the mock suite covers both plugins.I tested plain and
-Db_sanitize=undefinedbuilds on Linux x86_64. Under UBSan,masterfails 4wdc - commandssubtests and bothsandisk - commandstests, and this branch passes both. Normal and JSON output matchesmasterbyte-for-byte on zeroed and non-zero logs.