Skip to content

types: Fix nvme_ns_id_desc packing.#1026

Merged
igaw merged 1 commit intolinux-nvme:masterfrom
thieule742:nmve-ns-id-desc
Jun 26, 2025
Merged

types: Fix nvme_ns_id_desc packing.#1026
igaw merged 1 commit intolinux-nvme:masterfrom
thieule742:nmve-ns-id-desc

Conversation

@thieule742
Copy link
Copy Markdown
Contributor

The namespace identifier length (nidl) field can be any length which could potentially lead to unaligned access.

Signed-off-by: Thieu Le [email protected]

@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Jun 13, 2025

Why should the length field value change the outer alignment of the data struct? Adding the packed attribute is breaking the ABI.

@thieule742
Copy link
Copy Markdown
Contributor Author

thieule742 commented Jun 16, 2025

The namespace identifiers are returned in one contiguous buffer. Even if the main buffer is aligned, when there is one odd length nvme_ns_id_desc within that buffer, it will throw off the alignment of the subsequent nvme_ns_id_desc structures. An example of this is the QEMU NVMe device which returns a CSI identifier that is of length 1.

@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Jun 26, 2025

Ah I see, this is actually describing the wire format and thus there is no alignment.

image

The namespace identifier length (nidl) field can be any length which
could potentially lead to unaligned access.

Signed-off-by: Thieu Le <[email protected]>
@igaw igaw force-pushed the nmve-ns-id-desc branch from 668f546 to b029018 Compare June 26, 2025 15:58
@igaw igaw merged commit e37a51a into linux-nvme:master Jun 26, 2025
11 of 12 checks passed
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Jun 26, 2025

Thanks!

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.

2 participants