From patchwork Sat Dec 18 20:02:07 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: 49090 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 60F453858407 for ; Sat, 18 Dec 2021 20:02:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60F453858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639857752; bh=WVcLp2FdxN0jZy/r/j6VNjfY8hg36U5YQqeS7RWshYc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tnchgRvbyO5JwDDJCLYQPxm8tpAPaHN8K8gNT+piFD1B/CRnjJSNIoNoHIyJ4O2CS vPHmP4QtaQW/ZzCRo1gSuHx1O/pEDeInM/UNyBqeG+5rFvZ0OpN2+GcI9de6ovG4Pe 5ilmwdl8cM86ENubDVM0d0Db8KI+Ct9szShvFlUQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id A268B3858D28 for ; Sat, 18 Dec 2021 20:02:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A268B3858D28 Received: by mail-pj1-x1035.google.com with SMTP id c22-20020a17090a109600b001b101f02dd1so8927782pja.5 for ; Sat, 18 Dec 2021 12:02:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=WVcLp2FdxN0jZy/r/j6VNjfY8hg36U5YQqeS7RWshYc=; b=FmoYK+s+8ZY4I7Yq2FR9mz2YNv60pyI8fgxxMx9pY2v2Y0Pc9TyuhU9mC0FiawzMOC efURBXZnYTltSdPjoBz3+iHpaBUePlEoPQsHSrDd61Dq6mOCC5HBbehergCWae/v6VYW WG1fEdm7Pk8sSmJAHLtSGdPL8g/IibpP3ZQlf5KH1llUhlhf18GVnRMBvJtdZ/mNFQpf Z8AK5UPZUARbqTdWsXyg7X099ZiaaDLrKhXCB+ykfeirDPoPZLgSCvDIioyDz6DxyfmJ Ezkgnyg+bABpuo1kD4l52XkIjj61G+zpStxOGb07l56HvQN498CYpYdPgVEBoSuMDtAR 8TGw== X-Gm-Message-State: AOAM532DiJYwDoBQmpGJdC7j62vBloat6pj0KYna30aUOnlNKF+M4uV0 r71/+lpMkdxRBAkzwKqzutYhE6xcxQ4= X-Google-Smtp-Source: ABdhPJytFKEQRBu9PLKHbOxGrErjVYshqOuWa4qr7aevZ8zCS8ZTyXjZuZyPRYY9eOzmTPSngjcUGw== X-Received: by 2002:a17:90b:4b03:: with SMTP id lx3mr10874015pjb.18.1639857729524; Sat, 18 Dec 2021 12:02:09 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.133]) by smtp.gmail.com with ESMTPSA id j190sm11799305pge.70.2021.12.18.12.02.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Dec 2021 12:02:09 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id E68C2C0692 for ; Sat, 18 Dec 2021 12:02:07 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH] elf: Inline do_tunable_update_val/tunable_initialize [BZ #28712] Date: Sat, 18 Dec 2021 12:02:07 -0800 Message-Id: <20211218200207.3034783-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3029.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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" Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" In static PIE, __tunables_init is called before _dl_relocate_static_pie in LIBC_START_MAIN in csu/libc-start.c: __tunables_init (__environ); ARCH_INIT_CPU_FEATURES (); /* Do static pie self relocation after tunables and cpu features are setup for ifunc resolvers. Before this point relocations must be avoided. */ _dl_relocate_static_pie (); /* Perform IREL{,A} relocations. */ ARCH_SETUP_IREL (); Inline do_tunable_update_val and tunable_initialize to prevent compiler from generating dynamic relocation against tunable_list which causes __tunables_init to fail in static PIE on x86-64: FAIL: elf/tst-env-setuid since .L35: movq $-88, %rax subq .LC3(%rip), %rax ^^^^ This is executed before the .LC3 entry has been relocated. movq %rax, 8(%rsp) ... .section .data.rel.ro.local,"aw" .align 8 .LC3: .quad tunable_list Tested on x86-64, x32 and i686 with GCC 11 and GCC 12. This fixes BZ #28712. --- elf/dl-tunables.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index 497e948f1c..294ad81200 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -92,7 +92,7 @@ get_next_env (char **envp, char **name, size_t *namelen, char **val, return NULL; } -static void +static void inline do_tunable_update_val (tunable_t *cur, const tunable_val_t *valp, const tunable_num_t *minp, const tunable_num_t *maxp) @@ -139,7 +139,7 @@ do_tunable_update_val (tunable_t *cur, const tunable_val_t *valp, /* Validate range of the input value and initialize the tunable CUR if it looks good. */ -static void +static void inline tunable_initialize (tunable_t *cur, const char *strval) { tunable_val_t val;