Skip to contentSkip to conversation

kvm: mpic: extend active IRQ sources to 255

PATCH Superseded P J P 2 participants 3 messages Nov 13, 2019 – Nov 15, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH 1/1 kvm: mpic: extend active IRQ sources to 255

From: P J P <[email protected]>

openpic_src_write sets interrupt level 'src->output' masked with ILR_INTTGT_MASK(=0xFF). It's then used to index 'dst->outputs_active' array. With NUM_INPUTS=3, it may lead to OOB array access.

---
 arch/powerpc/kvm/mpic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/mpic.c +1 -1
index fe312c160d97..a5ae884d3891 100644
@@ -103,7 +103,7 @@ static struct fsl_mpic_info fsl_mpic_42 = {
 #define ILR_INTTGT_INT    0x00
 #define ILR_INTTGT_CINT   0x01	/* critical */
 #define ILR_INTTGT_MCP    0x02	/* machine check */
-#define NUM_OUTPUTS       3
+#define NUM_OUTPUTS       0xff
 
 #define MSIIR_OFFSET       0x140
 #define MSIIR_SRS_SHIFT    29
Signature · 1 line
2.21.0
#1 lore raw
Quoted 17 lines · P J P

From: P J P <[email protected]>

openpic_src_write sets interrupt level 'src->output' masked with ILR_INTTGT_MASK(=0xFF). It's then used to index 'dst->outputs_active' array. With NUM_INPUTS=3, it may lead to OOB array access.

---
 arch/powerpc/kvm/mpic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/mpic.c +0 -0
index fe312c160d97..a5ae884d3891 100644

arch/powerpc/kvm/mpic.c static struct fsl_mpic_info fsl_mpic_42 = { · line 106

Quoted 5 lines
arch/powerpc/kvm/mpic.c +1 -1
@@ -103,7 +103,7 @@ static struct fsl_mpic_info fsl_mpic_42 = {
 #define ILR_INTTGT_INT    0x00
 #define ILR_INTTGT_CINT   0x01	/* critical */
 #define ILR_INTTGT_MCP    0x02	/* machine check */
-#define NUM_OUTPUTS       3
+#define NUM_OUTPUTS       0xff

I don't think this is the correct fix. This code is emulating hardware which can drive up to three interrupt outputs per CPU, not
255. Instead we need either to prevent src->output from being set to 3 or greater, or else limit its value when it is used.

Paul.

author
#2 lore raw
In reply to P J P

Hello Paul,

+-- On Fri, 15 Nov 2019, Paul Mackerras wrote --+
| Instead we need either to prevent src->output from being set to 3 or 
| greater, or else limit its value when it is used.

I've sent a revised patch v2 for this.

It is not clear if this issue can be misused from a guest running on PPC E500 platform. Considering E500 is mostly used for SoC/Embedded systems.

...wdyt?
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D