]> git.ipfire.org Git - thirdparty/glibc.git/commit
elf/rtld: Fix auxiliary vector for enable_secure
authorStefan Liebler <stli@linux.ibm.com>
Tue, 2 Jul 2024 13:25:20 +0000 (15:25 +0200)
committerStefan Liebler <stli@linux.ibm.com>
Wed, 3 Jul 2024 11:01:44 +0000 (13:01 +0200)
commitd2f6ceaccbae2f645075dedad2b762896da1ec04
treed0e370e96ee8bad1724768d7e05a1a222740266a
parent4737e6a7a3f98c8e2674e313cb09d7882583f5f0
elf/rtld: Fix auxiliary vector for enable_secure

Starting with commit
59974938fe1f4add843f5325f78e2a7ccd8db853
elf/rtld: Count skipped environment variables for enable_secure

The new testcase elf/tst-tunables-enable_secure-env segfaults on s390 (31bit).
There _start parses the auxiliary vector for some additional checks.

Therefore it skips over the zeros after the environment variables ...
0x7fffac20:     0x7fffbd17      0x7fffbd32      0x7fffbd69      0x00000000
------------------------------------------------^^^last environment variable

... and then it parses the auxiliary vector and stops at AT_NULL.
0x7fffac30:     0x00000000      0x00000021      0x00000000      0x00000000
--------------------------------^^^AT_SYSINFO_EHDR--------------^^^AT_NULL
----------------^^^newp-----------------------------------------^^^oldp
Afterwards it tries to access AT_PHDR which points to somewhere and segfaults.

Due to not incorporating the skip_env variable in the computation of oldp
when shuffling down the auxv in rtld.c, it just copies one entry with AT_NULL
and value 0x00000021 and stops the loop.  In reality we have skipped
GLIBC_TUNABLES environment variable (=> skip_env=1). Thus we should copy from
here:
0x7fffac40:     0x00000021      0x7ffff000      0x00000010      0x007fffff
----------------^^^fixed-oldp

This patch fixes the computation of oldp when shuffling down auxiliary vector.
It also adds some checks in the testcase.  Those checks also fail on
s390x (64bit) and x86_64 without the fix.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
elf/Makefile
elf/rtld.c
elf/tst-tunables-enable_secure-env.c