Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prevent overflow with pre-allocated RAM blocks #1712

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions qemu/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,6 @@ RAMBlock *qemu_ram_alloc_from_ptr(struct uc_struct *uc, ram_addr_t size, void *h
RAMBlock *new_block;
ram_addr_t max_size = size;

size = HOST_PAGE_ALIGN(uc, size);
max_size = HOST_PAGE_ALIGN(uc, max_size);
new_block = g_malloc0(sizeof(*new_block));
if (new_block == NULL)
return NULL;
Expand All @@ -1100,6 +1098,9 @@ RAMBlock *qemu_ram_alloc_from_ptr(struct uc_struct *uc, ram_addr_t size, void *h
new_block->host = host;
if (host) {
new_block->flags |= RAM_PREALLOC;
} else {
size = HOST_PAGE_ALIGN(uc, size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks promising but assigning values to size and max_size seems doing nothing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. The max_length assignment should have moved down as well.

max_size = HOST_PAGE_ALIGN(uc, max_size);
}

uc->invalid_addr = UC_ERR_OK;
Expand Down