From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59550282F34 for ; Fri, 22 May 2026 15:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779464764; cv=none; b=i254aM4iFBGht2ZLEZekrfjaV66G1svgmjXrVuX+1Ocdv28F0AyI963nBL7atNnZhzh/jkFKXLOEppTQOzLWePy58Wth2oLuNVXAnX+2l3LJBfcb4vHa/rXJfJSWMz9INPRkC9Avk9bOljynlYo97LPnc486+c0zMzhXskE9OVI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779464764; c=relaxed/simple; bh=ZaxsNjMIWbtUf60yxKKmLjCElBuznNR1TnN85uUDnAg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z5qN1u1JPHoiUH482dDyDK8hWjwO1tluMPhERD8MBfgFIVrWpZttFYS2i10MldqPWyTIq8Nxq7XkaVz33Kkj2c1Eq6htPtxA7wjUfDyHWCtmo833pwsSoSvoWolcJq0kPXOnJXDOgNEJhVzDx2SfDP7lukjfPIPlk8cINFMYxE8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZoEwM3X7; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZoEwM3X7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82A991F000E9; Fri, 22 May 2026 15:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779464763; bh=slCSFqh3ovqTYMYBEmC2mxVNKxCOIPgFlRns58S1SIo=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=ZoEwM3X7Cin7xpQyIqelhsTfiBvpax921aItIcW4dfy4CYNK8XY9ysLQuhZwUErwD 5PhYmBRAkaMagPpoblMzhE98xxIZgmLJ5iCRUk7M1pYFmIb/a61HJjJGGn1jG/4M+r GJmKdPWMMcnk0pKrR9+PJoEFcH8dz9WtVoo7uvIU0pRjYe+fjeuzc6ObIcrxOnC4XW 4cIn908EAtlb1VPK6qPTCcP29otXBncT3ot2amxXK8kYeBXBDBW2PC1qvKCzKOEpe8 xYv35NTNo80lScvVAgtpemrpnj75gTBFOUMibDNKSOGm7Rxg6rix2cOIuh/hKhegzb UJRNTi6IHJofQ== Date: Fri, 22 May 2026 09:46:00 -0600 From: Keith Busch To: Chao Shi Cc: linux-nvme@lists.infradead.org, Christoph Hellwig , Sagi Grimberg , Jens Axboe , Tatsuya Sasaki , Maurizio Lombardi , linux-kernel@vger.kernel.org, Sungwoo Kim , Dave Tian , Weidong Zhu Subject: Re: [PATCH v3] nvme: reject keep-alive passthrough on non-fabrics Message-ID: References: <20260522152807.2061501-1-coshi036@gmail.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: <20260522152807.2061501-1-coshi036@gmail.com> On Fri, May 22, 2026 at 11:28:07AM -0400, Chao Shi wrote: > +static bool nvme_passthru_cmd_allowed(struct nvme_ctrl *ctrl, > + struct nvme_command *c) > +{ > + if (c->common.opcode != nvme_admin_set_features) > + return true; > + > + switch (le32_to_cpu(c->common.cdw10) & 0xff) { > + case NVME_FEAT_KATO: > + /* > + * Keep Alive is optional on PCIe (NVMe 2.0a 5.27.1.12) and the > + * driver only arms keep-alive for fabrics. Enabling it on > + * other transports starts a keep-alive command the driver is > + * not set up for and harms idle power states, so reject it. > + */ > + return ctrl->ops->flags & NVME_F_FABRICS; > + default: > + return true; > + } > +} > + > /* > * Convert integer values from ioctl structures to user pointers, silently > * ignoring the upper bits in the compat case to match behaviour of 32-bit > @@ -311,6 +338,9 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, > if (!nvme_cmd_allowed(ns, &c, 0, open_for_write)) > return -EACCES; > > + if (!nvme_passthru_cmd_allowed(ctrl, &c)) > + return -EOPNOTSUPP; You you have check if it's an admin command first. This going to break the "Data Set Management" IO command.