From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 AE495303CA0 for ; Sun, 8 Feb 2026 23:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770592238; cv=none; b=fbnQ5Tm4R21ZrvjPRBKcnYCT13+RMIf4rhho59pL2Yv82MFrUX5UVSS6zi2wZdbdxrKH6uTSLIrJDPDroBhsdgdmf5cCUxhXRDxBaSvnLjMLrWEiN1jXfNwZ4Ss6Y+ZRFp7iz2UAJC0F/xQquqUzujWiJPB4cgyHiOnwN2hTbJU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770592238; c=relaxed/simple; bh=p90J2/NxZTMIIM6EU0us87j6gSQJIKHTIx0TKculZdI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LA/lHpvULrJ0W+ogfiazk43Ud8i/lROYIPIhCvZtioIZoJEHmJKqRAmm3UAPw+fbxNwD6OVcOuOEylel3L0SUyWclGdQnF0JWQbLBMt227KAXHl4mLYpngtTMl31cxNAMkexIa7kpnnlqdBeLMMlO79WW/nDfI7ZNzz/M97Oeqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=QdY2RpMG; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="QdY2RpMG" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-81ed3e6b8e3so1084580b3a.2 for ; Sun, 08 Feb 2026 15:10:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1770592237; x=1771197037; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=87FEGSXpVAnMUQR8bI4H8RD58BaU52BiJQ1S2S5ywak=; b=QdY2RpMGrUBXcw0XAVU7nO7zI6y6Rrr1c6zrc1Ki0DKT8uoPUHGNU2rM4KZh3oyQce Or3Cb9qdysYplQbazNmiTDV5fNuGP/hY/6J0mu6QsIKY6Ppag/aP3JPgcjl0/FjqmAYK vIl8OklG/8/NwRVW3+BiVlMkAD0HJGbn+GmuXvjIvzZC+0ApdKhDynzQR51+9/swAolf xH4w1E3aJdzq29XpCQodoFatBw+G6HSL9ln5pX7dXM3sdgfhA225yjCJiFKGbywljayl Nkae9ghaxngg/71Jsfs/P7tk3tAS7owdPtGiu6WYn/pbSAyKg/z3YPc4ZGARRqAH6cy7 EGQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770592237; x=1771197037; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=87FEGSXpVAnMUQR8bI4H8RD58BaU52BiJQ1S2S5ywak=; b=W014l4kauG3EQ5seG+6COblyOxIkGUSC8z18GTgaFUjAB/E6L/OuFkUqyZE0PKf19L +efQSs3y4xDv1YuCJdKk5OtR9V5+eb41PxRbLjte/xkYHoXV0QrcKlskCpWN7laSefRC Mxyq3/+o0NniraYxFExt3WIfFGoKbqqnt6aV4Mz6jeWZ7H3PcLS/Z0rBuwi2CMQSofS+ FmtiDZPJc3W3I+Em2nRldBddpYcx6Rkw7tt8Nqt1ra/kzgC/246tIEFwThJEOLNj6Bs8 rMANbwKs53BZ1Va5TbH8z4slkPZ+bxEyOh6yFK0p5O7qm1+cRObr7z3n7ORBjvvqdU28 VKhw== X-Forwarded-Encrypted: i=1; AJvYcCW53QZ9hYdprgak9cPx2tklBmmmQJuNM0HeuDHz2wmbfj18qEHI2A/PfMb8/O7UlhCWrjKELYZHigZbwyY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0hGnGzDQ17pIWJ+G0arubGmCHFjm2QGNwUt2emdvP7DYcORek LXyq4d8JkaGjnV9iFIAkV2BpqYNLBEZSu9c/jJQYmV0ydXMOAFPcTO35klFoN305mso= X-Gm-Gg: AZuq6aJCRURRc6YjE7/H/KeVhc4fU19a79tdz1r6AKrSnEfyHEB43gcUKnHXzu2sCBO t79Bf+wq8XPH50u5YNIHpWvcRnXMZ/Oej5FPdqPJnFrJQvMeeuK5cjQDHINiu6LRsZA5FAKPLuH CCTaUpNAfhiSsrS23ok3YAsAh+uUMROzdwhoDClskhV60eX+TiiljyTePM8eEdX9kYbmVZtUd2A iCChDftcvmmttAwnaIdWlwrpoDNTYjmJxVbhUgLFECzHTskf5dx/0yLofPpNVe8m1q7pDHvTMJW QC3VCmFtV7AdC4amo7Z1LYDvge2cz/QyiG5gFs7w+lYIe2ismBtURdqEVHPbERnVE5gevxGsGof QNJH0C+oCDOD73HRv736pI5iOI6n8c0uG7gBElAnnR2eSlFJ3H0RHSzjYnlCgXoaOyWE8FiSRAf 5KCyxVB8aC6Du48jU= X-Received: by 2002:aa7:9062:0:b0:81f:9b0a:812a with SMTP id d2e1a72fcca58-824416097f1mr8006691b3a.14.1770592236722; Sun, 08 Feb 2026 15:10:36 -0800 (PST) Received: from medusa.lab.kspace.sh ([2601:640:8202:6fb0::68dd]) by smtp.googlemail.com with UTF8SMTPSA id d2e1a72fcca58-824416746cesm8521379b3a.11.2026.02.08.15.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Feb 2026 15:10:36 -0800 (PST) Date: Sun, 8 Feb 2026 15:10:34 -0800 From: Mohamed Khalfella To: Sagi Grimberg Cc: Hannes Reinecke , Justin Tee , Naresh Gottumukkala , Paul Ely , Chaitanya Kulkarni , Christoph Hellwig , Jens Axboe , Keith Busch , Aaron Dailey , Randy Jennings , Dhaval Giani , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 03/14] nvmet: Implement CCR nvme command Message-ID: <20260208231034.GD2392949-mkhalfella@purestorage.com> References: <20260130223531.2478849-1-mkhalfella@purestorage.com> <20260130223531.2478849-4-mkhalfella@purestorage.com> <77a00fa1-5707-4859-8a7a-e823ca18c9fe@suse.de> <20260203184039.GB3729-mkhalfella@purestorage.com> <21be273b-b1b2-4813-8178-e01cb0aa6301@suse.de> <20260204004417.GK3729-mkhalfella@purestorage.com> <20260204175250.GL3729-mkhalfella@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat 2026-02-07 15:58:49 +0200, Sagi Grimberg wrote: > > > On 04/02/2026 19:52, Mohamed Khalfella wrote: > > On Wed 2026-02-04 01:55:18 +0100, Hannes Reinecke wrote: > >> On 2/4/26 01:44, Mohamed Khalfella wrote: > >>> On Wed 2026-02-04 01:38:44 +0100, Hannes Reinecke wrote: > >>>> On 2/3/26 19:40, Mohamed Khalfella wrote: > >>>>> On Tue 2026-02-03 04:19:50 +0100, Hannes Reinecke wrote: > >>>>>> On 1/30/26 23:34, Mohamed Khalfella wrote: > >>>>>>> @@ -1501,6 +1516,38 @@ struct nvmet_ctrl *nvmet_ctrl_find_get(const char *subsysnqn, > >>>>>>> return ctrl; > >>>>>>> } > >>>>>>> > >>>>>>> +struct nvmet_ctrl *nvmet_ctrl_find_get_ccr(struct nvmet_subsys *subsys, > >>>>>>> + const char *hostnqn, u8 ciu, > >>>>>>> + u16 cntlid, u64 cirn) > >>>>>>> +{ > >>>>>>> + struct nvmet_ctrl *ctrl; > >>>>>>> + bool found = false; > >>>>>>> + > >>>>>>> + mutex_lock(&subsys->lock); > >>>>>>> + list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) { > >>>>>>> + if (ctrl->cntlid != cntlid) > >>>>>>> + continue; > >>>>>>> + if (strncmp(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE)) > >>>>>>> + continue; > >>>>>>> + > >>>>>> Why do we compare the hostnqn here, too? To my understanding the host > >>>>>> NQN is tied to the controller, so the controller ID should be sufficient > >>>>>> here. > >>>>> We got cntlid from CCR nvme command and we do not trust the value sent by > >>>>> the host. We check hostnqn to confirm that host is actually connected to > >>>>> the impacted controller. A host should not be allowed to reset a > >>>>> controller connected to another host. > >>>>> > >>>> Errm. So we're starting to not trust values in NVMe commands? > >>>> That is a very slippery road. > >>>> Ultimately it would require us to validate the cntlid on each > >>>> admin command. Which we don't. > >>>> And really there is no difference between CCR and any other > >>>> admin command; you get even worse effects if you would assume > >>>> a misdirected 'FORMAT' command. > >>>> > >>>> Please don't. Security is _not_ a concern here. > >>> I do not think the check hurts. If you say it is wrong I will delete it. > >>> > >> It's not 'wrong', It's inconsistent. The argument that the contents of > >> an admin command may be wrong applies to _every_ admin command. > >> Yet we never check on any of those commands. > >> So I fail to see why this command requires special treatment. > > Okay, I will delete this check. > > It is a very different command than other commands that nvmet serves. Format > is different because it is an attached namespace, hence the host should > be able > to format it. If it would have been possible to access a namespace that > is not mapped > to a controller, then this check would have been warranted I think. > > There have been some issues lately opened on nvme-tcp that expose > attacks that can > crash the kernel with some hand-crafted commands, I'd say that this is a > potential attack vector. For an attacker to exploit CCR command they will have to guess both CUI (8bit) and CIRN(64bit) random values correctly. I do not see how an attacker can find these values without being connected to the impacted controller.