From patchwork Mon May 1 00:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Cruz X-Patchwork-Id: 1775401 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=uFyvj0BL; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q8k9v5qdbz1ydV for ; Mon, 1 May 2023 10:10:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84E97385840C for ; Mon, 1 May 2023 00:10:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84E97385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682899809; bh=UtXevhTE0R+7NCBMagQTkejLLdtrXshjs0xMRm/mp9U=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=uFyvj0BL/YUl7KLRVLGqcbxqyHVVQjVbs+woxA1MgzwZ4qmH8wqzgHIFPZsEdAtk3 BU6NLUU5DyInl7wbkTAPSrZt7wfzdW0KBcVGyvw2TrZYpgKuoptu/ssP9MNpUk11UR LeMbtPIbz91+CNK+eI3nfbgMc4bxtMJu6tuT/RkU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by sourceware.org (Postfix) with ESMTPS id C63BF3858D39 for ; Mon, 1 May 2023 00:09:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C63BF3858D39 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-55a00da4e53so20486787b3.0 for ; Sun, 30 Apr 2023 17:09:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682899792; x=1685491792; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UtXevhTE0R+7NCBMagQTkejLLdtrXshjs0xMRm/mp9U=; b=ijsxH4riNegk9l0JMg765PNotJydHun2Ur2BR6A4a7L4P0S2dRzy8oIjapJT3Z+tKk UkNsC4aNZ7qnPK/C4SwcNTpq8j0+ykEn1Ui9akP5TkGsIZNfIkNmqwAMwEfYiigfWpH6 +L+T3bhwCMycFMDU8F883buyMhQ+KcY20CgJjKV2PXAu4c9IvHKt2qF6N9FsJ1CDargm 2qxSpBnTzRs24RbZgvjpBs2qazYoY9w+AVZlYH35aLdMuY3p4IkJULEJ1aTN0Ln7C/uy rpvImZJW4CfrlxeOL0wv4oMxnfepG+7bLjuelVQoqWXbcPo+308BsjtaeaTBiW1Z/2S3 Du6A== X-Gm-Message-State: AC+VfDwetVgbijs1m2hlxOlULwN8acAZ5B3vN2wJvd8CXadzFUR2MBvh 1BXy8OHYi3KyQ2ErcJtD+M3txg0JFw== X-Google-Smtp-Source: ACHHUZ5FTMXgQWjpfjSmRXdR24keW+JR/t3QKqdfdGs1cyVcL2DiM0mrMkhYPODULtU292x3BKMdhQ== X-Received: by 2002:a0d:ef42:0:b0:539:1b13:3d64 with SMTP id y63-20020a0def42000000b005391b133d64mr10712195ywe.48.1682899792026; Sun, 30 Apr 2023 17:09:52 -0700 (PDT) Received: from jupiter.tail36e24.ts.net (dynamic-acs-24-154-253-225.zoominternet.net. [24.154.253.225]) by smtp.gmail.com with ESMTPSA id u185-20020a8184c2000000b0054640a352f2sm6918082ywf.20.2023.04.30.17.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Apr 2023 17:09:51 -0700 (PDT) Date: Sun, 30 Apr 2023 20:09:49 -0400 To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: samuel.thibault@gnu.org Subject: [PATCH glibc] Define __mig_strlen to support dynamically sized strings in hurd RPCs Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Flavio Cruz via Libc-alpha From: Flavio Cruz Reply-To: Flavio Cruz Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" We make lib{mach,hurd}user.so only call __mig_strlen which can be relocated before libc.so is relocated, similar to what is done with __mig_memcpy. --- mach/Makefile | 2 +- mach/Versions | 1 + mach/mach/mig_support.h | 1 + mach/mig_strlen.c | 26 +++++++++++++++++++++++++ sysdeps/mach/include/mach/mig_support.h | 3 ++- 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 mach/mig_strlen.c diff --git a/mach/Makefile b/mach/Makefile index 39358fdb83..a5d1252f95 100644 --- a/mach/Makefile +++ b/mach/Makefile @@ -25,7 +25,7 @@ headers = mach_init.h mach.h mach_error.h mach-shortcuts.h mach/mach_traps.h \ lock = spin-solid spin-lock mutex-init mutex-solid lock-headers = lock-intern.h spin-lock.h routines = $(mach-syscalls) $(mach-shortcuts) \ - mach_init mig_strncpy mig_memcpy msg \ + mach_init mig_strncpy mig_strlen mig_memcpy msg \ mig-alloc mig-dealloc mig-reply \ msg-destroy msgserver \ mach_error errstring error_compat errsystems \ diff --git a/mach/Versions b/mach/Versions index b525cfdcf9..72e9d557db 100644 --- a/mach/Versions +++ b/mach/Versions @@ -71,5 +71,6 @@ libc { GLIBC_PRIVATE { # functions used by RPC stubs __mig_memcpy; + __mig_strlen; } } diff --git a/mach/mach/mig_support.h b/mach/mach/mig_support.h index 78d4c4f0e3..c43fa953f8 100644 --- a/mach/mach/mig_support.h +++ b/mach/mach/mig_support.h @@ -55,5 +55,6 @@ extern vm_size_t mig_strncpy (char *__dst, const char *__src, vm_size_t __len); extern vm_size_t __mig_strncpy (char *__dst, const char *__src, vm_size_t); extern void *__mig_memcpy (void *__dst, const void *__src, vm_size_t __len); +extern vm_size_t __mig_strlen (const char *__src); #endif /* mach/mig_support.h */ diff --git a/mach/mig_strlen.c b/mach/mig_strlen.c new file mode 100644 index 0000000000..3c5ef8db15 --- /dev/null +++ b/mach/mig_strlen.c @@ -0,0 +1,26 @@ +/* strlen stub for mig stubs in libmachuser and libhurduser. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +vm_size_t +__mig_strlen (const char *src) +{ + return strlen (src); +} diff --git a/sysdeps/mach/include/mach/mig_support.h b/sysdeps/mach/include/mach/mig_support.h index 1888d481d2..242f310a9c 100644 --- a/sysdeps/mach/include/mach/mig_support.h +++ b/sysdeps/mach/include/mach/mig_support.h @@ -9,10 +9,11 @@ libc_hidden_proto (__mig_init) # include # if defined USE_MULTIARCH && (IS_IN (libmachuser) || IS_IN (libhurduser)) -/* Avoid directly calling ifunc-enabled memcpy or strpcpy, +/* Avoid directly calling ifunc-enabled memcpy or strlen, because they would introduce a relocation loop between lib*user and libc.so. */ # define memcpy(dest, src, n) __mig_memcpy(dest, src, n) +# define strlen(src) __mig_strlen(src) # endif #endif