Re: [PATCH v2] elf: Make string tunables startup-only

Yury Khrustalev <[email protected]> Thu, 30 Jul 2026 14:03:04 +0100
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
On Wed, Jul 29, 2026 at 05:18:47PM -0300, Adhemerval Zanella wrote:
> A string tunable value usually references the GLIBC_TUNABLES (or alias)
> environment string, which lives in the environment block the kernel places
> on the initial stack.  That memory is owned by the application, which may
> overwrite it (e.g. setproctitle), so the reference is only safe while no
> application code has run (a value coming from the system-wide tunables
> cache is a copy instead, but the rule is applied uniformly).
> 
> This patch make the lifetime explicit and enforced without copying the value
> or allocating any memory by adding __tunable_seal_strings, which drops every
> string tunable reference once early startup is complete.
> 
> The seal is applied after the only string tunable consumer and before any
> code outside of the startup sequence runs.
> 
> Checked on aarch64-linux-gnu and x86_64-linux-gnu.  I also run the elf
> tests on powerpc64le-linux-gnu, loongarch64-linux-gnuf64, and
> s390x-linux-gnu.

LGTM. Reviewed-by: Yury Khrustalev <[email protected]>

Thanks,
Yury