From 8be656b87c6bb1b9f8af3ff78094413d71e4443a Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Wed, 6 May 2015 23:47:32 +0200 Subject: 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 Signed-off-by: Riku Voipio --- include/exec/user/thunk.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/exec/user') diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index 87025c3b04..3b67462726 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -74,7 +74,7 @@ const argtype *thunk_convert(void *dst, const void *src, const argtype *type_ptr, int to_host); #ifndef NO_THUNK_TYPE_SIZE -extern StructEntry struct_entries[]; +extern StructEntry *struct_entries; int thunk_type_size_array(const argtype *type_ptr, int is_host); int thunk_type_align_array(const argtype *type_ptr, int is_host); @@ -186,4 +186,6 @@ unsigned int target_to_host_bitmask(unsigned int x86_mask, unsigned int host_to_target_bitmask(unsigned int alpha_mask, const bitmask_transtbl * trans_tbl); +void thunk_init(unsigned int max_structs); + #endif -- cgit v1.2.3