glibc/elf/dl-mseal-mode.h
Adhemerval Zanella 6a785f1dcf elf: Add support to memory sealing
The new Linux mseal syscall allows seal memory mappings to avoid
further changes such as memory protection or remap.  The sealing
is done in multiple places where the memory is supposed to
be immutable over program execution:

  * All shared library dependencies from the binary, including the
    read-only segments after PT_GNU_RELRO setup.

  * The binary itself, including dynamic and static links.  In both
    It is up either to binary or the loader to set up the sealing.

  * Any preload libraries.

  * Any library loaded with dlopen with RTLD_NODELETE flag (including
    libgcc.so loaded to enable unwind and/or thread cancellation).

  * Audit modules.

  * The loader bump allocator.

For binary dependencies, the RTLD_NODELETE signals the
link_map should be sealed.  It also makes dlopen objects with the
flag sealed as well.

The sealing is controlled by a new tunable, glibc.rtld.seal, with
three different states:

  0. Disabled, where no memory sealing is done.

  1. Enabled, where the loader will issue the mseal syscall on the
     memory mappings but any failure will be ignored.  This is
     the default.

  2. Enforce, similar to Enabled but any failure from the mseal
     will terminate the process.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
2024-07-31 17:02:05 -03:00

30 lines
974 B
C

/* Memory sealing. Generic definitions.
Copyright (C) 2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _DL_SEAL_MODE_H
#define _DL_SEAL_MODE_H
enum dl_seal_mode
{
DL_SEAL_DISABLE = 0,
DL_SEAL_ENABLE = 1,
DL_SEAL_ENFORCE = 2,
};
#endif