From patchwork Wed Apr 1 23:05:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 132601 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 138DC4BA23C7 for ; Wed, 1 Apr 2026 23:05:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 138DC4BA23C7 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 943784BA2E2A for ; Wed, 1 Apr 2026 23:05:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 943784BA2E2A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 943784BA2E2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775084716; cv=none; b=u5Voqgy98ur6YMUqgshCuhEtU3RWiBtn+U9NewUtxWelVqvzUc3afFhttQ7IxqU2/8x6LXCcgPY2sJd+F8DHKrkZIO+CKYt335k8vzltaqjJdJo7ca2xKlshKzeAfKCEiMGAmKa9cKqIediSxCgnQVq+/qGezo2CDEWBar708uA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775084716; c=relaxed/simple; bh=YO0AmN+/9+RXTCFowQeqnyf5voBgNT3bNh3kZZ/usko=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=mOYlH6Wt7pbGUNYVwOyLttwT54ozwn0Umb0kGM9rJNPAt2g/jkKmf7CHlRVtehuv/N3YEov4Rq77Fok3RF1SoF7v43SysY3PDrIPo39+Z4yl52o+gtYKn4XjLDd6H/YjeqXx5M+jaVSzkMt3l5zXuU3Nr6wPjPGiXBGpvYksqvA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 943784BA2E2A Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 615C6A49BC; Thu, 2 Apr 2026 01:05:15 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nt0S5Ha4L4qi; Thu, 2 Apr 2026 01:05:15 +0200 (CEST) Received: from end (aamiens-653-1-40-48.w83-192.abo.wanadoo.fr [83.192.199.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 28A7FA47DD; Thu, 2 Apr 2026 01:05:15 +0200 (CEST) Received: from samy by end with local (Exim 4.99.1) (envelope-from ) id 1w84cc-00000001Khl-2kKF; Thu, 02 Apr 2026 01:05:14 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Mike Kelly , commit-hurd@gnu.org Subject: [hurd, commited] hurd: alterations to MSG_EXAMINE interface (intr-msg.h) Date: Thu, 2 Apr 2026 01:05:13 +0200 Message-ID: <20260401230513.317910-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: Mike Kelly 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 | 15 ++++++++++++- sysdeps/mach/hurd/i386/intr-msg.h | 35 ++++++++++++++--------------- sysdeps/mach/hurd/x86_64/intr-msg.h | 19 +++++++--------- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/hurd/report-wait.c b/hurd/report-wait.c index 3f141345f4..703482c6cc 100644 --- a/hurd/report-wait.c +++ b/hurd/report-wait.c @@ -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 diff --git a/sysdeps/mach/hurd/i386/intr-msg.h b/sysdeps/mach/hurd/i386/intr-msg.h index e8acf63bd0..5b9a35d526 100644 --- a/sysdeps/mach/hurd/i386/intr-msg.h +++ b/sysdeps/mach/hurd/i386/intr-msg.h @@ -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; \ }) diff --git a/sysdeps/mach/hurd/x86_64/intr-msg.h b/sysdeps/mach/hurd/x86_64/intr-msg.h index 82cc78eeb5..6f0ea90ded 100644 --- a/sysdeps/mach/hurd/x86_64/intr-msg.h +++ b/sysdeps/mach/hurd/x86_64/intr-msg.h @@ -92,27 +92,24 @@ /* 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; \