Patchwork multiboot: Prevent loading of x86_64 images

login
register
mail settings
Submitter Adam Lackorzynski
Date Nov. 4, 2010, 10:22 p.m.
Message ID <20101104222214.GC30050@os.inf.tu-dresden.de>
Download mbox | patch
Permalink /patch/70176/
State New
Headers show

Comments

Adam Lackorzynski - Nov. 4, 2010, 10:22 p.m.
A via -kernel supplied x86_64 ELF image is being started in 32bit mode.
Detect and exit if a 64bit image has been supplied.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
Acked-by: Alexander Graf <agraf@suse.de>
---
 hw/multiboot.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Anthony Liguori - Nov. 16, 2010, 8:09 p.m.
On 11/04/2010 05:22 PM, Adam Lackorzynski wrote:
> A via -kernel supplied x86_64 ELF image is being started in 32bit mode.
> Detect and exit if a 64bit image has been supplied.
>
> Signed-off-by: Adam Lackorzynski<adam@os.inf.tu-dresden.de>
> Acked-by: Alexander Graf<agraf@suse.de>
>    

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   hw/multiboot.c |    6 ++++++
>   1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/hw/multiboot.c b/hw/multiboot.c
> index f9097a2..e710bbb 100644
> --- a/hw/multiboot.c
> +++ b/hw/multiboot.c
> @@ -171,6 +171,12 @@ int load_multiboot(void *fw_cfg,
>           uint64_t elf_low, elf_high;
>           int kernel_size;
>           fclose(f);
> +
> +        if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) {
> +            fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n");
> +            exit(1);
> +        }
> +
>           kernel_size = load_elf(kernel_filename, NULL, NULL,&elf_entry,
>                                  &elf_low,&elf_high, 0, ELF_MACHINE, 0);
>           if (kernel_size<  0) {
>

Patch

diff --git a/hw/multiboot.c b/hw/multiboot.c
index f9097a2..e710bbb 100644
--- a/hw/multiboot.c
+++ b/hw/multiboot.c
@@ -171,6 +171,12 @@  int load_multiboot(void *fw_cfg,
         uint64_t elf_low, elf_high;
         int kernel_size;
         fclose(f);
+
+        if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) {
+            fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n");
+            exit(1);
+        }
+
         kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
                                &elf_low, &elf_high, 0, ELF_MACHINE, 0);
         if (kernel_size < 0) {