|
|
Log in / Subscribe / Register

Additional hardening for the glibc dynamic linker

By Daroc Alden
November 11, 2026

The Node.js project recently had a security vulnerability that affected its Brotli decoder. The bug was a buffer overflow, but the particular way that official Node.js binaries are built for Linux meant that one of the main protections against turning a buffer overflow into remote code execution, address space layout randomization (ASLR) could not be turned on. If ASLR had been enabled, the bug would still be exploitable in theory, but much more difficult to exploit in practice. In response, the GNU C Library (glibc) is considering a new set of tunable settings to allow administrators to forbid programs that do not support ASLR. The new settings, while a welcome hardening measure, may not address the root problem.

Background

When a program contains a buffer overflow, it is frequently possible to use that buffer overflow to take control of the program's execution, turning a data-corruption bug into a remote-code-execution vulnerability. Generally, this is done by overwriting a pointer that the program later jumps to, redirecting the program's flow of control to an attacker-chosen address. From there, it is straightforward to, for example, call execv() with attacker-controlled arguments. The pointer that is overwritten is often a return address on the stack, but similar attacks have been demonstrated with callbacks, indirect jumps within a function, and C++ virtual method tables.

There are many mitigations intended to make this more difficult for attackers, including control-flow integrity, shadow stacks, and even tweaking code generation to reduce the number of useful places to jump to. ASLR is arguably the simplest such mitigation. It uses the fact that modern compilers can emit relocatable code to place the program in a randomly chosen part of virtual memory. Attackers wishing to overwrite a function pointer must figure out the program's base address in order to divert control flow anywhere useful.

Compiling to position-independent code does have an impact: such code is often slightly larger and slightly slower than position-dependent code. In 2020, Node.js contributor "woodfairy" measured the impact on Node.js in particular at a slowdown of 5-10%, depending on workload. That slowdown was judged acceptable on macOS, but not on Linux (except for Android, which forbids position-dependent code, forcing the choice).

Several Linux distributions, including Debian, Ubuntu, Arch, Alpine, and Gentoo, enable position-independent executables by default. On those distributions, compiling Node.js from source or installing the distribution packages will enable ASLR. The official Node.js binary packages, which are compiled on a system running Red Hat Enterprise Linux 8, still do not.

Dynamic linking

Dynamically linked programs rely on the dynamic linker to initialize a new process. On Linux, the linker is typically provided by the glibc project, although there are distributions that make other arrangements. That linker supports configuration options known as tunables to affect its operation. These can be set by environment variables, or system-wide in a file at /etc/tunables.conf.

On October 26, Daniel Colascione asked the glibc development mailing list whether it made sense to add a new tunable that would forbid position-dependent executables. Adhemerval Zanella Netto responded with a list of hardening-related tunables that he hoped to implement, saying that they were all on his to-do list. He also suggested adding a single glibc.hardened tunable to enable all of them as a batch, similar to GCC's -fhardened option.

Zack Weinberg noted that, because most fixed-position executables are linked at low addresses, users can ask the kernel to refuse them by setting the minimum mmap() address (the vm.mmap_min_addr sysctl) to a higher number. He did note there were some problems with the idea, and Maciej Rozycki pointed out more.

Zanella posted the implementation of his promised tunables on October 28. The project's default behavior remains the same, but each option can be set to 0 or 1 (depending on its wording) to enable the new protections. The new options include:

  • glibc.rtld.require_pie=1, which requires loaded programs to be position-independent.
  • glibc.rtld.textrel=0, which forbids programs that ask the linker to perform a relocation targeting a section of the executable that is not mapped as writable.
  • glibc.rtld.wx_segments=0, which forbids programs that ask for some segments to be mapped as both writable and executable at startup.
  • glibc.rtld.bind_now=1, which disables the use of lazy global offset table resolution (equivalent to the use of the LD_BIND_NOW environment variable).
  • glibc.rtld.relative_rpath=0, which prevents dynamic libraries from being found via relative paths.
  • glibc.rtld.relro={1,2}, which requires the use of relocation read-only (RELRO) or -z now, respectively.

All six of the options can be set to the hardened behavior at once with glibc.rtld.hardened=1. Yury Khrustalev found many of the names overly terse, and suggested that longer names, such as allow_textrel, might be clearer. Zanella agreed to elongate them in the next version of the patch set.

The changes themselves drew little comment. Most of them should be possible for distributions to enable with minimal disruption. In particular, the distributions that already enable position-independent executables by default can enable the tunables without impacting any distribution packages. The more difficult problem will come from executables built outside the distribution. Unless widespread adoption of these tunables motivates projects like Node.js to abandon position-dependent code, users may need to disable the tunables for those programs that the tunables are intended to address.


Index entries for this article
SecurityDynamic linking


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds