From patchwork Fri Dec 31 17:23:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 49441 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1C7503858002 for ; Fri, 31 Dec 2021 17:23:35 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by sourceware.org (Postfix) with ESMTPS id 1FE913858D39 for ; Fri, 31 Dec 2021 17:23:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1FE913858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 178D5287; Fri, 31 Dec 2021 18:23:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LJv58Ycs4H8Q; Fri, 31 Dec 2021 18:23:19 +0100 (CET) Received: from begin.home (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id E8FC5C4; Fri, 31 Dec 2021 18:23:18 +0100 (CET) Received: from samy by begin.home with local (Exim 4.95) (envelope-from ) id 1n3Lcb-006fN1-Mn; Fri, 31 Dec 2021 18:23:17 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited] hurd: Avoid overzealous shared objects constraints Date: Fri, 31 Dec 2021 18:23:17 +0100 Message-Id: <20211231172317.1588988-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spamd-Bar: ++++ X-Rspamd-Server: hera Authentication-Results: hera.aquilenet.fr; none X-Rspamd-Queue-Id: 178D5287 X-Spamd-Result: default: False [4.90 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[] X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 407765e9f24f ("hurd: Fix ELF_MACHINE_USER_ADDRESS_MASK value") switched ELF_MACHINE_USER_ADDRESS_MASK from 0xf8000000UL to 0xf0000000UL to let libraries etc. get loaded at 0x08000000. But ELF_MACHINE_USER_ADDRESS_MASK is actually only meaningful for the main program anyway, so keep it at 0xf8000000UL to prevent the program loader from putting ld.so beyond 0x08000000. And conversely, drop the use of ELF_MACHINE_USER_ADDRESS_MASK for shared objects, which don't need any constraints since the program will have already be loaded by then. --- sysdeps/i386/dl-machine.h | 2 +- sysdeps/mach/hurd/dl-sysdep.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 2f0dbc27a9..b5a5dd0983 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -117,7 +117,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], /* Mask identifying addresses reserved for the user program, where the dynamic linker should not map anything. */ -#define ELF_MACHINE_USER_ADDRESS_MASK 0xf0000000UL +#define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL /* Initial entry point code for the dynamic linker. The C function `_dl_start' is the real entry point; diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 968a58f668..b1a151abc1 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -476,7 +476,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) mapaddr = (vm_address_t) addr; err = __vm_map (__mach_task_self (), - &mapaddr, (vm_size_t) len, ELF_MACHINE_USER_ADDRESS_MASK, + &mapaddr, (vm_size_t) len, 0, !(flags & MAP_FIXED), memobj_rd, (vm_offset_t) offset, @@ -491,7 +491,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) if (! err) err = __vm_map (__mach_task_self (), &mapaddr, (vm_size_t) len, - ELF_MACHINE_USER_ADDRESS_MASK, + 0, !(flags & MAP_FIXED), memobj_rd, (vm_offset_t) offset, flags & (MAP_COPY|MAP_PRIVATE),