From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9F4B113A27E; Wed, 3 Jul 2024 11:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720006149; cv=none; b=nBGf9vNIQ9xI78853ij0TxrKERufmMlhpx8bRYm8VdNKhQ10nx+AocLEo22+PEWY55bOxDf/YNFVNJfcljNhcO81P7t9qga5L41qBGbARGOuTtfRib6OxBQ9QB+2gkSKTSdvu7K5GWg8pbWB75Vb6J1hbKextqkPvaaJ+AzW+88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720006149; c=relaxed/simple; bh=cDkRzQkSa1y7gpb91KkRLX2+dSYvwUdo9gE3oH/hXAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GLJ+0SXfJYSBe4uSLnEJ0nSAc0YeUjhGkAEzK2HoWfKjoMwnX/CLBliBLXxOeOYc4/vc6s68kiRnZxieocQFSRl6iSJIwmn+hxtE5VQ9e85ptEJHNaAUV4esb5S7uLL+G2NJyXeh2xaPPxqZqrtsSHrIzQw6Wufqc6jHXlHi5jE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2bClSfVR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2bClSfVR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCAF6C2BD10; Wed, 3 Jul 2024 11:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720006149; bh=cDkRzQkSa1y7gpb91KkRLX2+dSYvwUdo9gE3oH/hXAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2bClSfVRV9B23h+WynZ8isVrDgnZxDULoMsQzryP5nEE8JzqnMoPQeaKCFYoOHqpC jSaO82F0Pqhs009ozS0YqjnAzuRqHd/1tmUuCKA46ILE1+8lwiTipIKqVHywNccRkd vUO5KcNAM3baa8Mua+keqMf1UUWxQ5gzIvQjZmZk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jason Wang , Xie Yongji , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Maxime Coquelin , "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 5.15 285/356] vduse: validate block features only with block devices Date: Wed, 3 Jul 2024 12:40:21 +0200 Message-ID: <20240703102923.896470164@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240703102913.093882413@linuxfoundation.org> References: <20240703102913.093882413@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maxime Coquelin [ Upstream commit a115b5716fc9a64652aa9cb332070087178ffafa ] This patch is preliminary work to enable network device type support to VDUSE. As VIRTIO_BLK_F_CONFIG_WCE shares the same value as VIRTIO_NET_F_HOST_TSO4, we need to restrict its check to Virtio-blk device type. Acked-by: Jason Wang Reviewed-by: Xie Yongji Reviewed-by: Eugenio Pérez Signed-off-by: Maxime Coquelin Message-Id: <20240109111025.1320976-2-maxime.coquelin@redhat.com> Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/vdpa/vdpa_user/vduse_dev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 564864f039d20..898ef597338a2 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1227,13 +1227,14 @@ static bool device_is_allowed(u32 device_id) return false; } -static bool features_is_valid(u64 features) +static bool features_is_valid(struct vduse_dev_config *config) { - if (!(features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) + if (!(config->features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM))) return false; /* Now we only support read-only configuration space */ - if (features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE)) + if ((config->device_id == VIRTIO_ID_BLOCK) && + (config->features & BIT_ULL(VIRTIO_BLK_F_CONFIG_WCE))) return false; return true; @@ -1260,7 +1261,7 @@ static bool vduse_validate_config(struct vduse_dev_config *config) if (!device_is_allowed(config->device_id)) return false; - if (!features_is_valid(config->features)) + if (!features_is_valid(config)) return false; return true; -- 2.43.0