Skip to content

libnvme: fix crash on a malformed exclusion entry - #3926

Merged
igaw merged 2 commits into
linux-nvme:masterfrom
martin-belanger:exclusion-malformed-entry
Aug 27, 2026
Merged

libnvme: fix crash on a malformed exclusion entry#3926
igaw merged 2 commits into
linux-nvme:masterfrom
martin-belanger:exclusion-malformed-entry

Conversation

@martin-belanger

Copy link
Copy Markdown

Any exclusion entry with an unknown key, a token without =, or an empty value crashes every caller of libnvmf_exclusion_match(): nvme connect-all, nvme-discoverd, and anything else that consults the list.

printf '[exclusions]\nexclusion = bogus=x\n' > /etc/nvme/exclusions.conf
nvme connect-all ...     # SIGSEGV

entry_matches() parsed each entry with a NULL context to keep the match path quiet, but tid_parse() logs those three cases and libnvme_msg() dereferences the context.

The fix threads the caller's real context down instead, and reports a bad entry at DEBUG. Matching runs on every connect attempt, so one static typo must not produce a log line per connect. libnvmf_tid_parse() and libnvmf_tid_parse_strict() now return -EINVAL for a NULL context rather than documenting it as "parse silently", which was never true.

The second commit makes the typo visible where an admin would look for it. nvme exclusion list showed only drop-in names, so the entries of the main hand-edited /etc/nvme/exclusions.conf could not be listed at all. It now prints every list with its entries and marks the ones that can never match:

$ nvme exclusion list
(default)
  nqn=nqn.2014-08.org.nvmexpress:uuid:abc
  bogus=x  # invalid: never matches

user
  transport=tcp;traddr=10.0.0.1

--verbose logs the reason for each one.

Regression tests cover the four malformed forms plus a hostname in traddr, which was silently rejected with no diagnostic before.

Martin Belanger added 2 commits August 26, 2026 18:02
entry_matches() parsed entries with a NULL context to keep the match
path silent, but tid_parse() logs a malformed token and libnvme_msg()
dereferences the context. One typo in exclusions.conf crashed every
caller of libnvmf_exclusion_match(), including nvme connect-all and
nvme-discoverd.

Pass the real context down and report at DEBUG. Matching runs on every
connect attempt, so a static typo must not produce a log line per
connect. A NULL context is now rejected at the parser entry point.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
"nvme exclusion list" showed only drop-in names, so the entries of the
main hand-edited /etc/nvme/exclusions.conf could not be listed at all.
That is the file where a typo is most likely. Print every list with its
entries and mark the ones that can never match.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
@igaw
igaw merged commit 099a0bf into linux-nvme:master Aug 27, 2026
30 of 31 checks passed
@igaw

igaw commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

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