[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/22] ppc/pnv: check size before data buffer access
From: |
David Gibson |
Subject: |
[Qemu-devel] [PULL 17/22] ppc/pnv: check size before data buffer access |
Date: |
Thu, 8 Nov 2018 23:16:41 +1100 |
From: Prasad J Pandit <address@hidden>
While performing PowerNV memory r/w operations, the access length
'sz' could exceed the data[4] buffer size. Add check to avoid OOB
access.
Reported-by: Moguofang <address@hidden>
Signed-off-by: Prasad J Pandit <address@hidden>
Reviewed-by: Cédric Le Goater <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/pnv_lpc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index d7721320a2..172a915cfc 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -155,9 +155,15 @@ static void pnv_lpc_do_eccb(PnvLpcController *lpc,
uint64_t cmd)
/* XXX Check for magic bits at the top, addr size etc... */
unsigned int sz = (cmd & ECCB_CTL_SZ_MASK) >> ECCB_CTL_SZ_LSH;
uint32_t opb_addr = cmd & ECCB_CTL_ADDR_MASK;
- uint8_t data[4];
+ uint8_t data[8];
bool success;
+ if (sz > sizeof(data)) {
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "ECCB: invalid operation at @0x%08x size %d\n", opb_addr, sz);
+ return;
+ }
+
if (cmd & ECCB_CTL_READ) {
success = opb_read(lpc, opb_addr, data, sz);
if (success) {
--
2.19.1
- [Qemu-devel] [PULL 22/22] ppc/spapr_caps: Add SPAPR_CAP_NESTED_KVM_HV, (continued)
- [Qemu-devel] [PULL 22/22] ppc/spapr_caps: Add SPAPR_CAP_NESTED_KVM_HV, David Gibson, 2018/11/08
- [Qemu-devel] [PULL 09/22] target/ppc: Split out float_invalid_op_addsub, David Gibson, 2018/11/08
- [Qemu-devel] [PULL 10/22] target/ppc: Split out float_invalid_op_mul, David Gibson, 2018/11/08
- [Qemu-devel] [PULL 15/22] hw/ppc/mac_newworld: Free openpic_irqs array after use, David Gibson, 2018/11/08
- [Qemu-devel] [PULL 05/22] hw/ppc/spapr_rng: Introduce CONFIG_SPAPR_RNG switch for spapr_rng.c, David Gibson, 2018/11/08
- [Qemu-devel] [PULL 16/22] target/ppc: fix mtmsr instruction for icount, David Gibson, 2018/11/08
- [Qemu-devel] [PULL 14/22] macio/pmu: Fix missing vmsd terminator, David Gibson, 2018/11/08
- [Qemu-devel] [PULL 19/22] hw/ppc/ppc440_uc: Remove dead code in sdram_size(), David Gibson, 2018/11/08
- [Qemu-devel] [PULL 21/22] target/ppc: Add one reg id for ptcr, David Gibson, 2018/11/08
- [Qemu-devel] [PULL 13/22] spapr_pci: convert g_malloc() to g_new(), David Gibson, 2018/11/08
- [Qemu-devel] [PULL 17/22] ppc/pnv: check size before data buffer access,
David Gibson <=
- Re: [Qemu-devel] [PULL 00/22] ppc-for-3.1 queue 20181108, Eric Blake, 2018/11/08