]> sourceware.org Git - glibc.git/commitdiff
Update code to handle the new ABI for sending inlined port rights.
authorFlavio Cruz <flaviocruz@gmail.com>
Thu, 14 Dec 2023 06:02:28 +0000 (01:02 -0500)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 17 Dec 2023 22:48:37 +0000 (23:48 +0100)
For i686, this change is no op but for x86_64 it forces all inlined port
rights to be 8 bytes long.

hurd/intr-msg.c
mach/msg-destroy.c

index 24184f827f90f36f77909773ee7ab0f815509c73..9912f4f1f366f230af6b235dbb0ba077e514ecdf 100644 (file)
@@ -199,6 +199,28 @@ _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg,
                    __vm_deallocate (__mach_task_self (), (vm_address_t) data, length);
                }
 
+             inline void clean_inlined_ports (mach_port_name_inlined_t *ports)
+               {
+                 mach_msg_type_number_t i;
+                 switch (name)
+                   {
+                   case MACH_MSG_TYPE_MOVE_SEND:
+                     for (i = 0; i < number; i++)
+                       __mach_port_deallocate (__mach_task_self (), ports[i].name);
+                     if (ty->msgtl_header.msgt_longform)
+                       ty->msgtl_name = MACH_MSG_TYPE_COPY_SEND;
+                     else
+                       ty->msgtl_header.msgt_name = MACH_MSG_TYPE_COPY_SEND;
+                     break;
+                   case MACH_MSG_TYPE_COPY_SEND:
+                   case MACH_MSG_TYPE_MOVE_RECEIVE:
+                     break;
+                   default:
+                     if (MACH_MSG_TYPE_PORT_ANY (name))
+                       assert (! "unexpected port type in interruptible RPC");
+                   }
+               }
+
              char *data;
              if (ty->msgtl_header.msgt_longform)
                {
@@ -215,11 +237,11 @@ _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg,
                  data = (char *) ty + sizeof (mach_msg_type_t);
                }
 
+             /* Calculate length of data in bytes.  */
              const vm_size_t length = ((number * size) + 7) >> 3;
              if (ty->msgtl_header.msgt_inline)
                {
-                 /* Calculate length of data in bytes.  */
-                 clean_ports_and_memory (data, length, 0);
+                 clean_inlined_ports ((mach_port_name_inlined_t *) data);
                  /* Move to the next argument.  */
                  ty = (void *) PTR_ALIGN_UP (data + length, __alignof__ (uintptr_t));
                }
index 19137baa6226d0a5b7f6a2bbcc3ee99f7e84c55b..8640c965bd6722a8f505c669ec989e2226899ec7 100644 (file)
@@ -108,11 +108,17 @@ __mach_msg_destroy (mach_msg_header_t *msg)
            addr = is_inline ? saddr : * (vm_offset_t *) saddr;
 
            if (MACH_MSG_TYPE_PORT_ANY(name)) {
-               mach_port_t *ports = (mach_port_t *) addr;
                mach_msg_type_number_t i;
 
-               for (i = 0; i < number; i++)
-                   mach_msg_destroy_port(*ports++, name);
+               if (is_inline) {
+                   mach_port_name_inlined_t *inlined_ports = (mach_port_name_inlined_t *)addr;
+                   for (i = 0; i < number; i++)
+                       mach_msg_destroy_port(inlined_ports[i].name, name);
+               } else {
+                   mach_port_t *ports = (mach_port_t *) addr;
+                   for (i = 0; i < number; i++)
+                       mach_msg_destroy_port(ports[i], name);
+               }
            }
 
            if (is_inline) {
This page took 0.044008 seconds and 5 git commands to generate.