diff options
author | Thomas Huth <thuth@redhat.com> | 2018-06-26 11:35:40 +0200 |
---|---|---|
committer | Cornelia Huck <cohuck@redhat.com> | 2018-07-02 10:37:38 +0200 |
commit | 0f0f8b611eeea663c8d3b6021918033e257411a1 (patch) | |
tree | 69faeb3be924514248d41a232bf82e439c1da734 /hw/sparc64/sun4u.c | |
parent | 76ed4b18debfe597329d1f6a9eb2ec9ffa751ecd (diff) | |
download | qemu-0f0f8b611eeea663c8d3b6021918033e257411a1.zip qemu-0f0f8b611eeea663c8d3b6021918033e257411a1.tar.gz qemu-0f0f8b611eeea663c8d3b6021918033e257411a1.tar.bz2 |
loader: Check access size when calling rom_ptr() to avoid crashes
The rom_ptr() function allows direct access to the ROM blobs that we
load during startup. However, there are currently no checks for the
size of the accesses, so it's currently possible to crash QEMU for
example with:
$ echo "Insane in the mainframe" > /tmp/test.txt
$ s390x-softmmu/qemu-system-s390x -kernel /tmp/test.txt -append xyz
Segmentation fault (core dumped)
$ s390x-softmmu/qemu-system-s390x -kernel /tmp/test.txt -initrd /tmp/test.txt
Segmentation fault (core dumped)
$ echo -n HdrS > /tmp/hdr.txt
$ sparc64-softmmu/qemu-system-sparc64 -kernel /tmp/hdr.txt -initrd /tmp/hdr.txt
Segmentation fault (core dumped)
We need a possibility to check the size of the ROM area that we want
to access, thus let's add a size parameter to the rom_ptr() function
to avoid these problems.
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1530005740-25254-1-git-send-email-thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'hw/sparc64/sun4u.c')
-rw-r--r-- | hw/sparc64/sun4u.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 3975a7b..334dd70 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -186,8 +186,8 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename, } if (*initrd_size > 0) { for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) { - ptr = rom_ptr(*kernel_addr + i); - if (ldl_p(ptr + 8) == 0x48647253) { /* HdrS */ + ptr = rom_ptr(*kernel_addr + i, 32); + if (ptr && ldl_p(ptr + 8) == 0x48647253) { /* HdrS */ stl_p(ptr + 24, *initrd_addr + *kernel_addr); stl_p(ptr + 28, *initrd_size); break; |