From: "H.J. Lu" <hjl.tools@gmail.com>
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 [thread overview]
Message-ID: <20211218202743.3105160-1-hjl.tools@gmail.com> (raw)
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;
--
2.33.1
next reply other threads:[~2021-12-18 20:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-18 20:27 H.J. Lu [this message]
2021-12-18 22:46 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211218202743.3105160-1-hjl.tools@gmail.com \
--to=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).