summaryrefslogtreecommitdiff
path: root/ipc
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-28 03:33:37 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-28 03:33:37 +0200
commit30c93547cd14db1ae44ea9e32bf36a2c2b152c07 (patch)
tree1e192300f34a022f43ebe48e904828afd6933ed1 /ipc
parent286ae33f3b02045491e651326aaf544db3ace4ad (diff)
kmsg: factorize uint32_t into an alignment type
and restore the checks for offset alignment in the message, even if currently it is trivially always alright.
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_kmsg.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c
index cf7ec77d..8f54f81d 100644
--- a/ipc/ipc_kmsg.c
+++ b/ipc/ipc_kmsg.c
@@ -69,9 +69,11 @@
#endif
/* msg body is always aligned to 4 bytes */
-#define msg_is_misaligned(x) ( ((vm_offset_t)(x)) & (sizeof(uint32_t)-1) )
+typedef uint32_t msg_align_t;
+
+#define msg_is_misaligned(x) ( ((vm_offset_t)(x)) & (sizeof(msg_align_t)-1) )
#define msg_align(x) \
- ( ( ((vm_offset_t)(x)) + (sizeof(uint32_t)-1) ) & ~(sizeof(uint32_t)-1) )
+ ( ( ((vm_offset_t)(x)) + (sizeof(msg_align_t)-1) ) & ~(sizeof(msg_align_t)-1) )
ipc_kmsg_t ipc_kmsg_cache[NCPUS];
@@ -1377,6 +1379,9 @@ ipc_kmsg_copyin_body(
} else {
vm_offset_t addr;
+ if (sizeof(msg_align_t) > sizeof(mach_msg_type_t))
+ saddr = msg_align(saddr);
+
if ((eaddr - saddr) < sizeof(vm_offset_t)) {
ipc_kmsg_clean_partial(kmsg, taddr, FALSE, 0);
return MACH_SEND_MSG_TOO_SMALL;
@@ -2424,6 +2429,9 @@ ipc_kmsg_copyout_body(
} else {
vm_offset_t data;
+ if (sizeof(msg_align_t) > sizeof(mach_msg_type_t))
+ saddr = msg_align(saddr);
+
data = * (vm_offset_t *) saddr;
/* copyout memory carried in the message */