From patchwork Mon May 25 21:40:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 135639 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB4504BA23F5 for ; Mon, 25 May 2026 21:40:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB4504BA23F5 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 02F904BA23E8 for ; Mon, 25 May 2026 21:40:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 02F904BA23E8 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 02F904BA23E8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779745203; cv=none; b=bgQlwL5HBGB9IZbocrkoGiMaEZpr7gP8DubMj8EMc7O+/o8ftUsjn1K5wid3zZCGQ+NYZlWlBGAn1yZUrpYYJjhLahFo48xIl9PaCfhiYrgxWMS5IJqQKEGHfUkXEDeFh5Uzr1QXFoL0BPoAUJPRIe6s2nhSn1aHLAGpOtiKNuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779745203; c=relaxed/simple; bh=Jrm4yikZXg3oSOawKei22EIiSWqeZAhG4ta+JbynNKI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=CRq1f9EqddlbcybgLg/3gBmSSnfF+N29HWI//LVvtB4TXIBhaxRI3NgicUNc0Cq3IsMCj0l/WmIPnVELb/BEPVygosHxhXQMOYbarfrodj7+KMkslVhg60cA0kyXa3bWS7OVQwJC1TEVyyNPtyIvwvCAp0XJFDP3CIqvzWfL+jU= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02F904BA23E8 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id DF598A0129; Mon, 25 May 2026 23:40:01 +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 EavezNBpVTll; Mon, 25 May 2026 23:40:01 +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 BEC1AA0120; Mon, 25 May 2026 23:40:01 +0200 (CEST) Received: from samy by end with local (Exim 4.99.2) (envelope-from ) id 1wRd1l-0000000FdYA-0t8N; Mon, 25 May 2026 23:40:01 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Diego Nieto Cid , commit-hurd@gnu.org Subject: [hurd,commited] hurd: let the root user raise its priority Date: Mon, 25 May 2026 23:40:00 +0200 Message-ID: <20260525214000.3726938-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, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_PBL, SPF_HELO_PASS, SPF_PASS, TXREP shortcircuit=no 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: Diego Nieto Cid Check for task_max_priority RPC * config.h.in: add #undef for HAVE_MACH_TASK_MAX_PRIORITY. * sysdeps/mach/configure.ac: use mach_RPC_CHECK to check for task_max_priority RPC in mach_host.defs. * sysdeps/mach/configure: regenerate file. Use task_max_priority when setpriority is called by root * sysdeps/mach/hurd/setpriority.c: clamp the prio argument to the range [-NZERO, NZERO-1] and use task_max_priority when called by root. Message-ID: <8e806c83d8d7b59b2894b4944e4ad82477ecc3cd.1779316637.git.dnietoc@gmail.com> --- config.h.in | 3 +++ sysdeps/mach/configure | 30 ++++++++++++++++++++++++++++++ sysdeps/mach/configure.ac | 2 ++ sysdeps/mach/hurd/setpriority.c | 16 +++++++++++++++- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/config.h.in b/config.h.in index b53731c393..87befaa9c6 100644 --- a/config.h.in +++ b/config.h.in @@ -170,6 +170,9 @@ /* Mach specific: define if the `vm_set_size_limit' RPC is available. */ #undef HAVE_MACH_VM_SET_SIZE_LIMIT +/* Mach specific: define if the `task_max_priority' RPC is available. */ +#undef HAVE_MACH_TASK_MAX_PRIORITY + /* Mach/i386 specific: define if the `i386_io_perm_*' RPCs are available. */ #undef HAVE_I386_IO_PERM_MODIFY diff --git a/sysdeps/mach/configure b/sysdeps/mach/configure index 0161937ab4..a725cd1c7d 100755 --- a/sysdeps/mach/configure +++ b/sysdeps/mach/configure @@ -641,6 +641,36 @@ if test $libc_cv_mach_rpc_vm_get_size_limit = yes; then fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for task_max_priority in mach_host.defs" >&5 +printf %s "checking for task_max_priority in mach_host.defs... " >&6; } +if test ${libc_cv_mach_rpc_task_max_priority+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP_TRADITIONAL "task_max_priority" >/dev/null 2>&1 +then : + libc_cv_mach_rpc_task_max_priority=yes +else case e in #( + e) libc_cv_mach_rpc_task_max_priority=no ;; +esac +fi +rm -rf conftest* + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mach_rpc_task_max_priority" >&5 +printf "%s\n" "$libc_cv_mach_rpc_task_max_priority" >&6; } +if test $libc_cv_mach_rpc_task_max_priority = yes; then + printf "%s\n" "#define HAVE_MACH_TASK_MAX_PRIORITY 1" >>confdefs.h + +fi + ac_fn_c_check_header_preproc "$LINENO" "mach/machine/ndr_def.h" "ac_cv_header_mach_machine_ndr_def_h" if test "x$ac_cv_header_mach_machine_ndr_def_h" = xyes diff --git a/sysdeps/mach/configure.ac b/sysdeps/mach/configure.ac index 237b8be937..b591e6fd9b 100644 --- a/sysdeps/mach/configure.ac +++ b/sysdeps/mach/configure.ac @@ -104,6 +104,8 @@ mach_RPC_CHECK(gnumach.defs, vm_set_size_limit, HAVE_MACH_VM_SET_SIZE_LIMIT) mach_RPC_CHECK(gnumach.defs, vm_get_size_limit, HAVE_MACH_VM_GET_SIZE_LIMIT) +mach_RPC_CHECK(mach_host.defs, task_max_priority, + HAVE_MACH_TASK_MAX_PRIORITY) AC_CHECK_HEADER(mach/machine/ndr_def.h, [dnl DEFINES="$DEFINES -DNDR_DEF_HEADER=''"], [dnl diff --git a/sysdeps/mach/hurd/setpriority.c b/sysdeps/mach/hurd/setpriority.c index 8107098991..6ee34aa1a9 100644 --- a/sysdeps/mach/hurd/setpriority.c +++ b/sysdeps/mach/hurd/setpriority.c @@ -57,11 +57,25 @@ __setpriority (enum __priority_which which, id_t who, int prio) 0, 1); } #else - prierr = __task_priority (task, NICE_TO_MACH_PRIORITY (prio), 1); + do { +#ifdef HAVE_MACH_TASK_MAX_PRIORITY + mach_port_t host = MACH_PORT_NULL; + error_t priverr = __get_privileged_ports (&host, NULL); + if (!priverr) + { + prierr = __task_max_priority (host, task, NICE_TO_MACH_PRIORITY (prio), 1, 1); + __mach_port_deallocate (__mach_task_self (), host); + if (prierr != MIG_BAD_ID) + break; + } +#endif + prierr = __task_priority (task, NICE_TO_MACH_PRIORITY (prio), 1); + } while (0); #endif __mach_port_deallocate (__mach_task_self (), task); switch (prierr) { + case KERN_NO_ACCESS: case KERN_FAILURE: ++nacces; break;