public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/11] Improve tunable handling
@ 2023-10-10 18:01 Adhemerval Zanella
  2023-10-10 18:01 ` [PATCH 01/11] elf: Remove /etc/suid-debug support Adhemerval Zanella
                   ` (10 more replies)
  0 siblings, 11 replies; 27+ messages in thread
From: Adhemerval Zanella @ 2023-10-10 18:01 UTC (permalink / raw)
  To: libc-alpha, Siddhesh Poyarekar

The recent CVE-2023-4911 fix [1] and tunable change to SXID_ERASE
discussion [2] brought some issues with the current tunable handling by
the loader. Besides the bugs in tuning parsing, some other questions
are:
* What should be the security boundaries for tunable and other tuning
* environment variables?
* Should tunables be filtered out or be disabled altogether in setuid
* binaries [3]?
* How should ld.so handle security-sensitive tunable (like malloc
* options)?
* How to handle ill-formatted tunable definition [4]?
* Is tunable copy/parsing (through tunable_strdup) required [5]?

On this patchset, I followed the idea laid out in the discussion on
whether to apply SXID_ERASE to all tunables [6]:
Ignore any tunable on AT_SECURE binaries (as some Linux distributions
are already [7]);
Add malloc tunables along with GLIBC_TUNABLES to unsecvars;
Do not parse ill-formatted GLIBC_TUNABLES strings;
Remove the requirement of duplicating the GLIBC_TUNABLES string for
parsing.

Patch #1 removes '/etc/suid-debug', which has not been working since
malloc debugging supported moved to libc_malloc_debug.so. It is one
thing less that might change AT_SECURE binaries' behavior
due to environment configurations.

Patch #2 removed tunables parsing and applying for setuid/setgid
binaries (similar to Alt Linux patch).

Patch #3 and #4 add all malloc tunable and GLIBC_TUNABLES to unsecvars
and improve tst-env-setuid.c to test all possible environment variables.

Patch #5 and #6 improved the GLIBC_TUNABLES handling to avoid handling
ill-formatted inputs.

Patch #7 makes _dl_debug_vdprintf usable before self-relocation so patch
#8 can add a loader warning that ill-formatted GLIBC_TUNABLES inputs are
ignored (it also fixes the issue where the GLIBC_TUNABLE allocation
failure will trigger a SEGFAULT on some architecture for PIE).

Patch #9, #10, and #11 remove the tunable_strdup and make the
GLIBC_TUNABLE parsing in place (no more possible allocation failure).
The parsing now tracks the tunable start and its size. The
dl-tunable-parse.h adds helper functions to help to parse, like an
strcmp that also checks for size and an iterator for suboptions that are
comma-separated (used on hwcap parsing by x86, powerpc, and s390x).

[1] https://sourceware.org/pipermail/libc-alpha/2023-October/151921.html
[2] https://sourceware.org/pipermail/libc-alpha/2023-October/151936.html
[3] https://www.openwall.com/lists/oss-security/2023/10/03/3
[4] https://sourceware.org/pipermail/libc-alpha/2023-October/151927.html
[5] https://sourceware.org/pipermail/libc-alpha/2023-October/151959.html
[6] https://sourceware.org/pipermail/libc-alpha/2023-October/152011.html
[7] https://git.altlinux.org/gears/g/glibc.git?p=glibc.git;a=commitdiff;h=5d1686416ab766f3dd0780ab730650c4c0f76ca9

