Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvme: avoid segfault in check-tls-key due to null subsysnqn/hostnqn #2169

Closed
wants to merge 1 commit into from

Conversation

martin-gpy
Copy link
Contributor

Running nvme check-tls-key hits a segfault as seen below:

nvme check-tls-key
-d NVMeTLSkey-1:01:bB7soUnpHfxVg53sCY21KY3nLbqLit2RcIO8Rbdf3mKhcKaM:

Segmentation fault (core dumped)

This is because the strlen check on subsysnqn & hostnqn crashes in libnvme's nvme_identity_len() at src/nvme/linux.c due to them being null. Both subsysnqn and hostnqn are mandatory for generating a PSK identity or inserting the retained key, which is what this command attempts to do. So to avoid this segfault, ensure both the subsysnqn and hostnqn are properly updated in check_tls_key() of nvme-cli's nvme.c before proceeding ahead.

Running nvme check-tls-key hits a segfault as seen below:

nvme check-tls-key
-d NVMeTLSkey-1:01:bB7soUnpHfxVg53sCY21KY3nLbqLit2RcIO8Rbdf3mKhcKaM:

Segmentation fault (core dumped)

This is because the strlen check on subsysnqn & hostnqn crashes in
libnvme's nvme_identity_len() at src/nvme/linux.c due to them being
null. Both subsysnqn and hostnqn are mandatory for generating a PSK
identity or inserting the retained key, which is what this command
attempts to do. So to avoid this segfault, ensure both the subsysnqn
and hostnqn are properly updated in check_tls_key() of nvme-cli's
nvme.c before proceeding ahead.

Signed-off-by: Martin George <[email protected]>
@hreinecke
Copy link
Collaborator

Shouldn't we rather fix libnvme to accept a NULL pointer here?

@martin-gpy
Copy link
Contributor Author

Shouldn't we rather fix libnvme to accept a NULL pointer here?

Ok. I've submitted linux-nvme/libnvme#767 for handling the same. Please take a look. Thanks.

@martin-gpy martin-gpy closed this Jan 11, 2024
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