]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
ppc/spapr: Fix possible pa_features memory overflow
authorNicholas Piggin <npiggin@gmail.com>
Mon, 17 Mar 2025 03:49:36 +0000 (13:49 +1000)
committerNicholas Piggin <npiggin@gmail.com>
Thu, 20 Mar 2025 09:57:44 +0000 (19:57 +1000)
Coverity reports a possible memory overflow in spapr_dt_pa_features().
This should not be a true bug since DAWR1 cap is only be true for
CPU_POWERPC_LOGICAL_3_10. Add an assertion to ensure any bug there is
caught.

Resolves: Coverity CID 1593722
Fixes: 5f361ea187ba ("ppc: spapr: Enable 2nd DAWR on Power10 pSeries machine")
Reviewed-By: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
hw/ppc/spapr.c

index a415e51d077af98eaa01f1b0e6ce19359fd6fdb8..9865d7147ffe635d4f2e80275cb2ab7a4ab11aca 100644 (file)
@@ -296,6 +296,7 @@ static void spapr_dt_pa_features(SpaprMachineState *spapr,
         pa_features[40 + 2] &= ~0x80; /* Radix MMU */
     }
     if (spapr_get_cap(spapr, SPAPR_CAP_DAWR1)) {
+        g_assert(pa_size > 66);
         pa_features[66] |= 0x80;
     }