From 8ddf8e991c0d271d2681627fab08e6730ae73ae0 Mon Sep 17 00:00:00 2001 From: Luca Dariz Date: Mon, 16 Jan 2023 11:58:52 +0100 Subject: x86_64: expand and shrink messages in copy{in, out}msg routines * i386/i386/copy_user.h: new file to handle 32/64 bit differences - add msg_usize() to recontruct the user-space message size - add copyin/copyout helpers for addresses and ports * include/mach/message.h: add msg alignment macros * ipc/ipc_kmsg.c: - copyin/out ports names instead of using pointer magic * ipc/ipc_mqueue.c: use msg_usize() to check if we can actually receive the message * ipc/mach_msg.c: Likewise for continuations in receive path * x86_64/Makefrag.am: add x86_64/copy_user.c * x86_64/copy_user.c: new file to handle message expansion and shrinking during copyinmsg/copyoutmsg for 64 bit kernels. - port names -> port pointers on all 64-bit builds - 32-bit pointer -> 64 bit pointer when using 32-bit userspace * x86_64/locore.S: remove copyinmsg() and copyoutmsg() Message-Id: <20230116105857.240210-3-luca@orpolo.org> --- ipc/ipc_mqueue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ipc/ipc_mqueue.c') diff --git a/ipc/ipc_mqueue.c b/ipc/ipc_mqueue.c index ac6bed51..44e1eb98 100644 --- a/ipc/ipc_mqueue.c +++ b/ipc/ipc_mqueue.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -540,7 +541,7 @@ ipc_mqueue_receive( if (kmsg != IKM_NULL) { /* check space requirements */ - if (kmsg->ikm_header.msgh_size > max_size) { + if (msg_usize(&kmsg->ikm_header) > max_size) { * (mach_msg_size_t *) kmsgp = kmsg->ikm_header.msgh_size; imq_unlock(mqueue); @@ -649,7 +650,7 @@ ipc_mqueue_receive( /* we have a kmsg; unlock the msg queue */ imq_unlock(mqueue); - assert(kmsg->ikm_header.msgh_size <= max_size); + assert(msg_usize(&kmsg->ikm_header) <= max_size); } { -- cgit v1.2.3