From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 B3BCA4218B6 for ; Mon, 9 Feb 2026 19:27:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770665232; cv=none; b=sea+nm/Dd6AnAmM1GayHUF1bmMCU0vy1W5IaPCbszQFlq2qtGo/X7/nWSFtd5+CGxyU4zT4lya5pkAFurlDlNOX5oJPDzEdboiXgCS40NljASfxara4qtlaFB7VAyTv6rx4uR/RbV79c7ButXcyOJsaTr34AtHZ1UZ84oz0+IIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770665232; c=relaxed/simple; bh=B1mg4nsUnzmTbjyBZzhOidL/IRhZC93LXGG7F4NvOGA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pTwB+ArQ9cpXbkxZDWNWCJt+PmXTnlfOEVTsmCIB4s6z1n5HBjTdyZc1kwrCmJh7WPOWe7oL2UkkFITkBQ1IGL1eVVaLZenfgV6ojSSpNhsDUMloUN0254zm/9tteeGGRARehc+o7dCNkRhe1q4SXVWckLO21M0m6X+/JSUjy8Q= 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=ShV+cN4s; arc=none smtp.client-ip=209.85.128.45 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="ShV+cN4s" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4801bc32725so25988635e9.0 for ; Mon, 09 Feb 2026 11:27:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1770665230; x=1771270030; 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=uCKwtEDIGSn0kPdwgs9hDBGk0+B7QKz+ryxhKiPMenA=; b=ShV+cN4s3zto3LiLVNnDhOTA3kRgPnxtbZ8YAnivu6zx/a+Z8TyVh40iK1iGxowkSc 4hh1fPtqgREDJ4TcXwN1HisJrYwZQgM9+S3Tu/v2yXjVtFS10PGy1tGj1oDwAWBjHsMm +M4GZ6yHG5lD7V4tNEj7n5St9JlfujybzYwRM673J9wnOMnLXJXU3Qd3aIG5wzWWafxC 4fTSy9+i7USJp5bG99wxk6ckropMg4rA8ekzXrhijG58Fxr+kMkO686WcWtTbGNgZ4Dg 0V4UQ55622O9lqlBfMir4c08mnNawOMhd7rXZAXSne+cKv18IRki/N3DF7o3wdyTe1XG r/+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770665230; x=1771270030; 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=uCKwtEDIGSn0kPdwgs9hDBGk0+B7QKz+ryxhKiPMenA=; b=v9/IawvxTc5u9tFJXufTnpO0DZw+LDyvn70IS80F2TxOS4Q8GCtNsYNhhuvGg0sbfI zybmhwmrUvWx+3miFJknBjJf+XYYSSvCnueuO/JbbzfsPoRVBMFtHWlz9/ZcDUL3Laie yh6R1EH/mdnSp/8/hbf0S4RY3a/QOXL5k4ymyRbFF9w0R4TwVbeO/TLEjiVX9uJgFnXt rBnRlQ0QszYoweuCqArJ2tgAHlegE9iim/Foef9pGULNFVfOh3/7GwzZ36QXWdvdvWSE Qz2ogx0dDGzG/YwOQdDhoH+ytvRpVOGygaLajrLRtar58Rx5GH9zSKPBz+cDYHBQrpAY D1bg== X-Forwarded-Encrypted: i=1; AJvYcCVr1LqtgQYWCpAsiaWYzWdXtq7cJeKs8G1uHb2JOhu8Iw228nvoAwCi0uis3OjZ8eV29qOmNupJ1O5xOq8=@vger.kernel.org X-Gm-Message-State: AOJu0YzBH7gTjCFoIlEkC/r+h0NUBrEknwv8EuMhea3JTNWv2s+1T1Qs Kn687Vjemj5H4/Nj32Cuu1bS7sS+qtMdiurLzMfzBvNZT1ghW8k7JUcWtFGmc5gzo/w= X-Gm-Gg: AZuq6aKqwaXOXNRfkWxSVXLXGtHD7IfzsTlfwcl2or5BzpxT09Gjm2HTjfnn8ZZ+mXB dLl2nTPYG3BEW8Rfis7HxsK0qm0NUhoC0HGEtuKyKr1OOIq4ZAkDlUhi+JNPEuxoR8d5eOXzx7L je3ahikkuizQe1netYxAEjXIkV4LlOBIl30ghEVmSaFxNboyL5Pa1IlQsiS7Vsr4YsUOL2uMva0 pfJjaHf4WxHmUH7WToOwC6akpdg1Uh1NaX3sPG3Dkbbt9G5Y+be9T9mqwStdAOYEn9eFj1ME/ub IspAI0cMgN4A8D5D9FLvMcnC+QvbSxUgrqeOZ992UyLqae7B5W2Nw48Tk5UTE4TW/kPdvup4GhU 3HeqGvjI/agExCV1R+ANSjzkb6OdOh8bcgHNthELudYd/vXEJna/QjI5UpQb4LMAtDPQ2iQiw+E UGVhDOjIjDp/Rj4eSiVnkBAk+Xg99feBU= X-Received: by 2002:a05:600c:4584:b0:477:55ce:f3c2 with SMTP id 5b1f17b1804b1-483201e26acmr178083255e9.14.1770665229753; Mon, 09 Feb 2026 11:27:09 -0800 (PST) Received: from medusa.lab.kspace.sh ([208.88.152.253]) by smtp.googlemail.com with UTF8SMTPSA id 5b1f17b1804b1-4834d5ebd34sm9173895e9.7.2026.02.09.11.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Feb 2026 11:27:09 -0800 (PST) Date: Mon, 9 Feb 2026 11:27:06 -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: <20260209192706.GN3729-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> <20260208231034.GD2392949-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: <20260208231034.GD2392949-mkhalfella@purestorage.com> On Sun 2026-02-08 15:10:36 -0800, Mohamed Khalfella wrote: > 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. I changed ciu and cirn sysfs controller attributes on the host from S_IRUGO to S_IRUSR. This should mitigate an attack by unprivileged process running on host. On the target side debugfs files already have S_IRUSR so no change is needed.