mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
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>
This commit is contained in:
parent
76ed4b18de
commit
0f0f8b611e
7 changed files with 27 additions and 19 deletions
|
@ -272,8 +272,8 @@ static unsigned long sun4m_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_LOAD_ADDR + i);
|
||||
if (ldl_p(ptr) == 0x48647253) { // HdrS
|
||||
ptr = rom_ptr(KERNEL_LOAD_ADDR + i, 24);
|
||||
if (ptr && ldl_p(ptr) == 0x48647253) { /* HdrS */
|
||||
stl_p(ptr + 16, INITRD_LOAD_ADDR);
|
||||
stl_p(ptr + 20, initrd_size);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue