[PATCH v3] nvme: reject keep-alive passthrough on non-fabrics

Keith Busch kbusch at kernel.org
Fri May 22 08:46:00 PDT 2026


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.



More information about the Linux-nvme mailing list