Repository navigation
Do not let a scanned dhchap secret override a configured key - #1150
Merged
Merged
Conversation
nvme_scan_ctrl() copies the dhchap_secret of every live controller that has one into its host object. So when a host has a controller connected to subsystem B, 'nvme connect --config' for subsystem A sends the secret of B instead of the key configured for A, and authentication fails. A key set on the port loses too, because build_options() prefers the host key. Remember whether the host key was read from sysfs. A scanned secret no longer replaces a key set by the caller, and a usable host key of the controller itself, like the 'dhchap_key' of its port, now wins over a scanned one. Add a test that fakes sysfs and /dev/nvme-fabrics. Fixes: b547cdb ("Implement 'dhchap_key' host and controller attributes") Fixes: 6614a55 ("Parse dhchap_host_key on controller level") Signed-off-by: Joaquin Varela <joaquinvarela@neatech.ar>
After a scan the host key can be the secret of a live controller. json_update_config() writes it as the host 'dhchap_key', so 'nvme config --scan --update' saves the key of one subsystem as the key of the whole host. Only write a host key that was set by the caller. Extend the dhchap-key test for this. Fixes: b547cdb ("Implement 'dhchap_key' host and controller attributes") Signed-off-by: Joaquin Varela <joaquinvarela@neatech.ar>
Collaborator
|
Do we need something similar in nvme-cli/libnvme 3.x? We did some major surgery in this area but I lost overview what we have done there. @martin-belanger |
Contributor
Yes, 3.x has the same problem. The scan copies each live controller's dhchap_secret into the host, and build_options() prefers the host key. So a connect without a configured key sends the secret of another subsystem. Let me look closer into it. I'll submit a PR. |
Collaborator
|
Thanks! |
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.
When a host already has a controller connected to subsystem B,
nvme connect --configfor subsystem A sends the secret of B instead of the key configured for A, and the connect fails with an authentication error. The topology scan copies the live secret into the host object and it then wins over the configured key, at host or port level.The first patch keeps a key set by the caller and prefers a usable port key over a scanned secret. A host key set by the caller still wins over a port key, as before, and with no key configured at all it still falls back to the scanned secret. The second patch stops
nvme config --scan --updatefrom saving a scanned secret as the host key.Tested with nvmet over TCP and nvme-cli 2.x, which already skips connected controllers in
connect --config(linux-nvme/nvme-cli#4150).