Adhemerval Zanella (11):
  elf: Remove /etc/suid-debug support
  elf: Ignore GLIBC_TUNABLES for setuid/setgid binaries
  elf: Add all malloc tunable to unsecvars
  elf: Add GLIBC_TUNABLES to unsecvars
  elf: Do not process invalid tunable format
  elf: Do not parse ill-formatted strings
  elf: Fix _dl_debug_vdprintf to work before self-relocation
  elf: Emit warning if tunable is ill-formatted
  x86: Use dl-symbol-redir-ifunc.h on cpu-tunables
  s390: Use dl-symbol-redir-ifunc.h on cpu-tunables
  elf: Do not duplicate the GLIBC_TUNABLES string

 elf/Makefile                                  |   5 +-
 elf/dl-printf.c                               |  16 +-
 elf/dl-tunable-types.h                        |  10 -
 elf/dl-tunables.c                             | 219 +++++----------
 elf/dl-tunables.h                             |   6 +-
 elf/dl-tunables.list                          |   9 -
 elf/rtld.c                                    |   3 -
 elf/tst-env-setuid-tunables.c                 |  58 ++--
 elf/tst-env-setuid.c                          |  87 ++----
 elf/tst-tunables.c                            | 260 ++++++++++++++++++
 manual/README.tunables                        |   9 -
 manual/memory.texi                            |   4 +-
 manual/tunables.texi                          |   4 +-
 scripts/gen-tunables.awk                      |  18 +-
 stdio-common/Makefile                         |   5 +
 stdio-common/_itoa.c                          |   5 +
 sysdeps/generic/dl-tunables-parse.h           | 128 +++++++++
 sysdeps/generic/unsecvars.h                   |   8 +
 .../i686/multiarch/dl-symbol-redir-ifunc.h    |   5 +
 sysdeps/s390/cpu-features.c                   | 169 +++++-------
 .../s390/multiarch/dl-symbol-redir-ifunc.h    |   2 +
 .../unix/sysv/linux/aarch64/cpu-features.c    |  38 ++-
 .../sysv/linux/i386/dl-writev.h}              |  18 +-
 .../unix/sysv/linux/powerpc/cpu-features.c    |  45 +--
 .../sysv/linux/powerpc/tst-hwcap-tunables.c   |   6 +-
 sysdeps/x86/Makefile                          |   4 +-
 sysdeps/x86/cpu-tunables.c                    | 135 +++------
 sysdeps/x86/tst-hwcap-tunables.c              | 151 ++++++++++
 sysdeps/x86_64/64/dl-tunables.list            |   1 -
 .../x86_64/multiarch/dl-symbol-redir-ifunc.h  |  15 +
 30 files changed, 888 insertions(+), 555 deletions(-)
 create mode 100644 elf/tst-tunables.c
 create mode 100644 sysdeps/generic/dl-tunables-parse.h
 rename sysdeps/{x86_64/memcmp-isa-default-impl.h => unix/sysv/linux/i386/dl-writev.h} (62%)
 create mode 100644 sysdeps/x86/tst-hwcap-tunables.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2023-10-13 14:40 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-10 18:01 [PATCH 00/11] Improve tunable handling Adhemerval Zanella
2023-10-10 18:01 ` [PATCH 01/11] elf: Remove /etc/suid-debug support Adhemerval Zanella
2023-10-12  8:44   ` Florian Weimer
2023-10-12 10:43     ` Siddhesh Poyarekar
2023-10-12 16:01       ` Siddhesh Poyarekar
2023-10-13 13:47     ` Adhemerval Zanella Netto
2023-10-10 18:01 ` [PATCH 02/11] elf: Ignore GLIBC_TUNABLES for setuid/setgid binaries Adhemerval Zanella
2023-10-10 18:01 ` [PATCH 03/11] elf: Add all malloc tunable to unsecvars Adhemerval Zanella
2023-10-12  8:47   ` Florian Weimer
2023-10-13 13:53     ` Adhemerval Zanella Netto
2023-10-13 14:12       ` Florian Weimer
2023-10-13 14:27         ` Adhemerval Zanella Netto
2023-10-10 18:01 ` [PATCH 04/11] elf: Add GLIBC_TUNABLES " Adhemerval Zanella
2023-10-12  8:46   ` Florian Weimer
2023-10-13 13:51     ` Adhemerval Zanella Netto
2023-10-13 14:11       ` Florian Weimer
2023-10-13 14:26         ` Adhemerval Zanella Netto
2023-10-10 18:01 ` [PATCH 05/11] elf: Do not process invalid tunable format Adhemerval Zanella
2023-10-10 18:01 ` [PATCH 06/11] elf: Do not parse ill-formatted strings Adhemerval Zanella
2023-10-10 18:01 ` [PATCH 07/11] elf: Fix _dl_debug_vdprintf to work before self-relocation Adhemerval Zanella
2023-10-10 18:01 ` [PATCH 08/11] elf: Emit warning if tunable is ill-formatted Adhemerval Zanella
2023-10-10 18:01 ` [PATCH 09/11] x86: Use dl-symbol-redir-ifunc.h on cpu-tunables Adhemerval Zanella
2023-10-12 18:11   ` Noah Goldstein
2023-10-10 18:01 ` [PATCH 10/11] s390: " Adhemerval Zanella
2023-10-10 18:01 ` [PATCH 11/11] elf: Do not duplicate the GLIBC_TUNABLES string Adhemerval Zanella
2023-10-12 17:56   ` Noah Goldstein
2023-10-13 14:40     ` Adhemerval Zanella Netto

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).