]> xenbits.xensource.com Git - xen.git/commitdiff
xen/ucode: Make Intel's microcode_sanity_check() stricter
authorDemi Marie Obenour <demi@invisiblethingslab.com>
Tue, 29 Oct 2024 15:35:52 +0000 (16:35 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 29 Oct 2024 15:35:52 +0000 (16:35 +0100)
The SDM states that data size must be a multiple of 4, but Xen doesn't check
this propery.

This is liable to cause a later failures, but should be checked explicitly.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 8752ad83e79754f8109457cff796e5f86f644348
master date: 2024-09-24 18:57:38 +0100

xen/arch/x86/cpu/microcode/intel.c

index a2d88e3ac00b1eaaf937a784cdfae04917416529..bd15236709db85b178ccb1eb15ec9b850af06db2 100644 (file)
@@ -155,10 +155,13 @@ static int microcode_sanity_check(const struct microcode_patch *patch)
     uint32_t sum;
 
     /*
-     * Total size must be a multiple of 1024 bytes.  Data size and the header
-     * must fit within it.
+     * The SDM states:
+     * - Data size must be a multiple of 4.
+     * - Total size must be a multiple of 1024 bytes.  Data size and the
+     *   header must fit within it.
      */
     if ( (total_size & 1023) ||
+         (data_size & 3) ||
          data_size > (total_size - MC_HEADER_SIZE) )
     {
         printk(XENLOG_WARNING "microcode: Bad size\n");