All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/intc/arm_gic: Fix interrupt ID in GICD_SGIR register
@ 2021-01-31 10:34 Philippe Mathieu-Daudé
  2021-01-31 10:43 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-31 10:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Edgar E . Iglesias, Peter Maydell, Alexander Bulekov,
	Sai Pavan Boddu, qemu-stable, Li Qiang,
	Philippe Mathieu-Daudé,
	Prasad J Pandit, Darren Kenny, qemu-arm, Luc Michel

Per the ARM Generic Interrupt Controller Architecture specification
(document "ARM IHI 0048B.b (ID072613)"), the SGIINTID field is 4 bit,
not 10:

  - 4.3 Distributor register descriptions
  - 4.3.15 Software Generated Interrupt Register, GICD_SG

    - Table 4-21 GICD_SGIR bit assignments

    The Interrupt ID of the SGI to forward to the specified CPU
    interfaces. The value of this field is the Interrupt ID, in
    the range 0-15, for example a value of 0b0011 specifies
    Interrupt ID 3.

Correct the irq mask to fix an undefined behavior (which eventually
lead to a heap-buffer-overflow, see [Buglink]):

   $ echo 'writel 0x8000f00 0xff4affb0' | qemu-system-aarch64 -M virt,accel=qtest -qtest stdio
   [I 1612088147.116987] OPENED
  [R +0.278293] writel 0x8000f00 0xff4affb0
  ../hw/intc/arm_gic.c:1498:13: runtime error: index 944 out of bounds for type 'uint8_t [16][8]'
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../hw/intc/arm_gic.c:1498:13

Cc: qemu-stable@nongnu.org
Fixes: 9ee6e8bb853 ("ARMv7 support.")
Buglink: https://bugs.launchpad.net/qemu/+bug/1913916
Reported-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Isnt it worth a CVE to help distributions track backports?
---
 hw/intc/arm_gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index af41e2fb448..75316329516 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -1476,7 +1476,7 @@ static void gic_dist_writel(void *opaque, hwaddr offset,
         int target_cpu;
 
         cpu = gic_get_current_cpu(s);
-        irq = value & 0x3ff;
+        irq = value & 0xf;
         switch ((value >> 24) & 3) {
         case 0:
             mask = (value >> 16) & ALL_CPU_MASK;
-- 
2.26.2



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

end of thread, other threads:[~2021-02-03 10:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-31 10:34 [PATCH] hw/intc/arm_gic: Fix interrupt ID in GICD_SGIR register Philippe Mathieu-Daudé
2021-01-31 10:43 ` Philippe Mathieu-Daudé
     [not found]   ` <20p82p5p-ns25-n434-37os-n55013s6313@erqung.pbz>
     [not found]     ` <6d29aa57-2e6e-e81d-831f-803d9aae798f@amsat.org>
2021-02-02  6:21       ` [QEMU-SECURITY] " P J P
2021-02-02  9:32         ` Philippe Mathieu-Daudé
2021-02-02 12:21           ` Peter Maydell
2021-02-02 15:10             ` Alexander Bulekov
2021-02-03 10:15             ` P J P

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.