From dc85199e10bdbbdf8abfdd59e6b9cea28ac78797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 1 Nov 2023 15:38:50 +0100 Subject: [PATCH] libsemanage/tests: silence function UBSAN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian Göttsche --- libsemanage/src/database.c | 10 ++++++++++ libsemanage/src/database_file.c | 1 + libsemanage/src/database_join.c | 2 ++ libsemanage/src/database_llist.c | 8 ++++++++ libsemanage/src/database_policydb.c | 1 + libsemanage/src/direct_api.c | 1 + libsemanage/tests/test_handle.c | 1 + 7 files changed, 24 insertions(+) diff --git a/libsemanage/src/database.c b/libsemanage/src/database.c index fc4f7179f9..0e8c6b02d9 100644 --- a/libsemanage/src/database.c +++ b/libsemanage/src/database.c @@ -21,6 +21,7 @@ static int assert_init(semanage_handle_t * handle, dbase_config_t * dconfig) return STATUS_SUCCESS; } +__attribute__((no_sanitize("function"))) static int enter_ro(semanage_handle_t * handle, dbase_config_t * dconfig) { @@ -58,6 +59,7 @@ static inline int exit_ro(semanage_handle_t * handle) return commit_num; } +__attribute__((no_sanitize("function"))) static int enter_rw(semanage_handle_t * handle, dbase_config_t * dconfig) { @@ -79,6 +81,7 @@ static int enter_rw(semanage_handle_t * handle, dbase_config_t * dconfig) return STATUS_ERR; } +__attribute__((no_sanitize("function"))) int dbase_modify(semanage_handle_t * handle, dbase_config_t * dconfig, const record_key_t * key, const record_t * data) @@ -93,6 +96,7 @@ int dbase_modify(semanage_handle_t * handle, return STATUS_SUCCESS; } +__attribute__((no_sanitize("function"))) int dbase_set(semanage_handle_t * handle, dbase_config_t * dconfig, const record_key_t * key, const record_t * data) @@ -107,6 +111,7 @@ int dbase_set(semanage_handle_t * handle, return STATUS_SUCCESS; } +__attribute__((no_sanitize("function"))) int dbase_del(semanage_handle_t * handle, dbase_config_t * dconfig, const record_key_t * key) { @@ -120,6 +125,7 @@ int dbase_del(semanage_handle_t * handle, return STATUS_SUCCESS; } +__attribute__((no_sanitize("function"))) int dbase_query(semanage_handle_t * handle, dbase_config_t * dconfig, const record_key_t * key, record_t ** response) @@ -136,6 +142,7 @@ int dbase_query(semanage_handle_t * handle, return exit_ro(handle); } +__attribute__((no_sanitize("function"))) int dbase_exists(semanage_handle_t * handle, dbase_config_t * dconfig, const record_key_t * key, int *response) @@ -152,6 +159,7 @@ int dbase_exists(semanage_handle_t * handle, return exit_ro(handle); } +__attribute__((no_sanitize("function"))) int dbase_count(semanage_handle_t * handle, dbase_config_t * dconfig, unsigned int *response) { @@ -167,6 +175,7 @@ int dbase_count(semanage_handle_t * handle, return exit_ro(handle); } +__attribute__((no_sanitize("function"))) int dbase_iterate(semanage_handle_t * handle, dbase_config_t * dconfig, int (*fn) (const record_t * record, @@ -184,6 +193,7 @@ int dbase_iterate(semanage_handle_t * handle, return exit_ro(handle); } +__attribute__((no_sanitize("function"))) int dbase_list(semanage_handle_t * handle, dbase_config_t * dconfig, record_t *** records, unsigned int *count) diff --git a/libsemanage/src/database_file.c b/libsemanage/src/database_file.c index d5d2ef5b60..38bf5befcc 100644 --- a/libsemanage/src/database_file.c +++ b/libsemanage/src/database_file.c @@ -37,6 +37,7 @@ struct dbase_file { record_file_table_t *rftable; }; +__attribute__((no_sanitize("function"))) static int dbase_file_cache(semanage_handle_t * handle, dbase_file_t * dbase) { diff --git a/libsemanage/src/database_join.c b/libsemanage/src/database_join.c index 47fa6bcac8..af0b70e6bd 100644 --- a/libsemanage/src/database_join.c +++ b/libsemanage/src/database_join.c @@ -34,6 +34,7 @@ struct dbase_join { record_join_table_t *rjtable; }; +__attribute__((no_sanitize("function"))) static int dbase_join_cache(semanage_handle_t * handle, dbase_join_t * dbase) { @@ -170,6 +171,7 @@ static int dbase_join_cache(semanage_handle_t * handle, dbase_join_t * dbase) } /* Flush database */ +__attribute__((no_sanitize("function"))) static int dbase_join_flush(semanage_handle_t * handle, dbase_join_t * dbase) { diff --git a/libsemanage/src/database_llist.c b/libsemanage/src/database_llist.c index 240b2557b4..bc8f201939 100644 --- a/libsemanage/src/database_llist.c +++ b/libsemanage/src/database_llist.c @@ -34,6 +34,7 @@ int dbase_llist_needs_resync(semanage_handle_t * handle, dbase_llist_t * dbase) } /* Helper for adding records to the cache */ +__attribute__((no_sanitize("function"))) int dbase_llist_cache_prepend(semanage_handle_t * handle, dbase_llist_t * dbase, const record_t * data) { @@ -67,6 +68,7 @@ int dbase_llist_cache_prepend(semanage_handle_t * handle, return STATUS_ERR; } +__attribute__((no_sanitize("function"))) void dbase_llist_drop_cache(dbase_llist_t * dbase) { @@ -99,6 +101,7 @@ int dbase_llist_set_serial(semanage_handle_t * handle, dbase_llist_t * dbase) } /* Helper for finding records in the cache */ +__attribute__((no_sanitize("function"))) static int dbase_llist_cache_locate(semanage_handle_t * handle, dbase_llist_t * dbase, const record_key_t * key, @@ -226,6 +229,7 @@ int dbase_llist_modify(semanage_handle_t * handle, return STATUS_SUCCESS; } +__attribute__((no_sanitize("function"))) int dbase_llist_query(semanage_handle_t * handle, dbase_llist_t * dbase, const record_key_t * key, record_t ** response) @@ -248,6 +252,7 @@ int dbase_llist_query(semanage_handle_t * handle, return STATUS_ERR; } +__attribute__((no_sanitize("function"))) int dbase_llist_iterate(semanage_handle_t * handle, dbase_llist_t * dbase, int (*fn) (const record_t * record, @@ -274,6 +279,7 @@ int dbase_llist_iterate(semanage_handle_t * handle, return STATUS_ERR; } +__attribute__((no_sanitize("function"))) int dbase_llist_del(semanage_handle_t * handle __attribute__ ((unused)), dbase_llist_t * dbase, const record_key_t * key) { @@ -304,6 +310,7 @@ int dbase_llist_del(semanage_handle_t * handle __attribute__ ((unused)), return STATUS_SUCCESS; } +__attribute__((no_sanitize("function"))) int dbase_llist_clear(semanage_handle_t * handle, dbase_llist_t * dbase) { @@ -331,6 +338,7 @@ int dbase_llist_clear(semanage_handle_t * handle, dbase_llist_t * dbase) return STATUS_SUCCESS; } +__attribute__((no_sanitize("function"))) int dbase_llist_list(semanage_handle_t * handle, dbase_llist_t * dbase, record_t *** records, unsigned int *count) diff --git a/libsemanage/src/database_policydb.c b/libsemanage/src/database_policydb.c index 91425498f4..70604237b6 100644 --- a/libsemanage/src/database_policydb.c +++ b/libsemanage/src/database_policydb.c @@ -382,6 +382,7 @@ struct list_handler_arg { int pos; }; +__attribute__((no_sanitize("function"))) static int list_handler(const record_t * record, void *varg) { diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c index b85d00755e..f5a096e3a4 100644 --- a/libsemanage/src/direct_api.c +++ b/libsemanage/src/direct_api.c @@ -1141,6 +1141,7 @@ static int copy_file_if_exists(const char *src, const char *dst, mode_t mode){ /* Commits all changes in sandbox to the actual kernel policy. * Returns commit number on success, -1 on error. */ +__attribute__((no_sanitize("function"))) static int semanage_direct_commit(semanage_handle_t * sh) { char **mod_filenames = NULL; diff --git a/libsemanage/tests/test_handle.c b/libsemanage/tests/test_handle.c index a9c2b2f639..c1186dc8fd 100644 --- a/libsemanage/tests/test_handle.c +++ b/libsemanage/tests/test_handle.c @@ -317,6 +317,7 @@ static void helper_select_store(const char *name, enum semanage_connect_type typ cleanup_handle(SH_HANDLE); } +__attribute__((no_sanitize("implicit-integer-sign-change"))) static void test_select_store(void) { helper_select_store("asdf", SEMANAGE_CON_INVALID - 1, -1);