x86, amd-ucode: Check UCODE_MAGIC before loading the container file
authorBorislav Petkov <borislav.petkov@amd.com>
Thu, 29 Oct 2009 13:45:52 +0000 (14:45 +0100)
committerIngo Molnar <mingo@elte.hu>
Tue, 10 Nov 2009 04:46:09 +0000 (05:46 +0100)
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
LKML-Reference: <20091029134552.GC30802@alberich.amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/microcode_amd.c

index 366baa1..f4c538b 100644 (file)
@@ -317,6 +317,12 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device)
                return UCODE_NFOUND;
        }
 
+       if (*(u32 *)firmware->data != UCODE_MAGIC) {
+               printk(KERN_ERR "microcode: invalid UCODE_MAGIC (0x%08x)\n",
+                      *(u32 *)firmware->data);
+               return UCODE_ERROR;
+       }
+
        ret = generic_load_microcode(cpu, firmware->data, firmware->size);
 
        release_firmware(firmware);