]> xenbits.xensource.com Git - xen.git/commitdiff
x86/ucode/amd: Fix OoB read in cpu_request_microcode()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 9 Feb 2021 22:10:54 +0000 (22:10 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 10 Feb 2021 13:23:51 +0000 (13:23 +0000)
verify_patch_size() is a maximum size check, and doesn't have a minimum bound.

If the microcode container encodes a blob with a length less than 64 bytes,
the subsequent calls to microcode_fits()/compare_header() may read off the end
of the buffer.

Fixes: 4de936a38a ("x86/ucode/amd: Rework parsing logic in cpu_request_microcode()")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpu/microcode/amd.c

index 5255028af7136602073ab2df6b0bd50be1058127..3e51e53c1f8fea84220e5fc53aecdfb6988c7885 100644 (file)
@@ -349,6 +349,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf, size_t siz
             if ( size < sizeof(*mc) ||
                  (mc = buf)->type != UCODE_UCODE_TYPE ||
                  size - sizeof(*mc) < mc->len ||
+                 mc->len < sizeof(struct microcode_patch) ||
                  (!skip_ucode && !verify_patch_size(mc->len)) )
             {
                 printk(XENLOG_ERR "microcode: Bad microcode data\n");