diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-10-01 17:24:02 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-10-01 17:34:13 +0200 |
commit | 126c0364bf7d72d4f2ecf1ad2f4ebe1d2667940d (patch) | |
tree | 07be87498222a605dda3ea5e0ffe81d3e5b356b0 /ipc/ipc_kmsg.h | |
parent | 513125f30a05b4ad3408d5f4efd36d2c6ba10744 (diff) | |
download | gnumach-126c0364bf7d72d4f2ecf1ad2f4ebe1d2667940d.tar.gz gnumach-126c0364bf7d72d4f2ecf1ad2f4ebe1d2667940d.tar.bz2 gnumach-126c0364bf7d72d4f2ecf1ad2f4ebe1d2667940d.zip |
ipc: Fix allocating kernel buffer for storing user message
Otherwise ipc_kmsg_copyin_body will overflow.
Diffstat (limited to 'ipc/ipc_kmsg.h')
-rw-r--r-- | ipc/ipc_kmsg.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ipc/ipc_kmsg.h b/ipc/ipc_kmsg.h index 45e174b7..9ee1aa4a 100644 --- a/ipc/ipc_kmsg.h +++ b/ipc/ipc_kmsg.h @@ -156,6 +156,16 @@ MACRO_END #define ikm_alloc(size) \ ((ipc_kmsg_t) kalloc(ikm_plus_overhead(size))) +/* + * The conversion between userland and kernel-land has to convert from port + * names to ports. This may increase the size that needs to be allocated + * on the kernel size. At worse the message is full of port names to be + * converted. + */ +#define IKM_EXPAND_FACTOR ((sizeof(mach_port_t) + sizeof(mach_port_name_t) - 1) / sizeof(mach_port_name_t)) +/* But make sure it's not the converse. */ +_Static_assert(sizeof(mach_port_t) >= sizeof(mach_port_name_t)); + #define ikm_init(kmsg, size) \ MACRO_BEGIN \ ikm_init_special((kmsg), ikm_plus_overhead(size)); \ |