From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796431739; b=vYEdSSHH+bAT3s5nyM0xL4dG09p+AhRlgPaiHXGw8UpqI3xu3UI5LQ/+j7fqEZskHroP ZGpVv70oHE6Kfy8PT9gLSVTD/MJDrtDoGbksrs6id1w5213G1B8xdIlrLjsP/o10HJdvh 6JWEZ2Jhiz+wfRDV8kgOYqFkHZa34BLmabAMLs3U+f6o8Yk7OYgXTweHu4BvNqKkHp7Yv 9/68VrM67V9nTbwN4y28zzs7a1etQ4GooDxoffXsULkOk8Wc5pmDGk6l5c2UH0zocNyV6 tVooHig9Nl/dHIpsnBQb7ZxMxKqxROB9bOFUpzDHyW4dw6Lc7ZDx+Z7oXcRV+zncSNw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796431739; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=3/DZX66SAc+qXdhGeSFipSoaaI1WHMNzzTQtErHjJlo=; b=lPDDzJXb472Il5HGYZbYbrd5WhRBBqDrMl0FzEUPn4y4dbkWa63gkdGVCpow18YaQnXO 7blAzNDQ7PtiFIgw2CVwqe7ikoRC09bVHpk8X+CWzrtbr+eqFQjOSvRoTNsKAiKQAJzAi Aiwjos9fvWEIoaO5SUsDKUVM/p703CF7RBynBVZ6UrhPS+GnZw+LPjlRm6HQ5DQbH8JU/ HFnRE4gdlcwRxZGcRyF/OAQUe++ePKzvmPJjyEWvBHkl5N3bGe+89GV5QdV96k2/oazSs GkEaajsbKbLRGPh2g7wiWtXuEIPkMzrYDkJl3Ro9OO36mbAw4nA+h0fEXBlZAUM4uIQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=OJgcHNLV; arc=none smtp.remote-ip=209.85.210.170 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 703AF606A32F for ; Sat, 5 Dec 2026 00:48:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 703AF606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=OJgcHNLV Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8b67f25e6e1so820980b3a.0 for ; Fri, 04 Dec 2026 16:48:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796431738; x=1797036538; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=3/DZX66SAc+qXdhGeSFipSoaaI1WHMNzzTQtErHjJlo=; b=OJgcHNLVU6WpVTUbBjISwqmLvepijdNyR+5RYRBWrOi8uoY+cufA2dS3Hs5LOmYTTG lFErpuTeysssOg+IFNgLPn+qfTzadlXmukIt/ciSjqC1SUJbTnfyCFbaINt/b0atY0zE +0ZMepil1pyMTIBPGwM9blKzsctX7LjaB7QwknILWTShz3zXLxQgu0rBpeMt64u3koPu dmBN4iBldgiInxNH3w+SfEjmozoCUruw8F2Y2c32EOCUKR8UM2/1Dk86wOZYU+9e77UM kjQhitnUJhrkSagzljXUX34J870UeCvcVtkZi4yJpsSjwVKzFkUNVSmzKGMKdh31075I WJiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796431738; x=1797036538; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3/DZX66SAc+qXdhGeSFipSoaaI1WHMNzzTQtErHjJlo=; b=U9UEt1NBLS2wI/qeQQ2tFy+7f1qtq+H1SMHawRLFXN7WGYYHmYiV3edipOdrYqDzNg 9sssv/3pbVBp9o+sGP5rcp3C73HI2DV2b5g9pBZUc5S01FsCLw/i4RU39ipq1kmIGwhX 4pCtWlGNYuc96Rbarf3HuNO0QsPQDfre3pzz7WRxqPiCGjaenukXr/DVLRRjAFjMXP7u 5gUBDZirWLfXcUSfQJfYhfxoNEQhmHELgxBEba2tbctW61O63iNfG2Re6apoMX3s4l2c XjRVk2lGN8wNQb6KKlkQrzo0GOxVpERLs69CZXro9Llnp1ESAtHiup+Dg+WbTvl3QhlV qAaA== X-Forwarded-Encrypted: i=1; AL+hErFl8xINsEMIhv3O1lHmANT/XhcfuVyUm5NnNEahOqR8UvEVA/zzGsSwLoW0fdAGzd8KoPoUbTByjgQ/gis=@vger.kernel.org X-Gm-Message-State: AB4q+uEEjBshur9XCqbWLA/obJhLG9BzpxOZjV2SumdZLLIKjEUTj7a7 1KxejQtKHVH0fQtJmbXRPHijrK65dMqCybl8+PmvAZRzBxaf2XpEzxBq X-Gm-Gg: AZFdTZcgBMuoJUnOa1FzAAQfFqsV3aS+BuVhL/+4DHbIwvxlq2lmdEt+vP7Xj2T/Hgt BjNlNGcZAyIO/sVbkn6bLBA+KdzEwvX4falfKQJb8Ule+n4U+AbecpeohEzV7KKcZFVhYsOtUV0 b3xhoaCsL8R19Ec0fkVHInbHA+676B/qcoOg3K4xyiO7UK45wpJbLAfIWkEG8VG/y/VYCz1hCNS +a7vNt7MUjC/2NcwaUL9sBYyymDtEVj7CPbPIzpkHgjCuN1rVXbQGLbt7y7UTP4t5f2R0ay2h7D 2J671lObs0gXaR3nz269BalhbiDKYcQOS32EoNocZeTeRKQvUESWNkrbatlq2EsDJ56ZQK18M9u tqGiM5BlrG9B0fbxnHLTKhFDDWISZNDvJlVYAY1NL/2aFmDZANLtEP3ZwcroFtnFiX3qSE/zREi 9kXpi6bZEyX2fF3OMlCKuwbO2FomOYcBXU/SHzkhF999+6RQDO3TFNSbRVZB2DCR74R2sszfkwe bzAl6p1v2MMMChEhK6dTwhI+4JfOSLhAp41dsNvEOJ7e3J2VQIaUlTKIFfCXtvbJtrD5PNmmQVC yRk1P91I0FjQGnWZ/KVRvJF0PS9ANTYhW/9D/XOqZ0Hm0MbMbSlVZeURPJRI5SdedEUb3zDPvTN Up1nyjlfcR8SdLKg7grnxMJXlQNl6lMIZlrYAd5nCYk0VJ1gsNujn+lWbthJzqM4= X-Received: by 2002:a17:90b:5483:b0:3a7:f4d:b23d with SMTP id 98e67ed59e1d1-3b5e06a62d5mr3179848a91.52.1796431738436; Fri, 04 Dec 2026 16:48:58 -0800 (PST) Received: from localhost.localdomain ([42.118.185.60]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c7d9c004sm11773643a91.17.2026.12.04.16.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 16:48:58 -0800 (PST) From: Lee Seong Hyeon To: linux-nvme@lists.infradead.org Cc: hare@kernel.org, hch@lst.de, sagi@grimberg.me, kch@nvidia.com, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 0/2] nvmet-auth: fix use-after-free and out-of-bounds read across queues Date: Sat, 5 Dec 2026 07:48:14 +0700 Message-ID: <20261205004816.2017-1-ihopenre@gmail.com> X-Mailer: git-send-email 2.55.0.windows.3 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Resending to linux-nvme as Christoph and Hannes asked. The first posting went to the maintainers and security@kernel.org only. The only change is the Reviewed-by from Hannes on both patches, and the rebase onto 007722b8211f, where they apply without changes. The DH-HMAC-CHAP keys and the negotiated hash live in struct nvmet_ctrl and are shared by all queues, but each queue processes AUTH_Send and AUTH_Receive on its own and sq->auth_lock is per queue. 1. AUTH_Negotiate on one queue frees ctrl->host_key in nvmet_setup_auth() while a Reply on another queue uses it (KASAN use-after-free read). 2. AUTH_Negotiate on any queue can change ctrl->shash_id. A queue that got its challenge for SHA-256 and replies with hl=64 after another queue negotiated SHA-512 makes nvmet_auth_host_hash() read 64 bytes from the 32 byte sq->dhchap_c1 (KASAN slab-out-of-bounds read). Conditions: CONFIG_NVME_TARGET_AUTH and a subsystem exported to a host that has a dhchap_key set. A Connect for an I/O queue is accepted while the admin queue is unauthenticated, and both queues accept authentication commands. (1) is a race between two connections, (2) is deterministic. Tested in QEMU with KASAN over nvmet-tcp, on 20eef29b7c84 and again on 007722b8211f. Unpatched: both reports. Both patches: neither shows in a 20 second race run. With both patches the in-kernel nvme-tcp host still connects with dhchap_secret (SHA-256, NULL DH group), with and without dhchap_ctrl_secret, and reads and writes the namespace; a wrong secret is still rejected. W=1 and checkpatch --strict are clean. Not tested: lockdep (patch 1 adds a mutex nested inside sq->auth_lock; the lock order was checked by reading only), DH groups other than NULL, TLS, RDMA, FC and loop transports. Both patches were found and drafted with the help of an AI coding assistant; this is stated in each commit message. Lee Seong Hyeon (2): nvmet-auth: serialize the controller authentication state nvmet-auth: fail the transaction when the hash was changed drivers/nvme/target/auth.c | 2 ++ drivers/nvme/target/core.c | 3 +++ drivers/nvme/target/fabrics-cmd-auth.c | 31 ++++++++++++++++++++++++++ drivers/nvme/target/nvmet.h | 3 +++ 4 files changed, 39 insertions(+) base-commit: 007722b8211f7b34fdf21b1e6a9c32497633ea29 -- 2.53.0