[PATCH 4/4] nvmet-auth: select the configured DH group from the host's list
Hannes Reinecke
hare at suse.de
Wed Dec 2 23:56:57 PST 2026
On 12/2/26 4:47 AM, Guixin Liu wrote:
> The DH group negotiation loop adopts the first offered group that
> differs from the configured one and never assigns it, so the
> configured group is kept even when the host did not offer it, against
> the negotiation rule that the controller select from the host's list.
> The fallback path is only reached for entries equal to the configured
> group, which defeats its purpose.
>
> Mirror the hash negotiation loop: record the first usable offered
> group as the fallback, then adopt the configured group when the host
> offers it. When falling back, regenerate the DH context with
> nvmet_setup_dhgroup(), as the key pair was set up for the configured
> group at controller initialization. Treat the NULL DH group as usable
> like the configfs dhgroup store does, and guard against unknown group
> ids.
>
> Fixes: 7a277c37d3522 ("nvmet-auth: Diffie-Hellman key exchange support")
> Cc: stable at vger.kernel.org
> Signed-off-by: Guixin Liu <kanie at linux.alibaba.com>
> ---
>
> Reproduced in a QEMU/KVM guest with nvmet-tcp and DH-HMAC-CHAP
> authentication. The target host is configured for ffdhe2048; a
> TEST-ONLY injection in the test host (not part of this patch) makes it
> offer only ffdhe3072.
>
> Unpatched: the target keeps ffdhe2048, a group the host did not offer
> (observed via the selected-DH-group print). Patched: the target falls
> back to the offered ffdhe3072, regenerates the DH context, and
> authentication succeeds. An intermediate version that changed the
> group without regenerating the DH key pair failed authentication
> (host response mismatch); regenerating with nvmet_setup_dhgroup()
> fixes that.
>
> Regression without the injection (host offers the full group list):
> authentication with the configured group succeeds.
> drivers/nvme/target/fabrics-cmd-auth.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
Would be cool to have a testcase for that.
Otherwise:
Reviewed-by: Hannes Reinecke <hare at kernel.org>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
More information about the Linux-nvme
mailing list