All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH] xen/vpci: Fix UB in mask_write
@ 2024-11-06  8:05 Mykyta Poturai
  2024-11-06  9:00 ` Roger Pau Monné
  2024-11-06 11:35 ` Jan Beulich
  0 siblings, 2 replies; 13+ messages in thread
From: Mykyta Poturai @ 2024-11-06  8:05 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org; +Cc: Mykyta Poturai, Roger Pau Monné

During the construction of dmask value, it gets shifted by
(32 - msi->vectors) bits. If msi->vectors is 0, the result of the shift
becomes undefined due to shifting by a size of the type. While this
works fine on x86, on ARM the resulting mask becomes 0xFFFFFFFF, which
is incorrect.

Fix this by adding an explicit check for msi->vectors == 0.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
 xen/drivers/vpci/msi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/drivers/vpci/msi.c b/xen/drivers/vpci/msi.c
index 7bda47e7fc..787296fd42 100644
--- a/xen/drivers/vpci/msi.c
+++ b/xen/drivers/vpci/msi.c
@@ -172,7 +172,7 @@ static void cf_check mask_write(
     struct vpci_msi *msi = data;
     uint32_t dmask = msi->mask ^ val;
 
-    if ( !dmask )
+    if ( !dmask || msi->vectors == 0 )
         return;
 
     if ( msi->enabled )
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-11-12 11:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06  8:05 [XEN PATCH] xen/vpci: Fix UB in mask_write Mykyta Poturai
2024-11-06  9:00 ` Roger Pau Monné
2024-11-06  9:07   ` Roger Pau Monné
2024-11-06 11:31     ` Jan Beulich
2024-11-06 12:26       ` Mykyta Poturai
2024-11-06 12:42         ` Roger Pau Monné
2024-11-06 14:32           ` Mykyta Poturai
2024-11-06 14:57             ` Roger Pau Monné
2024-11-11 12:21               ` Mykyta Poturai
2024-11-12 11:26                 ` Roger Pau Monné
2024-11-07  9:25         ` Jan Beulich
2024-11-07  9:36           ` Roger Pau Monné
2024-11-06 11:35 ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.