libnvme/test: fix use after free in test_nvmf_sanitize_addrs() - #3759
Open
LJaved-IBM wants to merge 1 commit into
Open
libnvme/test: fix use after free in test_nvmf_sanitize_addrs()#3759LJaved-IBM wants to merge 1 commit into
LJaved-IBM wants to merge 1 commit into
Conversation
igaw
reviewed
Aug 7, 2026
| p = ret == -ENVME_CONNECT_TRADDR; | ||
| CHECK(p, "hostname host_traddr rejected at connect: %d", ret); | ||
| pass &= p; | ||
| if (c) { |
Collaborator
There was a problem hiding this comment.
I would just fail the complete test when libnvme_create_ctrl fails. No point to continue after this point, e.g.
libnvme_create_ctrl(ctx, ¶ms, &c);
shr_assert(c);
p = !strcmp(libnvme_ctrl_get_host_traddr(c), "storage.example.com");Tests are allowed to completely fail on the first error.
If libnvme_create_ctrl() fails and returns NULL, the subsequent calls to nvmf_sanitize_addrs() and libnvme_free_ctrl() are made with a NULL pointer, resulting in a use after free. Fail the test immediately when controller creation fails by checking the returned pointer with CHECK() and returning false, so the cause of any setup failure is immediately visible without proceeding with invalid state. Coverity CID: 561730 (Use after free) Signed-off-by: Laraib Javed <laraib.javed@ibm.com>
LJaved-IBM
force-pushed
the
fix-use-after-free-test-fabrics
branch
from
August 7, 2026 15:53
5458216 to
06310e0
Compare
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.
If libnvme_create_ctrl() fails, @c is NULL. The subsequent calls to nvmf_sanitize_addrs() and libnvme_free_ctrl() are then made with a NULL pointer, resulting in a use after free.
Guard each nvmf_sanitize_addrs() and libnvme_free_ctrl() block with if (c) to skip the sanitize and free steps when controller creation failed.