core: don't log plain pointer values for singletons

Logging pointer values allows to defeat ASLR. Don't do that.
This commit is contained in:
Thomas Haller 2019-05-05 15:40:04 +02:00
parent 78999f9b61
commit 58df3f37ea
6 changed files with 18 additions and 8 deletions

View file

@ -575,7 +575,8 @@ nm_auth_manager_setup (gboolean polkit_enabled)
singleton_instance = self;
nm_singleton_instance_register ();
nm_log_dbg (LOGD_CORE, "setup %s singleton (%p)", "NMAuthManager", singleton_instance);
nm_log_dbg (LOGD_CORE, "setup %s singleton ("NM_HASH_OBFUSCATE_PTR_FMT")",
"NMAuthManager", NM_HASH_OBFUSCATE_PTR (singleton_instance));
return self;
}

View file

@ -2709,7 +2709,8 @@ nm_config_setup (const NMConfigCmdLineOptions *cli, char **atomic_section_prefix
/* usually, you would not see this logging line because when creating the
* NMConfig instance, the logging is not yet set up to print debug message. */
nm_log_dbg (LOGD_CORE, "setup %s singleton (%p)", "NMConfig", singleton_instance);
nm_log_dbg (LOGD_CORE, "setup %s singleton ("NM_HASH_OBFUSCATE_PTR_FMT")",
"NMConfig", NM_HASH_OBFUSCATE_PTR (singleton_instance));
}
return singleton_instance;
}

View file

@ -142,8 +142,10 @@ _nm_singleton_instance_destroy (void)
g_object_weak_unref (instance, _nm_singleton_instance_weak_cb, NULL);
if (instance->ref_count > 1)
nm_log_dbg (LOGD_CORE, "disown %s singleton (%p)", G_OBJECT_TYPE_NAME (instance), instance);
if (instance->ref_count > 1) {
nm_log_dbg (LOGD_CORE, "disown %s singleton ("NM_HASH_OBFUSCATE_PTR_FMT")",
G_OBJECT_TYPE_NAME (instance), NM_HASH_OBFUSCATE_PTR (instance));
}
g_object_unref (instance);
}

View file

@ -42,7 +42,9 @@ static void \
_singleton_instance_weak_ref_cb (gpointer data, \
GObject *where_the_object_was) \
{ \
nm_log_dbg (LOGD_CORE, "disposing %s singleton (%p)", G_STRINGIFY (TYPE), singleton_instance); \
nm_log_dbg (LOGD_CORE, "disposing %s singleton ("NM_HASH_OBFUSCATE_PTR_FMT")", \
G_STRINGIFY (TYPE), \
NM_HASH_OBFUSCATE_PTR (singleton_instance)); \
singleton_instance = NULL; \
} \
static inline void \
@ -73,7 +75,9 @@ GETTER (void) \
singleton_instance = (g_object_new (GTYPE, ##__VA_ARGS__, NULL)); \
g_assert (singleton_instance); \
nm_singleton_instance_register (); \
nm_log_dbg (LOGD_CORE, "create %s singleton (%p)", G_STRINGIFY (TYPE), singleton_instance); \
nm_log_dbg (LOGD_CORE, "create %s singleton ("NM_HASH_OBFUSCATE_PTR_FMT")", \
G_STRINGIFY (TYPE), \
NM_HASH_OBFUSCATE_PTR (singleton_instance)); \
} \
return singleton_instance; \
} \

View file

@ -7272,7 +7272,8 @@ nm_manager_setup (void)
singleton_instance = self;
nm_singleton_instance_register ();
_LOGD (LOGD_CORE, "setup %s singleton (%p)", "NMManager", singleton_instance);
nm_log_dbg (LOGD_CORE, "setup %s singleton ("NM_HASH_OBFUSCATE_PTR_FMT")",
"NMManager", NM_HASH_OBFUSCATE_PTR (singleton_instance));
nm_dbus_object_export (NM_DBUS_OBJECT (self));
return self;

View file

@ -221,7 +221,8 @@ nm_platform_setup (NMPlatform *instance)
nm_singleton_instance_register ();
nm_log_dbg (LOGD_CORE, "setup %s singleton (%p, %s)", "NMPlatform", singleton_instance, G_OBJECT_TYPE_NAME (instance));
nm_log_dbg (LOGD_CORE, "setup %s singleton ("NM_HASH_OBFUSCATE_PTR_FMT")",
"NMPlatform", NM_HASH_OBFUSCATE_PTR (instance));
}
/**