From patchwork Sat Dec 18 20:27:43 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: 49091 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 70641385842D for ; Sat, 18 Dec 2021 20:28:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70641385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639859287; bh=KwbC7h9ONCLXNHp70xfbJTZa/e9Tq3FE1Gn+vo6JsOw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WMHExJqgoKpLsQSQeXt07E/jXL1GRqidv6kDQoKnSavmJwvfImg7ocUpWyFizslcb OfxWB78XXb8KDClOysoYSZOlgZ7LP6QoashsoBV6Vku6kCUGHS7zV4dhwqYK7hO5RE frdFdWzkPweLzYcVyQn7ZOYssWagxNlWcv9cFuS0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by sourceware.org (Postfix) with ESMTPS id 7597F3858D28 for ; Sat, 18 Dec 2021 20:27:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7597F3858D28 Received: by mail-pj1-x1033.google.com with SMTP id f18-20020a17090aa79200b001ad9cb23022so6156041pjq.4 for ; Sat, 18 Dec 2021 12:27:46 -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=KwbC7h9ONCLXNHp70xfbJTZa/e9Tq3FE1Gn+vo6JsOw=; b=SPbn77mtWkapw0jMVUFCk97W9CQAl331mJ1QeKWhuuotl6awlbJu7S60YxVuIMXa7T WJDqKNPBtI25Kbm5hOHnksBvBki9oMEN0MC6NaBplHG2fGInTNG/7FVGtHJcsPGFN3Ml aGGw6Ah1+Q/Oveq4u3BarIslwqsiD3ls9S1xXfV3OhrJ/7vsnSZ4vWPT/MZNmYjOixcZ pu9ColtNxuY8d25mqfbpBkdNBhfX62pcB6tOf4QVo9HK5rS8VWclX0oFaxTebnaJlWv0 2YDnmqUGogw5Iy7AV3mEitsaJl85oU8vQk8fyWwNGInLGUey0O/v9fMw5U+yaHP5D/FW n8Og== X-Gm-Message-State: AOAM533i6Oh5acfX/9kadDhP7FheyLt8KzKx40x7f44vg+C6VdLVgg9E /HqjGypxd91X4G9DN8wZ2I7vu12gFGY= X-Google-Smtp-Source: ABdhPJwbDv9/QiyNKxAajXJv3WvoqzEcFu5ZW6lFhzxscmbsTTyzGf1kqsrM6+MvIb1LrSusEDCb9A== X-Received: by 2002:a17:90a:4414:: with SMTP id s20mr19256458pjg.132.1639859265363; Sat, 18 Dec 2021 12:27:45 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.133]) by smtp.gmail.com with ESMTPSA id o124sm13217971pfb.177.2021.12.18.12.27.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Dec 2021 12:27:45 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id F12FDC0398 for ; Sat, 18 Dec 2021 12:27:43 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2] elf: Inline do_tunable_update_val/tunable_initialize [BZ #28712] Date: Sat, 18 Dec 2021 12:27:43 -0800 Message-Id: <20211218202743.3105160-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" Changes in v2: 1. Replace inline with __always_inline. 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..02402e2990 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 __always_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 __always_inline tunable_initialize (tunable_t *cur, const char *strval) { tunable_val_t val;