]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: alterations to MSG_EXAMINE interface (intr-msg.h)
authorMike Kelly <mike@weatherwax.co.uk>
Wed, 1 Apr 2026 19:49:32 +0000 (20:49 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 1 Apr 2026 23:04:40 +0000 (01:04 +0200)
MSG_EXAMINE has been broadened to allow the signal thread (for
example) to access additional arguments that are passed to
interruptible RPCs in other threads. All architecture specific
variants of intr-msg.h now comply with the revised interface and the
single user of MSG_EXAMINE (report-wait.c) adjusted accordingly.
Message-ID: <20260401194948.90428-2-mike@weatherwax.co.uk>

hurd/report-wait.c
sysdeps/mach/hurd/i386/intr-msg.h
sysdeps/mach/hurd/x86_64/intr-msg.h

index 3f141345f4a19eeb8c4d333b96ffb11cf8785a83..703482c6cce4fe9c06db6982d037688961a6ab4b 100644 (file)
@@ -155,16 +155,29 @@ _S_msg_report_wait (mach_port_t msgport, thread_t thread,
          assert (count == MACHINE_THREAD_STATE_COUNT);
          if (SYSCALL_EXAMINE (&state, msgid))
            {
+             mach_msg_header_t* msghdr;
              mach_port_t send_port, rcv_port;
+             mach_msg_size_t rcv_sz;
              mach_msg_option_t option;
              mach_msg_timeout_t timeout;
 
              /* Blocked in a system call.  */
              if (*msgid == -25
                  /* mach_msg system call.  Examine its parameters.  */
-                 && MSG_EXAMINE (&state, msgid, &rcv_port, &send_port,
+                 && MSG_EXAMINE (&state, &msghdr, &rcv_port, &rcv_sz,
                                  &option, &timeout) == 0)
                {
+                 if (msghdr != NULL)
+                   {
+                     send_port = msghdr->msgh_remote_port;
+                     *msgid = msghdr->msgh_id;
+                   }
+                 else
+                   {
+                     send_port = MACH_PORT_NULL;
+                     *msgid = 0;
+                   }
+
                  if (send_port != MACH_PORT_NULL && *msgid != 0)
                    {
                      /* For the normal case of RPCs, we consider the
index e8acf63bd0e1cac7cbd9f2aa186ab3a599f701af..5b9a35d526775eae334871826b6a547d0f3e11fd 100644 (file)
@@ -106,30 +106,29 @@ struct mach_msg_trap_args
 
 
 /* This cannot be an inline function because it calls setjmp.  */
-#define MSG_EXAMINE(state, msgid, rcvname, send_name, opt, tmout)            \
+#define MSG_EXAMINE(state, msghdr, rcvname, rcvsz, opt, tmout)               \
 ({                                                                           \
   const struct mach_msg_trap_args *args = (const void *) (state)->uesp;              \
-  mach_msg_header_t *msg;                                                    \
-  _hurdsig_catch_memory_fault (args) ? -1 :                                  \
-    ({                                                                       \
-      msg = args->msg;                                                       \
+  int ret = _hurdsig_catch_memory_fault (args) ? -1 : 0;                     \
+  if (ret == 0)                                                                      \
+    {                                                                        \
+      mach_msg_header_t *msg = args->msg;                                    \
+      *(msghdr) = msg;                                                       \
       *(opt) = args->option;                                                 \
       *(tmout) = args->timeout;                                                      \
       *(rcvname) = args->rcv_name;                                           \
+      *(rcvsz) = args->rcv_size;                                             \
       _hurdsig_end_catch_fault ();                                           \
-      if (msg == 0)                                                          \
+      if (msg != NULL)                                                       \
        {                                                                     \
-         *(send_name) = MACH_PORT_NULL;                                      \
-         *(msgid) = 0;                                                       \
+         ret = _hurdsig_catch_memory_fault (msg) ? -1 : 0;                   \
+         if (ret == 0)                                                       \
+           {                                                                 \
+             /* Access memory at msg to ensure validity */                   \
+             *((volatile mach_msg_id_t *) &msg->msgh_id) = msg->msgh_id;     \
+             _hurdsig_end_catch_fault ();                                    \
+           }                                                                 \
        }                                                                     \
-      else                                                                   \
-       {                                                                     \
-         if (_hurdsig_catch_memory_fault (msg))                              \
-           return -1;                                                        \
-         *(send_name) = msg->msgh_remote_port;                               \
-         *(msgid) = msg->msgh_id;                                            \
-         _hurdsig_end_catch_fault ();                                        \
-       }                                                                     \
-      0;                                                                     \
-    });                                                                              \
+    }                                                                        \
+    ret;                                                                     \
 })
index 82cc78eeb5b43ed3440d5b463e58f09f264fc190..6f0ea90ded170c236d0d217cac08410f2e618bf9 100644 (file)
 
 
 /* This cannot be an inline function because it calls setjmp.  */
-#define MSG_EXAMINE(state, msgid, rcvname, send_name, opt, tmout)            \
+#define MSG_EXAMINE(state, msghdr, rcvname, rcvsz, opt, tmout)               \
 ({                                                                           \
   int ret = 0;                                                               \
   const struct machine_thread_state *s = (state);                            \
-  const mach_msg_header_t *msg = (const void *) s->rdi;                              \
+  mach_msg_header_t *msg = (void *) s->rdi;                                  \
+  *(msghdr) = msg;                                                           \
   *(rcvname) = s->r8;                                                        \
   *(opt) = s->rsi;                                                           \
   *(tmout) = s->r9;                                                          \
-  if (msg == 0)                                                                      \
-    {                                                                        \
-      *(send_name) = MACH_PORT_NULL;                                         \
-      *(msgid) = 0;                                                          \
-    }                                                                        \
-  else                                                                       \
+  *(rcvsz) = s->r10;                                                         \
+  if (msg != NULL)                                                           \
     {                                                                        \
       ret = _hurdsig_catch_memory_fault (msg) ? -1 : 0;                              \
       if (ret == 0)                                                          \
         {                                                                    \
-          *(send_name) = msg->msgh_remote_port;                                      \
-          *(msgid) = msg->msgh_id;                                           \
-          _hurdsig_end_catch_fault ();                                       \
+           /* Access memory at msg to ensure validity */                     \
+           *((volatile mach_msg_id_t *) &msg->msgh_id) = msg->msgh_id;       \
+           _hurdsig_end_catch_fault ();                                      \
        }                                                                     \
     }                                                                        \
   ret;                                                                       \