From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D21E2D3A7C for ; Fri, 10 Jul 2026 02:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783650625; cv=none; b=KRgv5iF8z47FClVOYCwE44V0cDL7WcZYx6IzINY652M9wC5och+Knr7gdUzqkgM0V3YPXjpb5ZLMfOSK4E56dxGSGn0ACzljIY11fihkdJznltTN4cVCpXBnTI2EtLrMPgKQRS2RTsZlz3rTzvbndPde5kNQeQsAQyUoV/IYl9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783650625; c=relaxed/simple; bh=hoIkw9VtvA47vMVJbFDjkPA5pbPO8TsazoHJPLOge6I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JhIX0TzVtmIKQO2EB5B1LckIa/4oYxt/5bCupfsLBstBLRKYYJgmjF9rmD6C9RjPdnD2NpcA60Tbw1tAFUBXD3gHUO+7+v1PLPnyZICbCM6R1/UpLj1kV+VIF+O+2N26J8Gxrw9waAATCPvlsX4+6s3bSWANmWSG4d3jjucoRhE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=qDj/UtxE; arc=none smtp.client-ip=209.85.222.171 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) header.d=gmail.com header.i=@gmail.com header.b="qDj/UtxE" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-92ed3993c1eso23176685a.1 for ; Thu, 09 Jul 2026 19:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783650622; x=1784255422; 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=2A6lyd2jd7ZCM97ZM7yJgAgaHnmHNrVF3oV741yC5EI=; b=qDj/UtxEZlo3rDzPsjlyC6G5BIzW9s2vA/6yJOR+f/I3O/3JT3Phv09ZP0fvNb8ASS nqGtZKEtm+YUFC826PsKLUaduWBIicNTNQZYNypEYKDRTXA/ca2oQlxjcFI52zBJwbF3 JF4yrHf+znJz85qf9ImctThbKIcqMfXbYh9g1TTDTnK9h760Dj+5kGEwWUg3CbRtn4ZU uGRCmeGmT7PeFzqw04ir/wO8+ryUl9rW95y8y+1jjnx3psom8I+IZOJgi9K0IME/3nE1 ongBLwwL80AbxCaEvUvaJ9uo7bDsX+XShNRzk2facTPmWT7Pub7J1APesYVk4/WidU+n InfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783650622; x=1784255422; 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=2A6lyd2jd7ZCM97ZM7yJgAgaHnmHNrVF3oV741yC5EI=; b=Os8ljRg+zTat9AMnK/jIirQWGap6UMkXgICK+Jw5exyc4Te6zZl5LeG0jSMvnN+Ilk h+eyX3aBfoWwWx9Mb+pKE2qb6B1PKqK7cndy2CvxuqPMWN76faiSfOWUfhT2J6KjvW8Z fx6p2m2LWqf1ItqU+dgVn3huluVoMCSwcx4rFCO8fPN3lanOLgRms5g6eeagq/jJKEui v8Fsv7XHnUSiKJUGgj/lLBaI7tI2//9ClVh+20Bft/OvIDntQOX3K6J+rwzksSJoJb7Y CtRecFY/RgKq3jPjfDQCJR3Brlk8tvo8u+ZgkZFd92jhiOAz7mAKTE1at4pkvio5uknP 8z6w== X-Forwarded-Encrypted: i=1; AHgh+RrT+tAbaYYHpjEm8OqopMe1uqem+23TLkJA1egN9MrERf/7f5TU215A5Wux15YXOab3+TgKR9TW0InW1J0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywztd4iV/7luOQhKau4BJ7SeHZhEn4J5L4b4NG1jGoQzk9UsplP b16GipVVQFdMGzOrTtUwp3LFqCPdJ6DE1xDRxSysX0iSV/IKtRjdpGmy2adx8GH/GXE= X-Gm-Gg: AfdE7cmeIB+FwTmbNRUbm7uyUNbuQXMxPmLG7lvN2J6l0BcYBT0UGw3kyvTPC6y19iN ptqldTdKHKTeA4Q3MNmKzMnDrfM4cqyKYxNEyvDOrXKQmb+JfYx6454d6EcsfwSr+wwBQBlUO+L bumncOT9FKryiYAHaFDkDNjRb3oMUSXJZIA5xITe0WdTwc8UPWeLOSA9mlvLBF2VzV/VHc7DbdV 9HP96vNDPaNIoXp3wI1Ftw3nyReh+oMkUWIU6vI0G8miCmvs45GZpLbIslYu1umvBWj6rf8UWnJ tN1arbaVeLJPRC0Gh6j8kH+B7V70VGMw4TpLzHuUnDAy01oE8TISOgXTNT1EOasQIoUC3JP2wfu 7DKYE+kt7MWr6306hnmeo5HDRSaNdOJvwOBCupkuVQa6wDEnSDcslgjtYf9g3J+NAiz6HUHwVZB A9jeV648Mr5NibhNtdtNrWhILxfUMkX1BXa8HrbrzBxa4qDxbE7IKRHz3Vm9K/6YIA0zrjxDwxs gz382lQ2RR31lkpTUYFkCvi/KvxYYq6 X-Received: by 2002:a05:620a:270d:b0:92e:717f:e0b0 with SMTP id af79cd13be357-92ecf5b4811mr1052722885a.12.1783650622549; Thu, 09 Jul 2026 19:30:22 -0700 (PDT) Received: from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92ee5cf9d9bsm88854685a.28.2026.07.09.19.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 19:30:21 -0700 (PDT) From: Michael Bommarito To: Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: kwilczynski@kernel.org, Damien Le Moal , Manivannan Sadhasivam , Keith Busch , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 0/2] nvmet-pci: validate endpoint queue IDs Date: Thu, 9 Jul 2026 22:30:13 -0400 Message-ID: <20260710023015.3744082-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit A PCI root-complex host can crash an NVMe PCI endpoint target with malformed queue IDs. The endpoint transport allocates its SQ/CQ arrays using ctrl->nr_queues, which is capped by endpoint interrupt capacity, but the common target admin validation only checks queue IDs against subsys->max_qid. A host can therefore submit Create/Delete SQ/CQ commands with qids that pass the common checks yet index past the smaller endpoint transport arrays. Patch 1 rejects queue IDs outside ctrl->nr_queues before the endpoint SQ/CQ arrays are indexed. Patch 2 adds same-translation-unit KUnit/KASAN coverage: a valid queue ID that must still be accepted and the out-of-range Create/Delete SQ/CQ cases that must now be rejected. Reproduced with the KUnit/KASAN test: the stock Create CQ path faults in nvmet_pci_epf_create_cq() after nvmet_check_io_cqid() accepts qid 2 with max_qid 8 and nr_queues 2; patched rejects the malformed cases while the benign control still passes. Cc: stable@vger.kernel.org Michael Bommarito (2): nvmet-pci: validate queue IDs against endpoint queues nvmet-pci: add KUnit coverage for endpoint queue IDs drivers/nvme/target/Kconfig | 11 +++ drivers/nvme/target/pci-epf.c | 151 ++++++++++++++++++++++++++++++++-- 2 files changed, 157 insertions(+), 5 deletions(-) -- 2.53.0