Skip to content
Commit 71149c2a authored by Adhemerval Zanella's avatar Adhemerval Zanella
Browse files

elf: Only process multiple tunable once (BZ 31686)



The 680c597e commit made loader reject ill-formatted strings by
first tracking all set tunables and then applying them. However, it does
not take into consideration if the same tunable is set multiple times,
where parse_tunables_string appends the found tunable without checking
if it was already in the list. It leads to a stack-based buffer overflow
if the tunable is specified more than the total number of tunables.  For
instance:

  GLIBC_TUNABLES=glibc.malloc.check=2:... (repeat over the number of
  total support for different tunable).

Instead, use the index of the tunable list to get the expected tunable
entry.  Since now the initial list is zero-initialized, the compiler
might emit an extra memset and this requires some minor adjustment
on some ports.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

Reported-by: default avatarYuto Maeda <maeda@cyberdefense.jp>
Reported-by: default avatarYutaro Shimizu <shimizu@cyberdefense.jp>
Reviewed-by: default avatarSiddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit bcae44ea)
parent f8e46234
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment