From patchwork Thu Sep 23 16:14:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 45367 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 023D03857C52 for ; Thu, 23 Sep 2021 16:14:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 023D03857C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1632413690; bh=trfJ8gi8MLFO8adwcLT8bMdxDWTpa3BwAlxy/p0wIFc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=DnnSW/ITRPfSGqOXqnryVxLjssr+wupAnJPk4gHmqaNF0J+YVqnSiKU34oB0XX6Gi n0L+FZPrRsc8MELuNowCEObNZl5OPdbkAjodpCPSa1ateqNFrCVzlmG4WcqA6NN0Ds AgAm8Ig+8M2lM4MIQe81LWyV0gxt3VxnbtXqXAhE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 884E3385802A for ; Thu, 23 Sep 2021 16:14:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 884E3385802A Received: by mail-pg1-x535.google.com with SMTP id 17so6841001pgp.4 for ; Thu, 23 Sep 2021 09:14:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=trfJ8gi8MLFO8adwcLT8bMdxDWTpa3BwAlxy/p0wIFc=; b=x713Q6LMOLUpWAkIl1lDRtrakiIqs0Yt3z4pu/0hUfAbQtKh1ac+Fk2xJrIraBBPRL zvMB5SdUrk4acZnurDmpkOuXZZbsu6ncyLiNDwttNz4BqPJrAQzuFtVrfJxygPX7IsRZ GXKbN3stC2c0piV2gRuki+OMAjQcJB5H3r5669EQX2gB3Q7c5oleS6u2M3QyuIWmt6uU BW5R07Ze2VdrTpXaBRfnUmxR3w9G7VqpDN4IB+Y+zy+t4elNNH0ZZ/OB4SOaRSmzYSTb 4vxXdfEOwpgsG+oHVrz3Nj4brwzWNGfvICglxmjs2NagOAvdsrQXM9WIFEZ73ri4bsX9 YIpQ== X-Gm-Message-State: AOAM53313aC26ECdvFsNbxIhpaALFO5a09jaNRG1jjbnvXgzbgswkIt9 ixfvE5TBnre8HaFEl3Fjc+R+hj/yQ48= X-Google-Smtp-Source: ABdhPJwEAVHPzyxXdyWrf0AgEEXxs9TdisCaiwSX66XbXglMt/yy0pXXprBvu1DPnwg1HPsU4eFaTw== X-Received: by 2002:aa7:83d8:0:b0:3ef:990f:5525 with SMTP id j24-20020aa783d8000000b003ef990f5525mr5360405pfn.29.1632413668263; Thu, 23 Sep 2021 09:14:28 -0700 (PDT) Received: from gnu-gram-1.localdomain (2603-800c-230f-d241-0000-0000-0000-112a.res6.spectrum.com. [2603:800c:230f:d241::112a]) by smtp.gmail.com with ESMTPSA id a10sm7316760pgd.91.2021.09.23.09.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 09:14:27 -0700 (PDT) Received: from gnu-gram-1.localdomain (localhost [IPv6:::1]) by gnu-gram-1.localdomain (Postfix) with ESMTP id 564A6E0072; Thu, 23 Sep 2021 09:14:26 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] ld.so: Initialize bootstrap_map.l_ld_readonly [BZ #28340] Date: Thu, 23 Sep 2021 09:14:18 -0700 Message-Id: <20210923161418.1491862-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3032.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Before calling elf_get_dynamic_info to get dynamic info in bootstrap_map, initalize bootstrap_map.l_ld_readonly with BOOTSTRAP_MAP_RO_DYN_SECTION. This updates BZ #28340 fix. --- elf/rtld.c | 1 + sysdeps/generic/dl-relocate-ld.h | 3 +++ sysdeps/mips/dl-relocate-ld.h | 3 +++ sysdeps/riscv/dl-relocate-ld.h | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/elf/rtld.c b/elf/rtld.c index 8d2bba3d43..27e9f12560 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -547,6 +547,7 @@ _dl_start (void *arg) /* Read our own dynamic section and fill in the info array. */ bootstrap_map.l_ld = (void *) bootstrap_map.l_addr + elf_machine_dynamic (); + bootstrap_map.l_ld_readonly = BOOTSTRAP_MAP_RO_DYN_SECTION; elf_get_dynamic_info (&bootstrap_map); #if NO_TLS_OFFSET != 0 diff --git a/sysdeps/generic/dl-relocate-ld.h b/sysdeps/generic/dl-relocate-ld.h index 5fae206db9..09c7ba0448 100644 --- a/sysdeps/generic/dl-relocate-ld.h +++ b/sysdeps/generic/dl-relocate-ld.h @@ -19,6 +19,9 @@ #ifndef _DL_RELOCATE_LD_H #define _DL_RELOCATE_LD_H +/* The dynamic section in bootstrap_map is writable. */ +#define BOOTSTRAP_MAP_RO_DYN_SECTION 0 + /* Return true if dynamic section in the shared library L should be relocated. */ diff --git a/sysdeps/mips/dl-relocate-ld.h b/sysdeps/mips/dl-relocate-ld.h index 0c18d9a567..2c4edbe9f4 100644 --- a/sysdeps/mips/dl-relocate-ld.h +++ b/sysdeps/mips/dl-relocate-ld.h @@ -19,6 +19,9 @@ #ifndef _DL_RELOCATE_LD_H #define _DL_RELOCATE_LD_H +/* The dynamic section in bootstrap_map is readonly. */ +#define BOOTSTRAP_MAP_RO_DYN_SECTION 1 + /* Return true if dynamic section in the shared library L should be relocated. */ diff --git a/sysdeps/riscv/dl-relocate-ld.h b/sysdeps/riscv/dl-relocate-ld.h index 10327454b1..240f85b79e 100644 --- a/sysdeps/riscv/dl-relocate-ld.h +++ b/sysdeps/riscv/dl-relocate-ld.h @@ -19,6 +19,10 @@ #ifndef _DL_RELOCATE_LD_H #define _DL_RELOCATE_LD_H +/* The dynamic section in bootstrap_map is writable. This is ignored + on RISC-V. */ +#define BOOTSTRAP_MAP_RO_DYN_SECTION 0 + /* Return true if dynamic section in the shared library L should be relocated. */