mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-28 21:03:54 -06:00
linux-user: Allocate thunk size dynamically
We store all struct types in an array of static size without ever checking whether we overrun it. Of course some day someone (like me in another, ancient ALSA enabling patch set) will run into the limit without realizing it. So let's make the allocation dynamic. We already know the number of structs that we want to allocate, so we only need to pass the variable into the respective piece of code. Also, to ensure we don't accidently overwrite random memory, add some asserts to sanity check whether a thunk is actually part of our array. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
This commit is contained in:
parent
0a2df857a7
commit
8be656b87c
3 changed files with 18 additions and 5 deletions
|
@ -3277,6 +3277,7 @@ static abi_long do_ipc(unsigned int call, abi_long first,
|
|||
#define STRUCT_SPECIAL(name) STRUCT_ ## name,
|
||||
enum {
|
||||
#include "syscall_types.h"
|
||||
STRUCT_MAX
|
||||
};
|
||||
#undef STRUCT
|
||||
#undef STRUCT_SPECIAL
|
||||
|
@ -4879,6 +4880,8 @@ void syscall_init(void)
|
|||
int size;
|
||||
int i;
|
||||
|
||||
thunk_init(STRUCT_MAX);
|
||||
|
||||
#define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def);
|
||||
#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def);
|
||||
#include "syscall_types.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue