nvme: Fix get-feature on big-endian systems#2888
Merged
igaw merged 1 commit intolinux-nvme:masterfrom Aug 1, 2025
Merged
Conversation
The `parse_and_open()` function uses `OPT_BYTE` to parse the feature_id and sel options. This means it writes a single byte to the memory locations for `feature_id` and `sel` in the `feat_cfg` struct. However, these fields were declared as `enum`, which typically has the size of an `int`. On big-endian architectures, writing a single byte to the address of an `int` modifies the most significant byte, resulting in an incorrect value being read. This caused the `get-feature` command to fail. The command only worked on little-endian systems. Fix the issue by changing the type for `feature_id` and `sel` to `__u8`. This ensures the fields are treated as single bytes, guaranteeing correct behavior on all architectures. Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Contributor
Author
|
This bug made nvme/055 blktest fail on big endian archs like s390x |
Collaborator
|
Thanks a lot! |
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
parse_and_open()function usesOPT_BYTEto parse the feature_id and sel options. This means it writes a single byte to the memory locations forfeature_idandselin thefeat_cfgstruct.However, these fields were declared as
enum, which typically has the size of anint. On big-endian architectures, writing a single byte to the address of anintmodifies the most significant byte, resulting in an incorrect value being read. This caused theget-featurecommand to fail. The command only worked on little-endian systems.Fix the issue by changing the type for
feature_idandselto__u8. This ensures the fields are treated as single bytes, guaranteeing correct behavior on all architectures.