kvm: mpic: extend active IRQ sources to 255
Subsystems (2)
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
@@ -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
Quoted 17 lines · P J P
From: P J P <[email protected]>
openpic_src_writesets interrupt level 'src->output' masked withILR_INTTGT_MASK(=0xFF). It's then used to index 'dst->outputs_active' array. With NUM_INPUTS=3, it may lead to OOB array access.Reported-by Reno Robert <[email protected]>Signed-off-by P J P <[email protected]>--- arch/powerpc/kvm/mpic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/kvm/mpic.c +0
-0
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.
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