[PATCH nvme-7.3 v3 0/4] nvme-fabrics: localize string option parsing

From: raoxu

Date: Mon Aug 31 2026 - 03:08:33 EST


From: Xu Rao <raoxu@xxxxxxxxxxxxx>

nvmf_parse_options() currently uses the same temporary pointer for option
tokenization and for strings returned by match_strdup(). It also contains
several copies of the same string replacement and DH-CHAP parsing logic.

This series keeps the changes deliberately small. It separates the option
tokenizer pointer from allocated strings, factors only parsing operations
that are actually shared, and otherwise leaves option-specific code in
place.

The series is split as follows:

1/4 separates the option tokenizer pointer from the temporary pointer
used for match_strdup() results.

2/4 adds nvmf_parse_string_option() for the five direct owned-string
replacements: transport, traddr, trsvcid, host_traddr and host_iface.

3/4 reuses that helper for the subsystem NQN replacement only. The
existing NQN length check and discovery-NQN update are left
unchanged, and hostnqn and hostid are not modified.

4/4 adds nvmf_parse_dhchap_secret() for dhchap_secret and
dhchap_ctrl_secret. It reuses nvmf_parse_string_option() for the
common replacement step and keeps only DHHC-1 validation and
sensitive rejection cleanup in the DH-CHAP helper.

This series is based on nvme-7.3 after the accepted
"nvme-fabrics: fix DHCHAP secret leak on parse failure" change.

Changes in v3:
- Rework 4/4 in response to Sagi's feedback. Reuse
nvmf_parse_string_option() for the common allocation and ownership
transfer in nvmf_parse_dhchap_secret().
- On DH-CHAP validation failure, free the installed value with
kfree_sensitive() and clear the pointer before returning an error so
normal option cleanup can run safely.
- Keep Sagi's Reviewed-by tags on 1/4, 2/4 and 3/4. Do not carry the
old 4/4 Reviewed-by because the helper implementation changed.

Changes in v2:
- Rework 3/4 in response to Sagi's feedback. Drop the dedicated
identity helpers and limit the patch to reusing
nvmf_parse_string_option() for the subsystem NQN replacement.
- Leave hostnqn, hostid, nqnlen and the discovery-NQN code unchanged.
- Keep p for the remaining option-specific match_strdup() users.
- Keep the reviewed DH-CHAP helper logic unchanged; p remains declared
because hostnqn and hostid still use it.
- Add Sagi's Reviewed-by tags to 2/4 and 4/4.

Xu Rao (4):
nvme-fabrics: separate option tokenizer pointer
nvme-fabrics: add helper for owned string options
nvme-fabrics: reuse string helper for subsystem NQN
nvme-fabrics: add helper for DH-CHAP secret options

drivers/nvme/host/fabrics.c | 118 ++++++++++++++++--------------------
1 file changed, 53 insertions(+), 65 deletions(-)

--
2.50.1