lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu,  1 Feb 2024 20:56:56 -0800
From: Reinette Chatre <reinette.chatre@...el.com>
To: jgg@...dia.com,
	yishaih@...dia.com,
	shameerali.kolothum.thodi@...wei.com,
	kevin.tian@...el.com,
	alex.williamson@...hat.com
Cc: kvm@...r.kernel.org,
	dave.jiang@...el.com,
	ashok.raj@...el.com,
	reinette.chatre@...el.com,
	linux-kernel@...r.kernel.org,
	patches@...ts.linux.dev
Subject: [PATCH 02/17] vfio/pci: Remove duplicate check from vfio_pci_set_ctx_trigger_single() wrappers

Both wrappers of vfio_pci_set_ctx_trigger_single() perform the
same parameter checks before calling vfio_pci_set_ctx_trigger_single().

vfio_pci_set_ctx_trigger_single() only handles a single interrupt that
is expected to start from 0. Move parameter checks into
vfio_pci_set_ctx_trigger_single() instead of duplicated in its callers.

Signed-off-by: Reinette Chatre <reinette.chatre@...el.com>
---
 drivers/vfio/pci/vfio_pci_intrs.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index f9280e32972a..69ab11863282 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -704,9 +704,13 @@ static int vfio_pci_set_msi_trigger(struct vfio_pci_core_device *vdev,
 }
 
 static int vfio_pci_set_ctx_trigger_single(struct eventfd_ctx **ctx,
+					   unsigned int start,
 					   unsigned int count, uint32_t flags,
 					   void *data)
 {
+	if (start != 0 || count > 1)
+		return -EINVAL;
+
 	/* DATA_NONE/DATA_BOOL enables loopback testing */
 	if (flags & VFIO_IRQ_SET_DATA_NONE) {
 		if (*ctx) {
@@ -763,10 +767,10 @@ static int vfio_pci_set_err_trigger(struct vfio_pci_core_device *vdev,
 				    unsigned int count, uint32_t flags,
 				    void *data)
 {
-	if (index != VFIO_PCI_ERR_IRQ_INDEX || start != 0 || count > 1)
+	if (index != VFIO_PCI_ERR_IRQ_INDEX)
 		return -EINVAL;
 
-	return vfio_pci_set_ctx_trigger_single(&vdev->err_trigger,
+	return vfio_pci_set_ctx_trigger_single(&vdev->err_trigger, start,
 					       count, flags, data);
 }
 
@@ -775,10 +779,10 @@ static int vfio_pci_set_req_trigger(struct vfio_pci_core_device *vdev,
 				    unsigned int count, uint32_t flags,
 				    void *data)
 {
-	if (index != VFIO_PCI_REQ_IRQ_INDEX || start != 0 || count > 1)
+	if (index != VFIO_PCI_REQ_IRQ_INDEX)
 		return -EINVAL;
 
-	return vfio_pci_set_ctx_trigger_single(&vdev->req_trigger,
+	return vfio_pci_set_ctx_trigger_single(&vdev->req_trigger, start,
 					       count, flags, data);
 }
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