summaryrefslogtreecommitdiff
path: root/x86_64
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2023-12-03 02:05:44 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-12-03 02:05:44 +0100
commit3af20238bf9b834b213f5aa9d0278fe13bd69b3c (patch)
tree13665bcfa28100308ce2e3e58778bec104abfa39 /x86_64
parentab250d41152edc262ef3783224e51ba8125ebd52 (diff)
Revert "x86_64: Support 8 byte inlined port rights to avoid message resizing."
This reverts commit 29d4bcaafc4c2040df27a6247603c68e7757205c.
Diffstat (limited to 'x86_64')
-rw-r--r--x86_64/copy_user.c67
1 files changed, 7 insertions, 60 deletions
diff --git a/x86_64/copy_user.c b/x86_64/copy_user.c
index c6e125d9..0d3f301b 100644
--- a/x86_64/copy_user.c
+++ b/x86_64/copy_user.c
@@ -265,15 +265,8 @@ static inline int copyout_unpack_msg_type(vm_offset_t kaddr,
mach_msg_type_size_t orig_size = kmtl->msgtl_size;
int ret;
- if (MACH_MSG_TYPE_PORT_ANY(kmtl->msgtl_name)) {
-#ifdef USER32
+ if (MACH_MSG_TYPE_PORT_ANY(kmtl->msgtl_name))
kmtl->msgtl_size = bytes_to_descsize(sizeof(mach_port_name_t));
-#else
- /* 64 bit ABI uses mach_port_name_inlined_t for inlined ports. */
- if (!kmt->msgt_inline)
- kmtl->msgtl_size = bytes_to_descsize(sizeof(mach_port_name_t));
-#endif
- }
ret = copyout_mach_msg_type_long(kmtl, (void*)uaddr);
kmtl->msgtl_size = orig_size;
if (ret)
@@ -290,15 +283,8 @@ static inline int copyout_unpack_msg_type(vm_offset_t kaddr,
mach_msg_type_size_t orig_size = kmt->msgt_size;
int ret;
- if (MACH_MSG_TYPE_PORT_ANY(kmt->msgt_name)) {
-#ifdef USER32
+ if (MACH_MSG_TYPE_PORT_ANY(kmt->msgt_name))
kmt->msgt_size = bytes_to_descsize(sizeof(mach_port_name_t));
-#else
- /* 64 bit ABI uses mach_port_name_inlined_t for inlined ports. */
- if (!kmt->msgt_inline)
- kmt->msgt_size = bytes_to_descsize(sizeof(mach_port_name_t));
-#endif
- }
ret = copyout_mach_msg_type(kmt, (void *)uaddr);
kmt->msgt_size = orig_size;
if (ret)
@@ -313,10 +299,8 @@ static inline int copyout_unpack_msg_type(vm_offset_t kaddr,
return 0;
}
-#ifdef USER32
/*
- * Compute the user-space size of a message still in the kernel when processing
- * messages from 32bit userland.
+ * Compute the user-space size of a message still in the kernel.
* The message may be originating from userspace (in which case we could
* optimize this by keeping the usize around) or from kernel space (we could
* optimize if the message structure is fixed and known in advance).
@@ -349,8 +333,7 @@ size_t msg_usize(const mach_msg_header_t *kmsg)
{
if (MACH_MSG_TYPE_PORT_ANY(name))
{
- const vm_size_t length = sizeof(mach_port_t) * number;
- saddr += length;
+ saddr += sizeof(mach_port_t) * number;
usize += sizeof(mach_port_name_t) * number;
}
else
@@ -372,7 +355,6 @@ size_t msg_usize(const mach_msg_header_t *kmsg)
}
return usize;
}
-#endif /* USER32 */
/*
* Expand the msg header and, if required, the msg body (ports, pointers)
@@ -441,9 +423,6 @@ int copyinmsg (const void *userbuf, void *kernelbuf, const size_t usize, const s
{
if (MACH_MSG_TYPE_PORT_ANY(name))
{
-#ifdef USER32
- if (size != bytes_to_descsize(sizeof(mach_port_name_t)))
- return 1;
if ((usaddr + sizeof(mach_port_name_t)*number) > ueaddr)
return 1;
adjust_msg_type_size(ktaddr, sizeof(mach_port_t) - sizeof(mach_port_name_t));
@@ -454,17 +433,6 @@ int copyinmsg (const void *userbuf, void *kernelbuf, const size_t usize, const s
ksaddr += sizeof(mach_port_t);
usaddr += sizeof(mach_port_name_t);
}
-#else
- if (size != bytes_to_descsize(sizeof(mach_port_name_inlined_t)))
- return 1;
- const vm_size_t length = number * sizeof(mach_port_name_inlined_t);
- if ((usaddr + length) > ueaddr)
- return 1;
- if (copyin((void*)usaddr, (void*)ksaddr, length))
- return 1;
- usaddr += length;
- ksaddr += length;
-#endif
}
else
{
@@ -483,13 +451,9 @@ int copyinmsg (const void *userbuf, void *kernelbuf, const size_t usize, const s
if ((usaddr + sizeof(rpc_vm_offset_t)) > ueaddr)
return 1;
- /* out-of-line port arrays are always arrays of mach_port_name_t (4 bytes)
- * and are expanded in ipc_kmsg_copyin_body() */
- if (MACH_MSG_TYPE_PORT_ANY(name)) {
- if (size != bytes_to_descsize(sizeof(mach_port_name_t)))
- return 1;
+ // out-of-line port arrays are expanded in ipc_kmsg_copyin_body()
+ if (MACH_MSG_TYPE_PORT_ANY(name))
adjust_msg_type_size(ktaddr, sizeof(mach_port_t) - sizeof(mach_port_name_t));
- }
if (copyin_address((rpc_vm_offset_t*)usaddr, (vm_offset_t*)ksaddr))
return 1;
@@ -506,10 +470,6 @@ int copyinmsg (const void *userbuf, void *kernelbuf, const size_t usize, const s
kmsg->msgh_size = sizeof(mach_msg_header_t) + ksaddr - (vm_offset_t)(kmsg + 1);
assert(kmsg->msgh_size <= ksize);
-#ifndef USER32
- if (kmsg->msgh_size != usize)
- return 1;
-#endif
return 0;
}
@@ -559,7 +519,6 @@ int copyoutmsg (const void *kernelbuf, void *userbuf, const size_t ksize)
{
if (MACH_MSG_TYPE_PORT_ANY(name))
{
-#ifdef USER32
for (int i=0; i<number; i++)
{
if (copyout_port((mach_port_t*)ksaddr, (mach_port_name_t*)usaddr))
@@ -567,18 +526,10 @@ int copyoutmsg (const void *kernelbuf, void *userbuf, const size_t ksize)
ksaddr += sizeof(mach_port_t);
usaddr += sizeof(mach_port_name_t);
}
-#else
- if (size != bytes_to_descsize(sizeof(mach_port_name_inlined_t)))
- return 1;
- const vm_size_t length = number * sizeof(mach_port_name_inlined_t);
- if (copyout((void*)ksaddr, (void*)usaddr, length))
- return 1;
- ksaddr += length;
- usaddr += length;
-#endif
}
else
{
+ // type that doesn't need change
size_t n = descsize_to_bytes(size);
if (copyout((void*)ksaddr, (void*)usaddr, n*number))
return 1;
@@ -603,10 +554,6 @@ int copyoutmsg (const void *kernelbuf, void *userbuf, const size_t ksize)
usize = sizeof(mach_msg_user_header_t) + usaddr - (vm_offset_t)(umsg + 1);
if (copyout(&usize, &umsg->msgh_size, sizeof(umsg->msgh_size)))
return 1;
-#ifndef USER32
- if (usize != ksize)
- return 1;
-#endif
return 0;