Manage dlopen notes at beginning of execution, and downgrade priorities in shared libraries (#43060)

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-07-19 21:23:47 +02:00
committed by GitHub
105 changed files with 236 additions and 246 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ int dlopen_libacl(int log_level) {
#if HAVE_ACL
static void *libacl_dl = NULL;
LIBACL_NOTE(recommended);
LIBACL_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libacl_dl,
-6
View File
@@ -99,12 +99,6 @@ static inline int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask) {
int dlopen_libacl(int log_level) _dlopen_loader_;
#define DLOPEN_LIBACL(log_level, priority) \
({ \
LIBACL_NOTE(priority); \
dlopen_libacl(log_level); \
})
int fd_acl_make_read_only(int fd);
int fd_acl_make_writable(int fd);
+1 -1
View File
@@ -46,7 +46,7 @@ int dlopen_libapparmor(int log_level) {
#if HAVE_APPARMOR
static void *libapparmor_dl = NULL;
LIBAPPARMOR_NOTE(recommended);
LIBAPPARMOR_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libapparmor_dl,
+1 -1
View File
@@ -98,7 +98,7 @@ int dlopen_libblkid(int log_level) {
#if HAVE_BLKID
static void *libblkid_dl = NULL;
LIBBLKID_NOTE(recommended);
LIBBLKID_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libblkid_dl,
-6
View File
@@ -70,9 +70,3 @@ int blkid_probe_lookup_value_u64(blkid_probe b, const char *field, uint64_t *ret
#endif
int dlopen_libblkid(int log_level) _dlopen_loader_;
#define DLOPEN_LIBBLKID(log_level, priority) \
({ \
LIBBLKID_NOTE(priority); \
dlopen_libblkid(log_level); \
})
-6
View File
@@ -95,9 +95,3 @@ int bpf_get_error_translated(const void *ptr);
#endif
int dlopen_bpf(int log_level) _dlopen_loader_;
#define DLOPEN_BPF(log_level, priority) \
({ \
LIBBPF_NOTE(priority); \
dlopen_bpf(log_level); \
})
-6
View File
@@ -449,12 +449,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(OpenSSLAskPasswordUI*, openssl_ask_password_ui_
int dlopen_libcrypto(int log_level) _dlopen_loader_;
bool dlopen_libcrypto_has_argon2id(void);
#define DLOPEN_LIBCRYPTO(log_level, priority) \
({ \
LIBCRYPTO_NOTE(priority); \
dlopen_libcrypto(log_level); \
})
typedef struct Argon2IdParameters {
uint64_t memcost_bytes;
uint32_t iterations;
-6
View File
@@ -101,12 +101,6 @@ int cryptsetup_get_volume_key_id(struct crypt_device *cd, const char *volume_nam
int dlopen_cryptsetup(int log_level) _dlopen_loader_;
#define DLOPEN_CRYPTSETUP(log_level, priority) \
({ \
LIBCRYPTSETUP_NOTE(priority); \
dlopen_cryptsetup(log_level); \
})
int cryptsetup_get_keyslot_from_token(sd_json_variant *v);
const char* mangle_none(const char *s);
-6
View File
@@ -78,9 +78,3 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct curl_slist*, sym_curl_slist_free_
#endif
int dlopen_curl(int log_level) _dlopen_loader_;
#define DLOPEN_CURL(log_level, priority) \
({ \
LIBCURL_NOTE(priority); \
dlopen_curl(log_level); \
})
-6
View File
@@ -90,9 +90,3 @@ int fdisk_partition_set_attrs_as_uint64(struct fdisk_partition *pa, uint64_t fla
#endif
int dlopen_fdisk(int log_level) _dlopen_loader_;
#define DLOPEN_FDISK(log_level, priority) \
({ \
LIBFDISK_NOTE(priority); \
dlopen_fdisk(log_level); \
})
-6
View File
@@ -19,9 +19,3 @@ extern DLSYM_PROTOTYPE(idn2_to_unicode_8z8z);
#endif
int dlopen_idn(int log_level) _dlopen_loader_;
#define DLOPEN_IDN(log_level, priority) \
({ \
LIBIDN2_NOTE(priority); \
dlopen_idn(log_level); \
})
-6
View File
@@ -86,9 +86,3 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct archive*, sym_archive_read_free,
#endif
int dlopen_libarchive(int log_level) _dlopen_loader_;
#define DLOPEN_LIBARCHIVE(log_level, priority) \
({ \
LIBARCHIVE_NOTE(priority); \
dlopen_libarchive(log_level); \
})
+1 -1
View File
@@ -23,7 +23,7 @@ int dlopen_libaudit(int log_level) {
#if HAVE_AUDIT
static void *libaudit_dl = NULL;
LIBAUDIT_NOTE(recommended);
LIBAUDIT_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libaudit_dl,
+1 -1
View File
@@ -142,7 +142,7 @@ int dlopen_libcrypt(int log_level) {
if (cached < 0)
return cached; /* Already tried, and failed. */
LIBCRYPT_NOTE(recommended);
LIBCRYPT_NOTE(suggested);
/* Several distributions like Debian/Ubuntu and OpenSUSE provide libxcrypt as libcrypt.so.1
* (libcrypt.so.1.1 on some architectures), while others like Fedora/CentOS and Arch provide it as
+1 -1
View File
@@ -118,7 +118,7 @@ int dlopen_libmount(int log_level) {
#if HAVE_LIBMOUNT
static void *libmount_dl = NULL;
LIBMOUNT_NOTE(recommended);
LIBMOUNT_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libmount_dl,
-6
View File
@@ -89,9 +89,3 @@ static inline void* sym_mnt_unref_monitor(struct libmnt_monitor *p) {
#endif
int dlopen_libmount(int log_level) _dlopen_loader_;
#define DLOPEN_LIBMOUNT(log_level, priority) \
({ \
LIBMOUNT_NOTE(priority); \
dlopen_libmount(log_level); \
})
-6
View File
@@ -138,9 +138,3 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct MHD_Response*, sym_MHD_destroy_re
#endif
int dlopen_microhttpd(int log_level) _dlopen_loader_;
#define DLOPEN_MICROHTTPD(log_level, priority) \
({ \
LIBMICROHTTPD_NOTE(priority); \
dlopen_microhttpd(log_level); \
})
+1 -1
View File
@@ -171,7 +171,7 @@ int dlopen_libkmod(int log_level) {
#if HAVE_KMOD
static void *libkmod_dl = NULL;
LIBKMOD_NOTE(recommended);
LIBKMOD_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libkmod_dl,
-6
View File
@@ -54,9 +54,3 @@ static inline int module_load_and_warn(struct kmod_ctx *ctx, const char *module,
#endif
int dlopen_libkmod(int log_level) _dlopen_loader_;
#define DLOPEN_LIBKMOD(log_level, priority) \
({ \
LIBKMOD_NOTE(priority); \
dlopen_libkmod(log_level); \
})
+1 -1
View File
@@ -382,7 +382,7 @@ int dlopen_libpam(int log_level) {
#if HAVE_PAM
static void *libpam_dl = NULL;
LIBPAM_NOTE(recommended);
LIBPAM_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libpam_dl,
-6
View File
@@ -111,9 +111,3 @@ int pam_putenv_assign(pam_handle_t *pamh, const char *name, const char *value);
#endif
int dlopen_libpam(int log_level) _dlopen_loader_;
#define DLOPEN_LIBPAM(log_level, priority) \
({ \
LIBPAM_NOTE(priority); \
dlopen_libpam(log_level); \
})
+1 -1
View File
@@ -2601,7 +2601,7 @@ int dlopen_libseccomp(int log_level) {
#if HAVE_SECCOMP
static void *libseccomp_dl = NULL;
LIBSECCOMP_NOTE(recommended);
LIBSECCOMP_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libseccomp_dl,
-7
View File
@@ -166,17 +166,10 @@ static inline bool is_seccomp_available(void) {
return false;
}
#endif
int dlopen_libseccomp(int log_level) _dlopen_loader_;
#define DLOPEN_LIBSECCOMP(log_level, priority) \
({ \
LIBSECCOMP_NOTE(priority); \
dlopen_libseccomp(log_level); \
})
/* This is a special value to be used where syscall filters otherwise expect errno numbers, will be
replaced with real seccomp action. */
enum {
+1 -1
View File
@@ -92,7 +92,7 @@ int dlopen_libselinux(int log_level) {
#if HAVE_SELINUX
static void *libselinux_dl = NULL;
LIBSELINUX_NOTE(recommended);
LIBSELINUX_NOTE(suggested);
return dlopen_many_sym_or_warn(
&libselinux_dl,
-6
View File
@@ -65,12 +65,6 @@ static inline void freeconp(char **p) {
int dlopen_libselinux(int log_level) _dlopen_loader_;
#define DLOPEN_LIBSELINUX(log_level, priority) \
({ \
LIBSELINUX_NOTE(priority); \
dlopen_libselinux(log_level); \
})
#define _cleanup_freecon_ _cleanup_(freeconp)
/* This accepts 0 error, like _zerook(). */
-6
View File
@@ -48,9 +48,3 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(SSL_CTX*, sym_SSL_CTX_free, SSL_CTX_free
#endif
int dlopen_libssl(int log_level) _dlopen_loader_;
#define DLOPEN_LIBSSL(log_level, priority) \
({ \
LIBSSL_NOTE(priority); \
dlopen_libssl(log_level); \
})
-6
View File
@@ -59,12 +59,6 @@ int dlopen_tpm2(int log_level) _dlopen_loader_;
* other tokens. */
#define ERRNO_IS_NEG_TPM2_TOKEN_MISMATCH(r) IN_SET(r, -EREMCHG, -ENOANO, -EPERM, -ENOSTR, -EREMOTE, -EADDRNOTAVAIL)
#define DLOPEN_TPM2(log_level, priority) \
({ \
TPM2_NOTE(priority); \
dlopen_tpm2(log_level); \
})
#if HAVE_TPM2
#ifndef SYSTEMD_CFLAGS_MARKER_TPM2
# error "missing tpm2_cflags in meson dependency."