tree-wide: always do dlopen() with RTLD_NOW + RTLD_NODELETE
authorLennart Poettering <lennart@poettering.net>
Tue, 1 Oct 2024 14:44:18 +0000 (16:44 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 8 Oct 2024 15:39:12 +0000 (16:39 +0100)
commite012eedd727a38bd18c9a540b92b95aa880d2b42
treebc11e9968969ed26e89847e15d410ebf39ac67e7
parent915822604f25f69ab8f67db735fc89639ab6fed9
tree-wide: always do dlopen() with RTLD_NOW + RTLD_NODELETE

Let's systematically use RTL_NOW|RLTD_NODELETE as flags passed to
dlopen(), across our codebase.

Various distros build with "-z now" anyway, hence it's weird to specify
RTLD_LAZY trying to override that (which it doesn't). Hence, let's
follow suit, and just do what everybody else does.

Also set RTLD_NODELETE, which is apparently what distros will probably
end up implying sooner or later anyway. Given that for pretty much all
our dlopen() calls we never call dlclose() anyway, let's just set this
everywhere too, to make things systematic.

This way, the flags we use by default match what distros such as fedora
do, there are no surprises, and read-only relocations can be a thing.

Fixes: #34537
(cherry picked from commit bd4beaa2ebfbbec0a1263a7091a91e528ce8cf13)
src/basic/dlfcn-util.c
src/shared/bpf-dlopen.c
src/shared/idn-util.c
src/shared/tpm2-util.c
src/shared/userdb.c
src/test/test-dlopen.c
src/test/test-nss-hosts.c
src/test/test-nss-users.c