summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--futility/kernel_blob.h3
-rw-r--r--futility/vb1_helper.c14
2 files changed, 16 insertions, 1 deletions
diff --git a/futility/kernel_blob.h b/futility/kernel_blob.h
index ab1c82fd..1ee4ea7b 100644
--- a/futility/kernel_blob.h
+++ b/futility/kernel_blob.h
@@ -7,6 +7,9 @@
#ifndef VBOOT_REFERENCE_KERNEL_BLOB_H_
#define VBOOT_REFERENCE_KERNEL_BLOB_H_
+/* Linux vmlinuz header signature */
+#define VMLINUZ_HEADER_SIG 0x53726448
+
/* Maximum kernel command-line size */
#define CROS_CONFIG_SIZE 4096
diff --git a/futility/vb1_helper.c b/futility/vb1_helper.c
index fb9022f0..18caf1f3 100644
--- a/futility/vb1_helper.c
+++ b/futility/vb1_helper.c
@@ -146,6 +146,10 @@ static int KernelSize(uint8_t *kernel_buf,
/* The first part of the x86 vmlinuz is a header, followed by
* a real-mode boot stub. We only want the 32-bit part. */
lh = (struct linux_kernel_params *)kernel_buf;
+ if (lh->header != VMLINUZ_HEADER_SIG) {
+ Debug("Not a linux kernel image\n");
+ return kernel_size;
+ }
kernel32_start = (lh->setup_sects + 1) << 9;
if (kernel32_start >= kernel_size) {
fprintf(stderr, "Malformed kernel\n");
@@ -166,10 +170,15 @@ static int PickApartVmlinuz(uint8_t *kernel_buf,
struct linux_kernel_params *lh, *params;
/* Except for x86, the kernel is the kernel. */
- if (arch == ARCH_X86) {
+ switch (arch) {
+ case ARCH_X86:
/* The first part of the x86 vmlinuz is a header, followed by
* a real-mode boot stub. We only want the 32-bit part. */
lh = (struct linux_kernel_params *)kernel_buf;
+ if (lh->header != VMLINUZ_HEADER_SIG) {
+ Debug("Not a linux kernel image\n");
+ break;
+ }
kernel32_start = (lh->setup_sects + 1) << 9;
if (kernel32_start >= kernel_size) {
fprintf(stderr, "Malformed kernel\n");
@@ -207,6 +216,9 @@ static int PickApartVmlinuz(uint8_t *kernel_buf,
params->e820_entries[1].start_addr = 0xfffff000;
params->e820_entries[1].segment_size = 0x00001000;
params->e820_entries[1].segment_type = E820_TYPE_RESERVED;
+ break;
+ default:
+ break;
}
Debug(" kernel32_start=0x%" PRIx64 "\n", kernel32_start);