libnvme: guard against NULL transport handle in discovery path#3240
Open
martin-belanger wants to merge 1 commit intolinux-nvme:masterfrom
Open
libnvme: guard against NULL transport handle in discovery path#3240martin-belanger wants to merge 1 commit intolinux-nvme:masterfrom
martin-belanger wants to merge 1 commit intolinux-nvme:masterfrom
Conversation
Collaborator
|
Looks good. Just one question, do we want to log this? |
Author
Good idea. I'll add a log message. |
Author
|
Done. The log message follows the same "%s: \n" pattern used throughout the function, with LOG_DEBUG since this is an expected transient condition (device removed mid-operation), not an error worth surfacing at higher severity. |
While stress testing with nvme-stas using repeated nvmet create/delete cycles, a segmentation fault was observed during teardown when running nvme connect-all. The crash occurs in nvme_get_log() due to a NULL hdl: nvme_get_log(hdl=0x0, ...) Root cause is that the return value of nvme_ctrl_get_transport_handle() is not validated before use. Under certain conditions, a race can occur where the udev-triggered nvmf-connect@.service attempts to operate on a controller (e.g. nvme1) that has already been removed. Fix this by checking that the transport handle is non-NULL before issuing commands that depend on it. This prevents a potential SIGSEGV during discovery in transient device removal scenarios. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Collaborator
|
rebase due to merge conflict from the libnvme prefix change. |
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.
While stress testing with
nvme-stasusing repeatednvmetcreate/delete cycles, a segmentation fault was observed during teardown when runningnvme connect-all.The crash occurs in
nvme_get_log()due to aNULLhandle:Root cause is that the return value of
nvme_ctrl_get_transport_handle()is not validated before use. Under certain conditions, a race can occur where the udev-triggerednvmf-connect@.serviceattempts to operate on a controller (e.g.nvme1) that has already been removed.Fix this by checking that the transport handle is non-
NULLbefore issuing commands that depend on it.This prevents a potential SIGSEGV during discovery in transient device removal scenarios.