Skip to content

Commit

Permalink
libsemanage/tests: silence function UBSAN
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
  • Loading branch information
cgzones committed Nov 1, 2023
1 parent 2aee578 commit dc85199
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libsemanage/src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

Expand Down Expand Up @@ -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)
{

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
{
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
{
Expand All @@ -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,
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions libsemanage/src/database_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

Expand Down
2 changes: 2 additions & 0 deletions libsemanage/src/database_join.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

Expand Down Expand Up @@ -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)
{

Expand Down
8 changes: 8 additions & 0 deletions libsemanage/src/database_llist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions libsemanage/src/database_policydb.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ struct list_handler_arg {
int pos;
};

__attribute__((no_sanitize("function")))
static int list_handler(const record_t * record, void *varg)
{

Expand Down
1 change: 1 addition & 0 deletions libsemanage/src/direct_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libsemanage/tests/test_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit dc85199

Please sign in to comment.