libselinux: drop dso.h
This three part patch series drops the dso.h and hidden_* macros.
The old dso.h functionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.
The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition
[PATCH 1/3] dso: drop hidden_proto and hidden_def [PATCH 2/3] Makefile: add -fno-semantic-interposition [PATCH 3/3] Makefile: add linker script to minimize exports
PATCH 1/3 dso: drop hidden_proto and hidden_def
From: William Roberts <[email protected]>
--- libselinux/src/avc.c | 5 - libselinux/src/avc_internal.h | 52 ++++---- libselinux/src/avc_sidtab.h | 11 +- libselinux/src/booleans.c | 5 - libselinux/src/callbacks.h | 11 +- libselinux/src/canonicalize_context.c | 2 - libselinux/src/checkAccess.c | 1 - libselinux/src/check_context.c | 2 - libselinux/src/checkreqprot.c | 1 - libselinux/src/compute_av.c | 4 - libselinux/src/compute_create.c | 4 - libselinux/src/compute_member.c | 1 - libselinux/src/compute_relabel.c | 1 - libselinux/src/compute_user.c | 2 - libselinux/src/context.c | 9 +- libselinux/src/context_internal.h | 12 -- libselinux/src/deny_unknown.c | 1 - libselinux/src/disable.c | 1 - libselinux/src/dso.h | 23 ---- libselinux/src/enabled.c | 2 - libselinux/src/fgetfilecon.c | 1 - libselinux/src/freecon.c | 1 - libselinux/src/freeconary.c | 1 - libselinux/src/fsetfilecon.c | 1 - libselinux/src/get_context_list.c | 3 - libselinux/src/get_context_list_internal.h | 4 - libselinux/src/get_default_type_internal.h | 2 - libselinux/src/get_initial_context.c | 2 - libselinux/src/getenforce.c | 1 - libselinux/src/getfilecon.c | 2 - libselinux/src/getpeercon.c | 1 - libselinux/src/init.c | 4 - libselinux/src/label_internal.h | 19 ++- libselinux/src/label_support.c | 6 +- libselinux/src/lgetfilecon.c | 1 - libselinux/src/load_policy.c | 2 - libselinux/src/lsetfilecon.c | 1 - libselinux/src/matchpathcon.c | 3 +- libselinux/src/policyvers.c | 2 - libselinux/src/procattr.c | 21 +--- libselinux/src/regex.h | 21 ++-- libselinux/src/reject_unknown.c | 1 - .../src/selinux_check_securetty_context.c | 1 - libselinux/src/selinux_config.c | 36 ------ libselinux/src/selinux_internal.h | 117 +----------------- libselinux/src/setenforce.c | 1 - libselinux/src/setfilecon.c | 1 - libselinux/src/setrans_client.c | 8 +- libselinux/src/seusers.c | 2 +- libselinux/src/sha1.c | 7 +- libselinux/src/stringrep.c | 1 - libselinux/src/validatetrans.c | 2 - 52 files changed, 69 insertions(+), 357 deletions(-) delete mode 100644 libselinux/src/dso.h
libselinux/src/avc.c +0 -5
@@ -294,7 +294,6 @@ void avc_av_stats(void) slots_used, AVC_CACHE_SLOTS, max_chain_len); } -hidden_def (avc_av_stats)static inline struct avc_node *avc_reclaim_node (void ) {
@@ -494,7 +493,6 @@ void avc_cleanup(void) { } -hidden_def (avc_cleanup)int avc_reset (void ) {
@@ -539,7 +537,6 @@ int avc_reset(void)return rc; } -hidden_def (avc_reset)void avc_destroy (void ) {
@@ -733,7 +730,6 @@ void avc_audit(security_id_t ssid, security_id_t tsid,avc_release_lock (avc_log_lock); } -hidden_def (avc_audit)static void avd_init (struct av_decision *avd)
@@ -825,7 +821,6 @@ int avc_has_perm_noaudit(security_id_t ssid,return rc; } -hidden_def(avc_has_perm_noaudit) int avc_has_perm(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t requested,
libselinux/src/avc_internal.h +23 -29
85 lines not on this page · raw message
libselinux/src/avc_sidtab.h +5 -6
@@ -7,7 +7,6 @@#include <selinux/selinux.h> #include <selinux/avc.h> -#include "dso.h" struct sidtab_node {struct security_id sid_s;
@@ -24,13 +23,13 @@ struct sidtab { unsigned nel; }; -int sidtab_init(struct sidtab *s) hidden; -int sidtab_insert(struct sidtab *s, const char * ctx) hidden; +int sidtab_init (struct sidtab *s) ; +int sidtab_insert (struct sidtab *s,const char * ctx) ;int sidtab_context_to_sid (struct sidtab *s, - const char * ctx, security_id_t * sid) hidden; +const char * ctx,security_id_t * sid) ; -void sidtab_sid_stats(struct sidtab *s, char *buf, int buflen) hidden; -void sidtab_destroy(struct sidtab *s) hidden; +void sidtab_sid_stats (struct sidtab *s,char *buf,int buflen) ; +void sidtab_destroy (struct sidtab *s) ;#endif /* _SELINUX_AVC_SIDTAB_H_ */
libselinux/src/booleans.c +0 -5
@@ -414,8 +414,3 @@ char *selinux_boolean_sub(const char *name __attribute__((unused))) }#endif -hidden_def(security_get_boolean_names) -hidden_def(selinux_boolean_sub) -hidden_def(security_get_boolean_active) -hidden_def(security_set_boolean) -hidden_def(security_commit_booleans)
libselinux/src/callbacks.h +5 -6
@@ -9,22 +9,21 @@#include <stdlib.h> #include <string.h> #include <selinux/selinux.h> -#include "dso.h" /* callback pointers */ extern int __attribute__ ((format (printf,2 ,3 ))) -(*selinux_log) (int type, const char *, ...) hidden; +(*selinux_log) (int type,const char *, ...) ;extern int -(*selinux_audit) (void *, security_class_t, char *, size_t) hidden; +(*selinux_audit) (void *,security_class_t ,char *,size_t ) ;extern int -(*selinux_validate)(char **ctx) hidden; +(*selinux_validate)(char **ctx) ;extern int -(*selinux_netlink_setenforce) (int enforcing) hidden; +(*selinux_netlink_setenforce) (int enforcing) ;extern int -(*selinux_netlink_policyload) (int seqno) hidden; +(*selinux_netlink_policyload) (int seqno) ;#endif /* _SELINUX_CALLBACKS_H_ */
libselinux/src/canonicalize_context.c +0 -2
@@ -60,7 +60,6 @@ int security_canonicalize_context_raw(const char * con,return ret; } -hidden_def (security_canonicalize_context_raw)int security_canonicalize_context (const char * con,char ** canoncon)
@@ -83,4 +82,3 @@ int security_canonicalize_context(const char * con,return ret; } -hidden_def (security_canonicalize_context)
libselinux/src/checkAccess.c +0 -1
@@ -99,7 +99,6 @@ int selinux_check_passwd_access(access_vector_t requested)return status; } -hidden_def (selinux_check_passwd_access)int checkPasswdAccess (access_vector_t requested) {
libselinux/src/check_context.c +0 -2
@@ -31,7 +31,6 @@ int security_check_context_raw(const char * con)return 0 ; } -hidden_def (security_check_context_raw)int security_check_context (const char * con) {
@@ -48,4 +47,3 @@ int security_check_context(const char * con)return ret; } -hidden_def (security_check_context)
libselinux/src/checkreqprot.c +0 -1
@@ -37,4 +37,3 @@ int security_get_checkreqprot(void)return checkreqprot; } -hidden_def (security_get_checkreqprot);
libselinux/src/compute_av.c +0 -4
@@ -80,7 +80,6 @@ int security_compute_av_flags_raw(const char * scon,return ret; } -hidden_def(security_compute_av_flags_raw) int security_compute_av_raw(const char * scon, const char * tcon,
@@ -107,7 +106,6 @@ int security_compute_av_raw(const char * scon,return ret; } -hidden_def(security_compute_av_raw) int security_compute_av_flags(const char * scon, const char * tcon,
@@ -134,7 +132,6 @@ int security_compute_av_flags(const char * scon,return ret; } -hidden_def(security_compute_av_flags) int security_compute_av(const char * scon, const char * tcon,
@@ -162,4 +159,3 @@ int security_compute_av(const char * scon,return ret; } -hidden_def (security_compute_av)
libselinux/src/compute_create.c +0 -4
@@ -105,7 +105,6 @@ int security_compute_create_name_raw(const char * scon,close (fd);return ret; } -hidden_def(security_compute_create_name_raw) int security_compute_create_raw(const char * scon, const char * tcon,
@@ -115,7 +114,6 @@ int security_compute_create_raw(const char * scon,return security_compute_create_name_raw (scon, tcon, tclass,NULL , newcon); } -hidden_def(security_compute_create_raw) int security_compute_create_name(const char * scon, const char * tcon,
@@ -146,7 +144,6 @@ int security_compute_create_name(const char * scon,return ret; } -hidden_def(security_compute_create_name) int security_compute_create(const char * scon, const char * tcon,
@@ -155,4 +152,3 @@ int security_compute_create(const char * scon, {return security_compute_create_name (scon, tcon, tclass,NULL , newcon); } -hidden_def (security_compute_create)
libselinux/src/compute_member.c +0 -1
@@ -60,7 +60,6 @@ int security_compute_member_raw(const char * scon,return ret; } -hidden_def(security_compute_member_raw) int security_compute_member(const char * scon, const char * tcon,
libselinux/src/compute_relabel.c +0 -1
@@ -60,7 +60,6 @@ int security_compute_relabel_raw(const char * scon,return ret; } -hidden_def(security_compute_relabel_raw) int security_compute_relabel(const char * scon, const char * tcon,
libselinux/src/compute_user.c +0 -2
@@ -80,7 +80,6 @@ int security_compute_user_raw(const char * scon,return ret; } -hidden_def (security_compute_user_raw)int security_compute_user (const char * scon,const char *user,char *** con)
@@ -110,4 +109,3 @@ int security_compute_user(const char * scon,return ret; } -hidden_def (security_compute_user)
libselinux/src/context.c +2 -7
@@ -82,7 +82,6 @@ context_t context_new(const char *str)return 0 ; } -hidden_def (context_new)static void conditional_free (char **v) {
@@ -113,7 +112,6 @@ void context_free(context_t context) } } -hidden_def (context_free)/* * Return a pointer to the string value of the context.
@@ -144,7 +142,6 @@ char *context_str(context_t context)return n->current_str; } -hidden_def (context_str)/* Returns nonzero iff failed */ static int set_comp (context_private_t * n,int idx,const char *str)
@@ -176,8 +173,7 @@ const char * context_ ## name ## _get(context_t context) \ { \context_private_t *n = context->ptr; \return n->component[tag]; \ -} \ -hidden_def(context_ ## name ## _get) +} def_get(type, COMP_TYPE)def_get (user,COMP_USER )
@@ -187,8 +183,7 @@ def_get(type, COMP_TYPE) int context_ ## name ## _set(context_t context, const char* str) \ { \ return set_comp(context->ptr,tag,str);\ -} \ -hidden_def(context_ ## name ## _set) +} def_set(type, COMP_TYPE) def_set(role, COMP_ROLE)def_set (user,COMP_USER )
libselinux/src/context_internal.h +0 -12
@@ -1,14 +1,2 @@#include <selinux/context.h> -#include "dso.h" -hidden_proto(context_new) - hidden_proto(context_free) - hidden_proto(context_str) - hidden_proto(context_type_set) - hidden_proto(context_type_get) - hidden_proto(context_role_set) - hidden_proto(context_role_get) - hidden_proto(context_user_set) - hidden_proto(context_user_get) - hidden_proto(context_range_set) - hidden_proto(context_range_get)
libselinux/src/deny_unknown.c +0 -1
@@ -37,4 +37,3 @@ int security_deny_unknown(void)return deny_unknown; } -hidden_def (security_deny_unknown);
libselinux/src/disable.c +0 -1
@@ -35,4 +35,3 @@ int security_disable(void)return 0 ; } -hidden_def (security_disable)
libselinux/src/dso.h deleted +0 -23
@@ -1,23 +0,0 @@ -#ifndef _SELINUX_DSO_H -#define _SELINUX_DSO_H 1 - -#ifdef SHARED -# define hidden __attribute__ ((visibility ("hidden"))) -# define hidden_proto (fct) __hidden_proto (fct, fct##_internal) -# define __hidden_proto (fct, internal) \ - extern __typeof (fct) internal; \ - extern __typeof (fct) fct __asm (#internal) hidden; -# if defined(__alpha__) || defined(__mips__) -# define hidden_def (fct) \ - asm (".globl " #fct "\n" #fct " = " #fct "_internal"); -# else -# define hidden_def (fct) \ - asm (".globl " #fct "\n.set " #fct ", " #fct "_internal"); -#endif -#else -# define hidden -# define hidden_proto (fct) -# define hidden_def (fct) -#endif - -#endif
libselinux/src/enabled.c +0 -2
@@ -20,7 +20,6 @@ int is_selinux_enabled(void)#endif } -hidden_def (is_selinux_enabled)/* * Function: is_selinux_mls_enabled()
@@ -55,4 +54,3 @@ int is_selinux_mls_enabled(void)return enabled; } -hidden_def (is_selinux_mls_enabled)
libselinux/src/fgetfilecon.c +0 -1
@@ -49,7 +49,6 @@ int fgetfilecon_raw(int fd, char ** context)return ret; } -hidden_def (fgetfilecon_raw)int fgetfilecon (int fd,char ** context) {
libselinux/src/freecon.c +0 -1
@@ -8,4 +8,3 @@ void freecon(char * con)free (con); } -hidden_def (freecon)
libselinux/src/freeconary.c +0 -1
@@ -16,4 +16,3 @@ void freeconary(char ** con)free (con); } -hidden_def (freeconary)
libselinux/src/fsetfilecon.c +0 -1
@@ -25,7 +25,6 @@ int fsetfilecon_raw(int fd, const char * context)return rc; } -hidden_def (fsetfilecon_raw)int fsetfilecon (int fd,const char *context) {
libselinux/src/get_context_list.c +0 -3
@@ -52,7 +52,6 @@ int get_default_context_with_role(const char *user,return rc; } -hidden_def(get_default_context_with_role) int get_default_context_with_rolelevel(const char *user, const char *role,
@@ -385,7 +384,6 @@ int get_ordered_context_list_with_level(const char *user,return rc; } -hidden_def(get_ordered_context_list_with_level) int get_default_context_with_level(const char *user, const char *level,
@@ -497,4 +495,3 @@ int get_ordered_context_list(const char *user, goto out; } -hidden_def (get_ordered_context_list)
libselinux/src/get_context_list_internal.h +0 -4
@@ -1,6 +1,2 @@#include <selinux/get_context_list.h> -#include "dso.h" -hidden_proto(get_ordered_context_list) - hidden_proto(get_ordered_context_list_with_level) - hidden_proto(get_default_context_with_role)
libselinux/src/get_default_type_internal.h +0 -2
@@ -1,4 +1,2 @@#include <selinux/get_default_type.h> -#include "dso.h" -hidden_proto (selinux_default_type_path)
libselinux/src/get_initial_context.c +0 -2
@@ -53,7 +53,6 @@ int security_get_initial_context_raw(const char * name, char ** con)return ret; } -hidden_def (security_get_initial_context_raw)int security_get_initial_context (const char * name,char ** con) {
@@ -69,4 +68,3 @@ int security_get_initial_context(const char * name, char ** con)return ret; } -hidden_def (security_get_initial_context)
libselinux/src/getenforce.c +0 -1
@@ -37,4 +37,3 @@ int security_getenforce(void)return !!enforce; } -hidden_def (security_getenforce)
libselinux/src/getfilecon.c +0 -2
@@ -49,7 +49,6 @@ int getfilecon_raw(const char *path, char ** context)return ret; } -hidden_def (getfilecon_raw)int getfilecon (const char *path,char ** context) {
@@ -70,4 +69,3 @@ int getfilecon(const char *path, char ** context)return ret; } -hidden_def (getfilecon)
libselinux/src/getpeercon.c +0 -1
@@ -43,7 +43,6 @@ int getpeercon_raw(int fd, char ** context)return ret; } -hidden_def (getpeercon_raw)int getpeercon (int fd,char ** context) {
libselinux/src/init.c +0 -4
@@ -12,7 +12,6 @@#include <stdint.h> #include <limits.h> -#include "dso.h" #include "policy.h" #include "selinux_internal.h" #include "setrans_internal.h"
@@ -79,7 +78,6 @@ int selinuxfs_exists(void)fclose (fp);return exists; } -hidden_def (selinuxfs_exists)static void init_selinuxmnt (void ) {
@@ -138,14 +136,12 @@ void fini_selinuxmnt(void) selinux_mnt =NULL ; } -hidden_def (fini_selinuxmnt)void set_selinuxmnt (const char *mnt) { selinux_mnt =strdup (mnt); } -hidden_def (set_selinuxmnt)static void init_lib (void ) __attribute__ ((constructor));static void init_lib (void )
libselinux/src/label_internal.h +9 -10
@@ -13,7 +13,6 @@#include <stdio.h> #include <selinux/selinux.h> #include <selinux/label.h> -#include "dso.h" #include "sha1.h" #if defined(ANDROID ) || defined(__APPLE__)
@@ -26,22 +25,22 @@*/ int selabel_file_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_media_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_x_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_db_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_property_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_service_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;/* * Labeling internal structures
@@ -120,14 +119,14 @@ struct selabel_handle {*/ extern int selabel_validate (struct selabel_handle *rec, - struct selabel_lookup_rec *contexts) hidden; +struct selabel_lookup_rec *contexts) ;/* * Compatibility support */ extern int myprintf_compat;extern void __attribute__ ((format (printf,1 ,2 ))) -(*myprintf) (const char *fmt, ...) hidden; +(*myprintf) (const char *fmt, ...) ; #define COMPAT_LOG(type, fmt...) if (myprintf_compat) \ myprintf(fmt); \
@@ -137,7 +136,7 @@ extern void __attribute__ ((format(printf, 1, 2)))extern int compat_validate (struct selabel_handle *rec,struct selabel_lookup_rec *contexts, - const char *path, unsigned lineno) hidden; +const char *path,unsigned lineno) ;/* * The read_spec_entries function may be used to
libselinux/src/label_support.c +3 -3
@@ -63,7 +63,7 @@ static inline int read_spec_entry(char **entry, char **ptr, int *len, const char* This function calls read_spec_entry() to do the actual string processing. * As such, can return anything from that function as well. */ -int hidden read_spec_entries(char *line_buf, const char **errbuf, int num_args, ...) +int read_spec_entries (char *line_buf,const char **errbuf,int num_args, ...) {char **spec_entry, *buf_p;int len, rc, items, entry_len =0 ;
@@ -113,7 +113,7 @@ int hidden read_spec_entries(char *line_buf, const char **errbuf, int num_args, }/* Once all the specfiles are in the hash_buf, generate the hash. */ -void hidden digest_gen_hash(struct selabel_digest *digest) +void digest_gen_hash (struct selabel_digest *digest) {Sha1Context context;
@@ -141,7 +141,7 @@ void hidden digest_gen_hash(struct selabel_digest *digest)* * Return %0 on success, -%1 with @errno set on failure. */ -int hidden digest_add_specfile(struct selabel_digest *digest, FILE *fp, +int digest_add_specfile (struct selabel_digest *digest,FILE *fp,char *from_addr,size_t buf_len,const char *path) {
libselinux/src/lgetfilecon.c +0 -1
@@ -49,7 +49,6 @@ int lgetfilecon_raw(const char *path, char ** context)return ret; } -hidden_def (lgetfilecon_raw)int lgetfilecon (const char *path,char ** context) {
libselinux/src/load_policy.c +0 -2
@@ -45,7 +45,6 @@ int security_load_policy(void *data, size_t len)return 0 ; } -hidden_def(security_load_policy)#ifndef ANDROID #undef max
@@ -213,7 +212,6 @@ int selinux_mkload_policy(int preservebools __attribute__((unused)))return rc; } -hidden_def (selinux_mkload_policy)/* * Mount point for selinuxfs.
libselinux/src/lsetfilecon.c +0 -1
@@ -25,7 +25,6 @@ int lsetfilecon_raw(const char *path, const char * context)return rc; } -hidden_def (lsetfilecon_raw)int lsetfilecon (const char *path,const char *context) {
libselinux/src/matchpathcon.c +1 -2
@@ -322,7 +322,7 @@ static void matchpathcon_thread_destructor(void __attribute__((unused)) *ptr)void __attribute__((destructor))matchpathcon_lib_destructor (void ); -void hidden __attribute__((destructor)) matchpathcon_lib_destructor(void) +void __attribute__((destructor))matchpathcon_lib_destructor (void ) {if (destructor_key_initialized)__selinux_key_delete (destructor_key);
@@ -351,7 +351,6 @@ int matchpathcon_init_prefix(const char *path, const char *subset)return hnd ?0 :-1 ; } -hidden_def (matchpathcon_init_prefix)int matchpathcon_init (const char *path) {
libselinux/src/policyvers.c +0 -2
@@ -7,7 +7,6 @@#include "selinux_internal.h" #include <stdio.h> #include "policy.h" -#include "dso.h" #include <limits.h> int security_policyvers (void )
@@ -42,4 +41,3 @@ int security_policyvers(void)return vers; } -hidden_def (security_policyvers)
libselinux/src/procattr.c +1 -20
@@ -57,7 +57,7 @@ static void procattr_thread_destructor(void __attribute__((unused)) *unused)void __attribute__((destructor))procattr_destructor (void ); -void hidden __attribute__((destructor)) procattr_destructor(void) +void __attribute__((destructor))procattr_destructor (void ) {if (destructor_key_initialized)__selinux_key_delete (destructor_key);
@@ -345,22 +345,3 @@ all_selfattr_def(con, current) all_selfattr_def(sockcreatecon, sockcreate)all_selfattr_def (keycreatecon, keycreate) - hidden_def(getcon_raw) - hidden_def(getcon) - hidden_def(getexeccon_raw) - hidden_def(getfilecon_raw) - hidden_def(getfilecon) - hidden_def(getfscreatecon_raw) - hidden_def(getkeycreatecon_raw) - hidden_def(getpeercon_raw) - hidden_def(getpidcon_raw) - hidden_def(getprevcon_raw) - hidden_def(getprevcon) - hidden_def(getsockcreatecon_raw) - hidden_def(setcon_raw) - hidden_def(setexeccon_raw) - hidden_def(setexeccon) - hidden_def(setfilecon_raw) - hidden_def(setfscreatecon_raw) - hidden_def(setkeycreatecon_raw) - hidden_def(setsockcreatecon_raw)
libselinux/src/regex.h +10 -11
@@ -10,7 +10,6 @@#include <pcre.h> #endif -#include "dso.h" enum {REGEX_MATCH ,REGEX_MATCH_PARTIAL ,
@@ -42,7 +41,7 @@ struct mmap_area;* expressions are not portable across architectures that do not have a * matching arch-string. */ -char const *regex_arch_string (void ) hidden; +char const *regex_arch_string (void ) ;/** * regex_verison returns the version string of the underlying regular
@@ -55,12 +54,12 @@ char const *regex_arch_string(void) hidden;* * It may return NULL on error. */ -char const *regex_version (void ) hidden; +char const *regex_version (void ) ;/** * This constructor function allocates a buffer for a regex_data structure. * The buffer is being initialized with zeroes. */ -struct regex_data *regex_data_create (void ) hidden; +struct regex_data *regex_data_create (void ) ;/** * This complementary destructor function frees the a given regex_data buffer. * It also frees any non NULL member pointers with the appropriate pcreX_X_free
@@ -68,7 +67,7 @@ struct regex_data *regex_data_create(void) hidden;* the pcre_extra data conditionally. Calling this function on a NULL pointer is * save. */ -void regex_data_free(struct regex_data *regex) hidden; +void regex_data_free (struct regex_data *regex) ;/** * This function compiles the regular expression. Additionally, it prepares * data structures required by the different underlying engines. For PCRE
@@ -88,7 +87,7 @@ void regex_data_free(struct regex_data *regex) hidden;* @retval -1 on error */ int regex_prepare_data (struct regex_data **regex,char const *pattern_string, - struct regex_error_data *errordata) hidden; +struct regex_error_data *errordata) ;/** * This function loads a serialized precompiled pattern from a contiguous * data region given by map_area.
@@ -109,7 +108,7 @@ int regex_prepare_data(struct regex_data **regex, char const *pattern_string,int regex_load_mmap (struct mmap_area *map_area,struct regex_data **regex,int do_load_precompregex, - bool *regex_compiled) hidden; +bool *regex_compiled) ;/** * This function stores a precompiled regular expression to a file. * In the case of PCRE, it just dumps the binary representation of the
@@ -122,7 +121,7 @@ int regex_load_mmap(struct mmap_area *map_area,* the output file (ignored by PCRE1 back-end). */ int regex_writef (struct regex_data *regex,FILE *fp, - int do_write_precompregex) hidden; +int do_write_precompregex) ;/** * This function applies a precompiled pattern to a subject string and * returns whether or not a match was found.
@@ -139,7 +138,7 @@ int regex_writef(struct regex_data *regex, FILE *fp,* regular expression */ int regex_match (struct regex_data *regex,char const *subject, - int partial) hidden; +int partial) ;/** * This function compares two compiled regular expressions (regex1 and regex2). * It compares the binary representations of the compiled patterns. It is a very
@@ -150,7 +149,7 @@ int regex_match(struct regex_data *regex, char const *subject,* the same * @retval SELABEL_INCOMPARABLE otherwise */ -int regex_cmp(struct regex_data *regex1, struct regex_data *regex2) hidden; +int regex_cmp (struct regex_data *regex1,struct regex_data *regex2) ;/** * This function takes the error data returned by regex_prepare_data and turns * it in to a human readable error message.
@@ -163,5 +162,5 @@ int regex_cmp(struct regex_data *regex1, struct regex_data *regex2) hidden;* @arg buf_size Total size of the given buffer in bytes. */ void regex_format_error (struct regex_error_data const *error_data,char *buffer, - size_t buf_size) hidden; +size_t buf_size) ;#endif /* SRC_REGEX_H_ */
libselinux/src/reject_unknown.c +0 -1
@@ -37,4 +37,3 @@ int security_reject_unknown(void)return reject_unknown; } -hidden_def (security_reject_unknown);
libselinux/src/selinux_check_securetty_context.c +0 -1
@@ -50,4 +50,3 @@ int selinux_check_securetty_context(const char * tty_context)return found; } -hidden_def (selinux_check_securetty_context)
libselinux/src/selinux_config.c +0 -36
@@ -128,7 +128,6 @@ int selinux_getenforcemode(int *enforce)return ret; } -hidden_def (selinux_getenforcemode)static char *selinux_policytype;
@@ -141,7 +140,6 @@ int selinux_getpolicytype(char **type)return *type ?0 :-1 ; } -hidden_def (selinux_getpolicytype)static int setpolicytype (const char *type) {
@@ -249,7 +247,6 @@ void selinux_reset_config(void)init_selinux_config (); } -hidden_def (selinux_reset_config)static const char *get_path (int idx) {
@@ -262,7 +259,6 @@ const char *selinux_default_type_path(void)return get_path (DEFAULT_TYPE ); } -hidden_def (selinux_default_type_path)const char *selinux_policy_root (void ) {
@@ -305,42 +301,36 @@ const char *selinux_path(void)return selinux_rootpath; } -hidden_def (selinux_path)const char *selinux_default_context_path (void ) {return get_path (DEFAULT_CONTEXTS ); } -hidden_def (selinux_default_context_path)const char *selinux_securetty_types_path (void ) {return get_path (SECURETTY_TYPES ); } -hidden_def (selinux_securetty_types_path)const char *selinux_failsafe_context_path (void ) {return get_path (FAILSAFE_CONTEXT ); } -hidden_def (selinux_failsafe_context_path)const char *selinux_removable_context_path (void ) {return get_path (REMOVABLE_CONTEXT ); } -hidden_def (selinux_removable_context_path)const char *selinux_binary_policy_path (void ) {return get_path (BINPOLICY ); } -hidden_def (selinux_binary_policy_path)const char *selinux_current_policy_path (void ) {
@@ -365,35 +355,30 @@ const char *selinux_current_policy_path(void)return policy_path; } -hidden_def (selinux_current_policy_path)const char *selinux_file_context_path (void ) {return get_path (FILE_CONTEXTS ); } -hidden_def (selinux_file_context_path)const char *selinux_homedir_context_path (void ) {return get_path (HOMEDIR_CONTEXTS ); } -hidden_def (selinux_homedir_context_path)const char *selinux_media_context_path (void ) {return get_path (MEDIA_CONTEXTS ); } -hidden_def (selinux_media_context_path)const char *selinux_customizable_types_path (void ) {return get_path (CUSTOMIZABLE_TYPES ); } -hidden_def (selinux_customizable_types_path)const char *selinux_contexts_path (void ) {
@@ -405,7 +390,6 @@ const char *selinux_user_contexts_path(void)return get_path (USER_CONTEXTS ); } -hidden_def (selinux_user_contexts_path)/* Deprecated as local policy booleans no longer supported. */ const char *selinux_booleans_path (void )
@@ -413,7 +397,6 @@ const char *selinux_booleans_path(void)return get_path (BOOLEANS ); } -hidden_def (selinux_booleans_path)/* Deprecated as no longer supported. */ const char *selinux_users_path (void )
@@ -421,127 +404,108 @@ const char *selinux_users_path(void)return get_path (USERS_DIR ); } -hidden_def (selinux_users_path)const char *selinux_usersconf_path (void ) {return get_path (SEUSERS ); } -hidden_def (selinux_usersconf_path)const char *selinux_translations_path (void ) {return get_path (TRANSLATIONS ); } -hidden_def (selinux_translations_path)const char *selinux_colors_path (void ) {return get_path (COLORS ); } -hidden_def (selinux_colors_path)const char *selinux_netfilter_context_path (void ) {return get_path (NETFILTER_CONTEXTS ); } -hidden_def (selinux_netfilter_context_path)const char *selinux_file_context_homedir_path (void ) {return get_path (FILE_CONTEXTS_HOMEDIR ); } -hidden_def (selinux_file_context_homedir_path)const char *selinux_file_context_local_path (void ) {return get_path (FILE_CONTEXTS_LOCAL ); } -hidden_def (selinux_file_context_local_path)const char *selinux_x_context_path (void ) {return get_path (X_CONTEXTS ); } -hidden_def (selinux_x_context_path)const char *selinux_virtual_domain_context_path (void ) {return get_path (VIRTUAL_DOMAIN ); } -hidden_def (selinux_virtual_domain_context_path)const char *selinux_virtual_image_context_path (void ) {return get_path (VIRTUAL_IMAGE ); } -hidden_def (selinux_virtual_image_context_path)const char *selinux_lxc_contexts_path (void ) {return get_path (LXC_CONTEXTS ); } -hidden_def (selinux_lxc_contexts_path)const char *selinux_openrc_contexts_path (void ) {return get_path (OPENRC_CONTEXTS ); } -hidden_def (selinux_openrc_contexts_path)const char *selinux_openssh_contexts_path (void ) {return get_path (OPENSSH_CONTEXTS ); } -hidden_def (selinux_openssh_contexts_path)const char *selinux_snapperd_contexts_path (void ) {return get_path (SNAPPERD_CONTEXTS ); } -hidden_def (selinux_snapperd_contexts_path)const char *selinux_systemd_contexts_path (void ) {return get_path (SYSTEMD_CONTEXTS ); } -hidden_def (selinux_systemd_contexts_path)const char *selinux_booleans_subs_path (void ) {return get_path (BOOLEAN_SUBS ); } -hidden_def (selinux_booleans_subs_path)const char *selinux_file_context_subs_path (void ) {return get_path (FILE_CONTEXT_SUBS ); } -hidden_def (selinux_file_context_subs_path)const char *selinux_file_context_subs_dist_path (void ) {return get_path (FILE_CONTEXT_SUBS_DIST ); } -hidden_def (selinux_file_context_subs_dist_path)const char *selinux_sepgsql_context_path (void ) {return get_path (SEPGSQL_CONTEXTS ); } -hidden_def (selinux_sepgsql_context_path)
libselinux/src/selinux_internal.h +5 -112
125 lines not on this page · raw message
libselinux/src/setenforce.c +0 -1
@@ -34,4 +34,3 @@ int security_setenforce(int value)return 0 ; } -hidden_def (security_setenforce)
libselinux/src/setfilecon.c +0 -1
@@ -25,7 +25,6 @@ int setfilecon_raw(const char *path, const char * context)return rc; } -hidden_def (setfilecon_raw)int setfilecon (const char *path,const char *context) {
libselinux/src/setrans_client.c +1 -7
@@ -19,7 +19,6 @@#include <ctype.h> #include <unistd.h> #include <sys/uio.h> -#include "dso.h" #include "selinux_internal.h" #include "setrans_internal.h"
@@ -260,7 +259,7 @@ static void setrans_thread_destructor(void __attribute__((unused)) *unused)void __attribute__((destructor))setrans_lib_destructor (void ); -void hidden __attribute__((destructor)) setrans_lib_destructor(void) +void __attribute__((destructor))setrans_lib_destructor (void ) {if (!has_setrans)return ;
@@ -327,7 +326,6 @@ int selinux_trans_to_raw_context(const char * trans,return *rawp ?0 :-1 ; } -hidden_def (selinux_trans_to_raw_context)int selinux_raw_to_trans_context (const char * raw,char ** transp)
@@ -369,7 +367,6 @@ int selinux_raw_to_trans_context(const char * raw,return *transp ?0 :-1 ; } -hidden_def (selinux_raw_to_trans_context)int selinux_raw_context_to_color (const char * raw,char **transp) {
@@ -410,7 +407,6 @@ int selinux_raw_context_to_color(const char * raw, char **transp)return *transp ?0 :-1 ; } -hidden_def(selinux_raw_context_to_color)#else /*DISABLE_SETRANS*/ int selinux_trans_to_raw_context(const char * trans,
@@ -426,7 +422,6 @@ int selinux_trans_to_raw_context(const char * trans,return *rawp ?0 :-1 ; } -hidden_def (selinux_trans_to_raw_context)int selinux_raw_to_trans_context (const char * raw,char ** transp)
@@ -440,5 +435,4 @@ int selinux_raw_to_trans_context(const char * raw, return *transp ? 0 : -1; } -hidden_def(selinux_raw_to_trans_context)#endif /*DISABLE_SETRANS*/
libselinux/src/seusers.c +1 -1
@@ -88,7 +88,7 @@ static int process_seusers(const char *buffer,return -2 ;/* error */ } -int require_seusers hidden = 0; +int require_seusers =0 ;#include <pwd.h> #include <grp.h>
libselinux/src/sha1.c +3 -4
@@ -23,7 +23,6 @@/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "sha1.h" -#include "dso.h" #include <memory.h> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -126,7 +125,7 @@ void// // Initialises an SHA1 Context. Use this to initialise/reset a context. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Initialise ( Sha1Context* Context
@@ -148,7 +147,7 @@ void hidden// Adds data to the SHA1 context. This will process the data and update the internal state of the context. Keep on // calling this function until all the data has been added. Then call Sha1Finalise to calculate the hash. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Update ( Sha1Context* Context,
@@ -191,7 +190,7 @@ void hidden// Performs the final calculation of the hash and returns the digest (20 byte buffer containing 160bit hash). After // calling this, Sha1Initialised must be used to reuse the context. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Finalise ( Sha1Context* Context,
libselinux/src/stringrep.c +0 -1
@@ -180,7 +180,6 @@ void selinux_flush_class_cache(void) discover_class_cache =NULL ; } -hidden_def (selinux_flush_class_cache)security_class_t string_to_security_class (const char *s) {
libselinux/src/validatetrans.c +0 -2
@@ -57,7 +57,6 @@ out:return ret; } -hidden_def(security_validatetrans_raw) int security_validatetrans(const char *scon, const char *tcon,
@@ -91,4 +90,3 @@ out:return ret; } -hidden_def (security_validatetrans)
Signature · 1 line
2.17.1
PATCH 2/3 Makefile: add -fno-semantic-interposition
In reply to [email protected]From: William Roberts <[email protected]>
Add -fno-semantic-interposition to CFLAGS. This will restore the DSO infrastructures protections to insure internal callers of exported symbols call into libselinux and not something laoding first in the library list.
Clang has this enabled by default.
--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/Makefile +1 -1
@@ -65,7 +65,7 @@ EXTRA_CFLAGS = -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nan -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 \ - -Wstrict-overflow=5 + -Wstrict-overflow=5 -fno-semantic-interposition else EXTRA_CFLAGS = -Wunused-command-line-argument endif
Signature · 1 line
2.17.1
Stephen Smalley
maintainerRe: [PATCH 2/3] Makefile: add -fno-semantic-interposition
Quoted 11 lines · On Thu, Feb 27, 2020 at 6:01 PM <[email protected]> wrote:
From: William Roberts <[email protected]>
Add -fno-semantic-interposition to CFLAGS. This will restore the DSO infrastructures protections to insure internal callers of exported symbols call into libselinux and not something laoding first in the library list.
Clang has this enabled by default.
Signed-off-by William Roberts <[email protected]>
I'm fine with this but since Nicolas pointed out the option of using -Bsymbolic to
the linker as an alternative to hidden_def/hidden_proto in
https://github.com/SELinuxProject/selinux/issues/204#issuecomment-591092288
I was wondering how they differ. I guess -Bsymbolic only affects the linker while -fno-semantic-interposition
permits the compiler to further optimize the code.
Re: [PATCH 2/3] Makefile: add -fno-semantic-interposition
Quoted 14 lines · Stephen Smalley
Quoted 11 lines · On Thu, Feb 27, 2020 at 6:01 PM <[email protected]> wrote:
From: William Roberts <[email protected]>
Add -fno-semantic-interposition to CFLAGS. This will restore the DSO infrastructures protections to insure internal callers of exported symbols call into libselinux and not something laoding first in the library list.
Clang has this enabled by default.
Signed-off-by William Roberts <[email protected]>
Quoted 7 lines
I'm fine with this but since Nicolas pointed out the option of using -Bsymbolic to
the linker as an alternative to hidden_def/hidden_proto in
https://github.com/SELinuxProject/selinux/issues/204#issuecomment-591092288
I was wondering how they differ. I guess -Bsymbolic only affects the linker while -fno-semantic-interposition
permits the compiler to further optimize the code.
That's my understanding of the difference as well. -B is only link time, so the compiler can't
really optimize the calls, but IIUC the compiler can only optimize whats in the compilation
unit, so it can only optimize call sites for calls within the compilation unit.
-B also only works for elf builds, so we would conditionally need to modify LDFLAGS based
on host type. The compiler option is just a clang/gcc split, which is already there. To go
to symbolic we would have to conditionally set that... a tad bit more work :-p
Re: [PATCH 2/3] Makefile: add -fno-semantic-interposition
Quoted 31 lines · William Roberts
Quoted 14 lines · Stephen Smalley
Quoted 11 lines · On Thu, Feb 27, 2020 at 6:01 PM <[email protected]> wrote:
From: William Roberts <[email protected]>
Add -fno-semantic-interposition to CFLAGS. This will restore the DSO infrastructures protections to insure internal callers of exported symbols call into libselinux and not something laoding first in the library list.
Clang has this enabled by default.
Signed-off-by William Roberts <[email protected]>Quoted 7 lines
I'm fine with this but since Nicolas pointed out the option of using -Bsymbolic to
the linker as an alternative to hidden_def/hidden_proto in
https://github.com/SELinuxProject/selinux/issues/204#issuecomment-591092288
I was wondering how they differ. I guess -Bsymbolic only affects the linker while -fno-semantic-interposition
permits the compiler to further optimize the code.That's my understanding of the difference as well. -B is only link time, so the compiler can't
really optimize the calls, but IIUC the compiler can only optimize whats in the compilation
unit, so it can only optimize call sites for calls within the compilation unit.
Quoted 5 lines
-B also only works for elf builds, so we would conditionally need to modify LDFLAGS based
on host type. The compiler option is just a clang/gcc split, which is already there. To go
to symbolic we would have to conditionally set that... a tad bit more work :-p
I am not very familiar with -Bsymbolic and did not know about -fno-semantic-interposition before a few days ago. As far as I understand, -Bsymbolic puts an entry of type "SYMBOLIC" in the dynamic section of the .so file, which changes the behavior of the dynamic linker at link time without modifying anything in the build-time linking process. It is only compatible with ELF files and seems quite uncommon.
With this in mind, -fno-semantic-interposition seems more powerful and better suited for what we want to achieve (to optimize the compilation). I agree with the approach of this patchset and would have given an Acked-By if there weren't an issue with "-z,relro-Wl" ;)
Thanks for working on this!
Nicolas
PATCH v4 1/1 libselinux: drop dso.h
Version 4:
- Fix linker option warnings.
- Move map file to begining of options.
Version 3:
- Add more symbols that should be dropped from the dso:
- map_class;
- map_decision;
- map_perm;
Version 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso:
- dir_xattr_list
- myprintf_compat
- unmap_class
- unmap_perm
This four part patch series drops the dso.h and hidden_* macros.
The old dso.h functionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.
The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition
[PATCH v4 1/4] dso: drop hidden_proto and hidden_def [PATCH v4 2/4] Makefile: add -fno-semantic-interposition [PATCH v4 3/4] Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from map
PATCH v4 1/4 dso: drop hidden_proto and hidden_def
From: William Roberts <[email protected]>
--- libselinux/src/avc.c | 5 - libselinux/src/avc_internal.h | 52 ++++---- libselinux/src/avc_sidtab.h | 11 +- libselinux/src/booleans.c | 5 - libselinux/src/callbacks.h | 11 +- libselinux/src/canonicalize_context.c | 2 - libselinux/src/checkAccess.c | 1 - libselinux/src/check_context.c | 2 - libselinux/src/checkreqprot.c | 1 - libselinux/src/compute_av.c | 4 - libselinux/src/compute_create.c | 4 - libselinux/src/compute_member.c | 1 - libselinux/src/compute_relabel.c | 1 - libselinux/src/compute_user.c | 2 - libselinux/src/context.c | 9 +- libselinux/src/context_internal.h | 12 -- libselinux/src/deny_unknown.c | 1 - libselinux/src/disable.c | 1 - libselinux/src/dso.h | 23 ---- libselinux/src/enabled.c | 2 - libselinux/src/fgetfilecon.c | 1 - libselinux/src/freecon.c | 1 - libselinux/src/freeconary.c | 1 - libselinux/src/fsetfilecon.c | 1 - libselinux/src/get_context_list.c | 3 - libselinux/src/get_context_list_internal.h | 4 - libselinux/src/get_default_type_internal.h | 2 - libselinux/src/get_initial_context.c | 2 - libselinux/src/getenforce.c | 1 - libselinux/src/getfilecon.c | 2 - libselinux/src/getpeercon.c | 1 - libselinux/src/init.c | 4 - libselinux/src/label_internal.h | 19 ++- libselinux/src/label_support.c | 6 +- libselinux/src/lgetfilecon.c | 1 - libselinux/src/load_policy.c | 2 - libselinux/src/lsetfilecon.c | 1 - libselinux/src/matchpathcon.c | 3 +- libselinux/src/policyvers.c | 2 - libselinux/src/procattr.c | 21 +--- libselinux/src/regex.h | 21 ++-- libselinux/src/reject_unknown.c | 1 - .../src/selinux_check_securetty_context.c | 1 - libselinux/src/selinux_config.c | 36 ------ libselinux/src/selinux_internal.h | 117 +----------------- libselinux/src/setenforce.c | 1 - libselinux/src/setfilecon.c | 1 - libselinux/src/setrans_client.c | 8 +- libselinux/src/seusers.c | 2 +- libselinux/src/sha1.c | 7 +- libselinux/src/stringrep.c | 1 - libselinux/src/validatetrans.c | 2 - 52 files changed, 69 insertions(+), 357 deletions(-) delete mode 100644 libselinux/src/dso.h
libselinux/src/avc.c +0 -5
@@ -294,7 +294,6 @@ void avc_av_stats(void) slots_used, AVC_CACHE_SLOTS, max_chain_len); } -hidden_def (avc_av_stats)static inline struct avc_node *avc_reclaim_node (void ) {
@@ -494,7 +493,6 @@ void avc_cleanup(void) { } -hidden_def (avc_cleanup)int avc_reset (void ) {
@@ -539,7 +537,6 @@ int avc_reset(void)return rc; } -hidden_def (avc_reset)void avc_destroy (void ) {
@@ -733,7 +730,6 @@ void avc_audit(security_id_t ssid, security_id_t tsid,avc_release_lock (avc_log_lock); } -hidden_def (avc_audit)static void avd_init (struct av_decision *avd)
@@ -825,7 +821,6 @@ int avc_has_perm_noaudit(security_id_t ssid,return rc; } -hidden_def(avc_has_perm_noaudit) int avc_has_perm(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t requested,
libselinux/src/avc_internal.h +23 -29
85 lines not on this page · raw message
libselinux/src/avc_sidtab.h +5 -6
@@ -7,7 +7,6 @@#include <selinux/selinux.h> #include <selinux/avc.h> -#include "dso.h" struct sidtab_node {struct security_id sid_s;
@@ -24,13 +23,13 @@ struct sidtab { unsigned nel; }; -int sidtab_init(struct sidtab *s) hidden; -int sidtab_insert(struct sidtab *s, const char * ctx) hidden; +int sidtab_init (struct sidtab *s) ; +int sidtab_insert (struct sidtab *s,const char * ctx) ;int sidtab_context_to_sid (struct sidtab *s, - const char * ctx, security_id_t * sid) hidden; +const char * ctx,security_id_t * sid) ; -void sidtab_sid_stats(struct sidtab *s, char *buf, int buflen) hidden; -void sidtab_destroy(struct sidtab *s) hidden; +void sidtab_sid_stats (struct sidtab *s,char *buf,int buflen) ; +void sidtab_destroy (struct sidtab *s) ;#endif /* _SELINUX_AVC_SIDTAB_H_ */
libselinux/src/booleans.c +0 -5
@@ -414,8 +414,3 @@ char *selinux_boolean_sub(const char *name __attribute__((unused))) }#endif -hidden_def(security_get_boolean_names) -hidden_def(selinux_boolean_sub) -hidden_def(security_get_boolean_active) -hidden_def(security_set_boolean) -hidden_def(security_commit_booleans)
libselinux/src/callbacks.h +5 -6
@@ -9,22 +9,21 @@#include <stdlib.h> #include <string.h> #include <selinux/selinux.h> -#include "dso.h" /* callback pointers */ extern int __attribute__ ((format (printf,2 ,3 ))) -(*selinux_log) (int type, const char *, ...) hidden; +(*selinux_log) (int type,const char *, ...) ;extern int -(*selinux_audit) (void *, security_class_t, char *, size_t) hidden; +(*selinux_audit) (void *,security_class_t ,char *,size_t ) ;extern int -(*selinux_validate)(char **ctx) hidden; +(*selinux_validate)(char **ctx) ;extern int -(*selinux_netlink_setenforce) (int enforcing) hidden; +(*selinux_netlink_setenforce) (int enforcing) ;extern int -(*selinux_netlink_policyload) (int seqno) hidden; +(*selinux_netlink_policyload) (int seqno) ;#endif /* _SELINUX_CALLBACKS_H_ */
libselinux/src/canonicalize_context.c +0 -2
@@ -60,7 +60,6 @@ int security_canonicalize_context_raw(const char * con,return ret; } -hidden_def (security_canonicalize_context_raw)int security_canonicalize_context (const char * con,char ** canoncon)
@@ -83,4 +82,3 @@ int security_canonicalize_context(const char * con,return ret; } -hidden_def (security_canonicalize_context)
libselinux/src/checkAccess.c +0 -1
@@ -99,7 +99,6 @@ int selinux_check_passwd_access(access_vector_t requested)return status; } -hidden_def (selinux_check_passwd_access)int checkPasswdAccess (access_vector_t requested) {
libselinux/src/check_context.c +0 -2
@@ -31,7 +31,6 @@ int security_check_context_raw(const char * con)return 0 ; } -hidden_def (security_check_context_raw)int security_check_context (const char * con) {
@@ -48,4 +47,3 @@ int security_check_context(const char * con)return ret; } -hidden_def (security_check_context)
libselinux/src/checkreqprot.c +0 -1
@@ -37,4 +37,3 @@ int security_get_checkreqprot(void)return checkreqprot; } -hidden_def (security_get_checkreqprot);
libselinux/src/compute_av.c +0 -4
@@ -80,7 +80,6 @@ int security_compute_av_flags_raw(const char * scon,return ret; } -hidden_def(security_compute_av_flags_raw) int security_compute_av_raw(const char * scon, const char * tcon,
@@ -107,7 +106,6 @@ int security_compute_av_raw(const char * scon,return ret; } -hidden_def(security_compute_av_raw) int security_compute_av_flags(const char * scon, const char * tcon,
@@ -134,7 +132,6 @@ int security_compute_av_flags(const char * scon,return ret; } -hidden_def(security_compute_av_flags) int security_compute_av(const char * scon, const char * tcon,
@@ -162,4 +159,3 @@ int security_compute_av(const char * scon,return ret; } -hidden_def (security_compute_av)
libselinux/src/compute_create.c +0 -4
@@ -105,7 +105,6 @@ int security_compute_create_name_raw(const char * scon,close (fd);return ret; } -hidden_def(security_compute_create_name_raw) int security_compute_create_raw(const char * scon, const char * tcon,
@@ -115,7 +114,6 @@ int security_compute_create_raw(const char * scon,return security_compute_create_name_raw (scon, tcon, tclass,NULL , newcon); } -hidden_def(security_compute_create_raw) int security_compute_create_name(const char * scon, const char * tcon,
@@ -146,7 +144,6 @@ int security_compute_create_name(const char * scon,return ret; } -hidden_def(security_compute_create_name) int security_compute_create(const char * scon, const char * tcon,
@@ -155,4 +152,3 @@ int security_compute_create(const char * scon, {return security_compute_create_name (scon, tcon, tclass,NULL , newcon); } -hidden_def (security_compute_create)
libselinux/src/compute_member.c +0 -1
@@ -60,7 +60,6 @@ int security_compute_member_raw(const char * scon,return ret; } -hidden_def(security_compute_member_raw) int security_compute_member(const char * scon, const char * tcon,
libselinux/src/compute_relabel.c +0 -1
@@ -60,7 +60,6 @@ int security_compute_relabel_raw(const char * scon,return ret; } -hidden_def(security_compute_relabel_raw) int security_compute_relabel(const char * scon, const char * tcon,
libselinux/src/compute_user.c +0 -2
@@ -80,7 +80,6 @@ int security_compute_user_raw(const char * scon,return ret; } -hidden_def (security_compute_user_raw)int security_compute_user (const char * scon,const char *user,char *** con)
@@ -110,4 +109,3 @@ int security_compute_user(const char * scon,return ret; } -hidden_def (security_compute_user)
libselinux/src/context.c +2 -7
@@ -82,7 +82,6 @@ context_t context_new(const char *str)return 0 ; } -hidden_def (context_new)static void conditional_free (char **v) {
@@ -113,7 +112,6 @@ void context_free(context_t context) } } -hidden_def (context_free)/* * Return a pointer to the string value of the context.
@@ -144,7 +142,6 @@ char *context_str(context_t context)return n->current_str; } -hidden_def (context_str)/* Returns nonzero iff failed */ static int set_comp (context_private_t * n,int idx,const char *str)
@@ -176,8 +173,7 @@ const char * context_ ## name ## _get(context_t context) \ { \context_private_t *n = context->ptr; \return n->component[tag]; \ -} \ -hidden_def(context_ ## name ## _get) +} def_get(type, COMP_TYPE)def_get (user,COMP_USER )
@@ -187,8 +183,7 @@ def_get(type, COMP_TYPE) int context_ ## name ## _set(context_t context, const char* str) \ { \ return set_comp(context->ptr,tag,str);\ -} \ -hidden_def(context_ ## name ## _set) +} def_set(type, COMP_TYPE) def_set(role, COMP_ROLE)def_set (user,COMP_USER )
libselinux/src/context_internal.h +0 -12
@@ -1,14 +1,2 @@#include <selinux/context.h> -#include "dso.h" -hidden_proto(context_new) - hidden_proto(context_free) - hidden_proto(context_str) - hidden_proto(context_type_set) - hidden_proto(context_type_get) - hidden_proto(context_role_set) - hidden_proto(context_role_get) - hidden_proto(context_user_set) - hidden_proto(context_user_get) - hidden_proto(context_range_set) - hidden_proto(context_range_get)
libselinux/src/deny_unknown.c +0 -1
@@ -37,4 +37,3 @@ int security_deny_unknown(void)return deny_unknown; } -hidden_def (security_deny_unknown);
libselinux/src/disable.c +0 -1
@@ -35,4 +35,3 @@ int security_disable(void)return 0 ; } -hidden_def (security_disable)
libselinux/src/dso.h deleted +0 -23
@@ -1,23 +0,0 @@ -#ifndef _SELINUX_DSO_H -#define _SELINUX_DSO_H 1 - -#ifdef SHARED -# define hidden __attribute__ ((visibility ("hidden"))) -# define hidden_proto (fct) __hidden_proto (fct, fct##_internal) -# define __hidden_proto (fct, internal) \ - extern __typeof (fct) internal; \ - extern __typeof (fct) fct __asm (#internal) hidden; -# if defined(__alpha__) || defined(__mips__) -# define hidden_def (fct) \ - asm (".globl " #fct "\n" #fct " = " #fct "_internal"); -# else -# define hidden_def (fct) \ - asm (".globl " #fct "\n.set " #fct ", " #fct "_internal"); -#endif -#else -# define hidden -# define hidden_proto (fct) -# define hidden_def (fct) -#endif - -#endif
libselinux/src/enabled.c +0 -2
@@ -20,7 +20,6 @@ int is_selinux_enabled(void)#endif } -hidden_def (is_selinux_enabled)/* * Function: is_selinux_mls_enabled()
@@ -55,4 +54,3 @@ int is_selinux_mls_enabled(void)return enabled; } -hidden_def (is_selinux_mls_enabled)
libselinux/src/fgetfilecon.c +0 -1
@@ -49,7 +49,6 @@ int fgetfilecon_raw(int fd, char ** context)return ret; } -hidden_def (fgetfilecon_raw)int fgetfilecon (int fd,char ** context) {
libselinux/src/freecon.c +0 -1
@@ -8,4 +8,3 @@ void freecon(char * con)free (con); } -hidden_def (freecon)
libselinux/src/freeconary.c +0 -1
@@ -16,4 +16,3 @@ void freeconary(char ** con)free (con); } -hidden_def (freeconary)
libselinux/src/fsetfilecon.c +0 -1
@@ -25,7 +25,6 @@ int fsetfilecon_raw(int fd, const char * context)return rc; } -hidden_def (fsetfilecon_raw)int fsetfilecon (int fd,const char *context) {
libselinux/src/get_context_list.c +0 -3
@@ -52,7 +52,6 @@ int get_default_context_with_role(const char *user,return rc; } -hidden_def(get_default_context_with_role) int get_default_context_with_rolelevel(const char *user, const char *role,
@@ -385,7 +384,6 @@ int get_ordered_context_list_with_level(const char *user,return rc; } -hidden_def(get_ordered_context_list_with_level) int get_default_context_with_level(const char *user, const char *level,
@@ -497,4 +495,3 @@ int get_ordered_context_list(const char *user, goto out; } -hidden_def (get_ordered_context_list)
libselinux/src/get_context_list_internal.h +0 -4
@@ -1,6 +1,2 @@#include <selinux/get_context_list.h> -#include "dso.h" -hidden_proto(get_ordered_context_list) - hidden_proto(get_ordered_context_list_with_level) - hidden_proto(get_default_context_with_role)
libselinux/src/get_default_type_internal.h +0 -2
@@ -1,4 +1,2 @@#include <selinux/get_default_type.h> -#include "dso.h" -hidden_proto (selinux_default_type_path)
libselinux/src/get_initial_context.c +0 -2
@@ -53,7 +53,6 @@ int security_get_initial_context_raw(const char * name, char ** con)return ret; } -hidden_def (security_get_initial_context_raw)int security_get_initial_context (const char * name,char ** con) {
@@ -69,4 +68,3 @@ int security_get_initial_context(const char * name, char ** con)return ret; } -hidden_def (security_get_initial_context)
libselinux/src/getenforce.c +0 -1
@@ -37,4 +37,3 @@ int security_getenforce(void)return !!enforce; } -hidden_def (security_getenforce)
libselinux/src/getfilecon.c +0 -2
@@ -49,7 +49,6 @@ int getfilecon_raw(const char *path, char ** context)return ret; } -hidden_def (getfilecon_raw)int getfilecon (const char *path,char ** context) {
@@ -70,4 +69,3 @@ int getfilecon(const char *path, char ** context)return ret; } -hidden_def (getfilecon)
libselinux/src/getpeercon.c +0 -1
@@ -43,7 +43,6 @@ int getpeercon_raw(int fd, char ** context)return ret; } -hidden_def (getpeercon_raw)int getpeercon (int fd,char ** context) {
libselinux/src/init.c +0 -4
@@ -12,7 +12,6 @@#include <stdint.h> #include <limits.h> -#include "dso.h" #include "policy.h" #include "selinux_internal.h" #include "setrans_internal.h"
@@ -79,7 +78,6 @@ int selinuxfs_exists(void)fclose (fp);return exists; } -hidden_def (selinuxfs_exists)static void init_selinuxmnt (void ) {
@@ -138,14 +136,12 @@ void fini_selinuxmnt(void) selinux_mnt =NULL ; } -hidden_def (fini_selinuxmnt)void set_selinuxmnt (const char *mnt) { selinux_mnt =strdup (mnt); } -hidden_def (set_selinuxmnt)static void init_lib (void ) __attribute__ ((constructor));static void init_lib (void )
libselinux/src/label_internal.h +9 -10
@@ -13,7 +13,6 @@#include <stdio.h> #include <selinux/selinux.h> #include <selinux/label.h> -#include "dso.h" #include "sha1.h" #if defined(ANDROID ) || defined(__APPLE__)
@@ -26,22 +25,22 @@*/ int selabel_file_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_media_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_x_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_db_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_property_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_service_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;/* * Labeling internal structures
@@ -120,14 +119,14 @@ struct selabel_handle {*/ extern int selabel_validate (struct selabel_handle *rec, - struct selabel_lookup_rec *contexts) hidden; +struct selabel_lookup_rec *contexts) ;/* * Compatibility support */ extern int myprintf_compat;extern void __attribute__ ((format (printf,1 ,2 ))) -(*myprintf) (const char *fmt, ...) hidden; +(*myprintf) (const char *fmt, ...) ; #define COMPAT_LOG(type, fmt...) if (myprintf_compat) \ myprintf(fmt); \
@@ -137,7 +136,7 @@ extern void __attribute__ ((format(printf, 1, 2)))extern int compat_validate (struct selabel_handle *rec,struct selabel_lookup_rec *contexts, - const char *path, unsigned lineno) hidden; +const char *path,unsigned lineno) ;/* * The read_spec_entries function may be used to
libselinux/src/label_support.c +3 -3
@@ -63,7 +63,7 @@ static inline int read_spec_entry(char **entry, char **ptr, int *len, const char* This function calls read_spec_entry() to do the actual string processing. * As such, can return anything from that function as well. */ -int hidden read_spec_entries(char *line_buf, const char **errbuf, int num_args, ...) +int read_spec_entries (char *line_buf,const char **errbuf,int num_args, ...) {char **spec_entry, *buf_p;int len, rc, items, entry_len =0 ;
@@ -113,7 +113,7 @@ int hidden read_spec_entries(char *line_buf, const char **errbuf, int num_args, }/* Once all the specfiles are in the hash_buf, generate the hash. */ -void hidden digest_gen_hash(struct selabel_digest *digest) +void digest_gen_hash (struct selabel_digest *digest) {Sha1Context context;
@@ -141,7 +141,7 @@ void hidden digest_gen_hash(struct selabel_digest *digest)* * Return %0 on success, -%1 with @errno set on failure. */ -int hidden digest_add_specfile(struct selabel_digest *digest, FILE *fp, +int digest_add_specfile (struct selabel_digest *digest,FILE *fp,char *from_addr,size_t buf_len,const char *path) {
libselinux/src/lgetfilecon.c +0 -1
@@ -49,7 +49,6 @@ int lgetfilecon_raw(const char *path, char ** context)return ret; } -hidden_def (lgetfilecon_raw)int lgetfilecon (const char *path,char ** context) {
libselinux/src/load_policy.c +0 -2
@@ -45,7 +45,6 @@ int security_load_policy(void *data, size_t len)return 0 ; } -hidden_def(security_load_policy)#ifndef ANDROID #undef max
@@ -213,7 +212,6 @@ int selinux_mkload_policy(int preservebools __attribute__((unused)))return rc; } -hidden_def (selinux_mkload_policy)/* * Mount point for selinuxfs.
libselinux/src/lsetfilecon.c +0 -1
@@ -25,7 +25,6 @@ int lsetfilecon_raw(const char *path, const char * context)return rc; } -hidden_def (lsetfilecon_raw)int lsetfilecon (const char *path,const char *context) {
libselinux/src/matchpathcon.c +1 -2
@@ -322,7 +322,7 @@ static void matchpathcon_thread_destructor(void __attribute__((unused)) *ptr)void __attribute__((destructor))matchpathcon_lib_destructor (void ); -void hidden __attribute__((destructor)) matchpathcon_lib_destructor(void) +void __attribute__((destructor))matchpathcon_lib_destructor (void ) {if (destructor_key_initialized)__selinux_key_delete (destructor_key);
@@ -351,7 +351,6 @@ int matchpathcon_init_prefix(const char *path, const char *subset)return hnd ?0 :-1 ; } -hidden_def (matchpathcon_init_prefix)int matchpathcon_init (const char *path) {
libselinux/src/policyvers.c +0 -2
@@ -7,7 +7,6 @@#include "selinux_internal.h" #include <stdio.h> #include "policy.h" -#include "dso.h" #include <limits.h> int security_policyvers (void )
@@ -42,4 +41,3 @@ int security_policyvers(void)return vers; } -hidden_def (security_policyvers)
libselinux/src/procattr.c +1 -20
@@ -57,7 +57,7 @@ static void procattr_thread_destructor(void __attribute__((unused)) *unused)void __attribute__((destructor))procattr_destructor (void ); -void hidden __attribute__((destructor)) procattr_destructor(void) +void __attribute__((destructor))procattr_destructor (void ) {if (destructor_key_initialized)__selinux_key_delete (destructor_key);
@@ -345,22 +345,3 @@ all_selfattr_def(con, current) all_selfattr_def(sockcreatecon, sockcreate)all_selfattr_def (keycreatecon, keycreate) - hidden_def(getcon_raw) - hidden_def(getcon) - hidden_def(getexeccon_raw) - hidden_def(getfilecon_raw) - hidden_def(getfilecon) - hidden_def(getfscreatecon_raw) - hidden_def(getkeycreatecon_raw) - hidden_def(getpeercon_raw) - hidden_def(getpidcon_raw) - hidden_def(getprevcon_raw) - hidden_def(getprevcon) - hidden_def(getsockcreatecon_raw) - hidden_def(setcon_raw) - hidden_def(setexeccon_raw) - hidden_def(setexeccon) - hidden_def(setfilecon_raw) - hidden_def(setfscreatecon_raw) - hidden_def(setkeycreatecon_raw) - hidden_def(setsockcreatecon_raw)
libselinux/src/regex.h +10 -11
@@ -10,7 +10,6 @@#include <pcre.h> #endif -#include "dso.h" enum {REGEX_MATCH ,REGEX_MATCH_PARTIAL ,
@@ -42,7 +41,7 @@ struct mmap_area;* expressions are not portable across architectures that do not have a * matching arch-string. */ -char const *regex_arch_string (void ) hidden; +char const *regex_arch_string (void ) ;/** * regex_verison returns the version string of the underlying regular
@@ -55,12 +54,12 @@ char const *regex_arch_string(void) hidden;* * It may return NULL on error. */ -char const *regex_version (void ) hidden; +char const *regex_version (void ) ;/** * This constructor function allocates a buffer for a regex_data structure. * The buffer is being initialized with zeroes. */ -struct regex_data *regex_data_create (void ) hidden; +struct regex_data *regex_data_create (void ) ;/** * This complementary destructor function frees the a given regex_data buffer. * It also frees any non NULL member pointers with the appropriate pcreX_X_free
@@ -68,7 +67,7 @@ struct regex_data *regex_data_create(void) hidden;* the pcre_extra data conditionally. Calling this function on a NULL pointer is * save. */ -void regex_data_free(struct regex_data *regex) hidden; +void regex_data_free (struct regex_data *regex) ;/** * This function compiles the regular expression. Additionally, it prepares * data structures required by the different underlying engines. For PCRE
@@ -88,7 +87,7 @@ void regex_data_free(struct regex_data *regex) hidden;* @retval -1 on error */ int regex_prepare_data (struct regex_data **regex,char const *pattern_string, - struct regex_error_data *errordata) hidden; +struct regex_error_data *errordata) ;/** * This function loads a serialized precompiled pattern from a contiguous * data region given by map_area.
@@ -109,7 +108,7 @@ int regex_prepare_data(struct regex_data **regex, char const *pattern_string,int regex_load_mmap (struct mmap_area *map_area,struct regex_data **regex,int do_load_precompregex, - bool *regex_compiled) hidden; +bool *regex_compiled) ;/** * This function stores a precompiled regular expression to a file. * In the case of PCRE, it just dumps the binary representation of the
@@ -122,7 +121,7 @@ int regex_load_mmap(struct mmap_area *map_area,* the output file (ignored by PCRE1 back-end). */ int regex_writef (struct regex_data *regex,FILE *fp, - int do_write_precompregex) hidden; +int do_write_precompregex) ;/** * This function applies a precompiled pattern to a subject string and * returns whether or not a match was found.
@@ -139,7 +138,7 @@ int regex_writef(struct regex_data *regex, FILE *fp,* regular expression */ int regex_match (struct regex_data *regex,char const *subject, - int partial) hidden; +int partial) ;/** * This function compares two compiled regular expressions (regex1 and regex2). * It compares the binary representations of the compiled patterns. It is a very
@@ -150,7 +149,7 @@ int regex_match(struct regex_data *regex, char const *subject,* the same * @retval SELABEL_INCOMPARABLE otherwise */ -int regex_cmp(struct regex_data *regex1, struct regex_data *regex2) hidden; +int regex_cmp (struct regex_data *regex1,struct regex_data *regex2) ;/** * This function takes the error data returned by regex_prepare_data and turns * it in to a human readable error message.
@@ -163,5 +162,5 @@ int regex_cmp(struct regex_data *regex1, struct regex_data *regex2) hidden;* @arg buf_size Total size of the given buffer in bytes. */ void regex_format_error (struct regex_error_data const *error_data,char *buffer, - size_t buf_size) hidden; +size_t buf_size) ;#endif /* SRC_REGEX_H_ */
libselinux/src/reject_unknown.c +0 -1
@@ -37,4 +37,3 @@ int security_reject_unknown(void)return reject_unknown; } -hidden_def (security_reject_unknown);
libselinux/src/selinux_check_securetty_context.c +0 -1
@@ -50,4 +50,3 @@ int selinux_check_securetty_context(const char * tty_context)return found; } -hidden_def (selinux_check_securetty_context)
libselinux/src/selinux_config.c +0 -36
@@ -128,7 +128,6 @@ int selinux_getenforcemode(int *enforce)return ret; } -hidden_def (selinux_getenforcemode)static char *selinux_policytype;
@@ -141,7 +140,6 @@ int selinux_getpolicytype(char **type)return *type ?0 :-1 ; } -hidden_def (selinux_getpolicytype)static int setpolicytype (const char *type) {
@@ -249,7 +247,6 @@ void selinux_reset_config(void)init_selinux_config (); } -hidden_def (selinux_reset_config)static const char *get_path (int idx) {
@@ -262,7 +259,6 @@ const char *selinux_default_type_path(void)return get_path (DEFAULT_TYPE ); } -hidden_def (selinux_default_type_path)const char *selinux_policy_root (void ) {
@@ -305,42 +301,36 @@ const char *selinux_path(void)return selinux_rootpath; } -hidden_def (selinux_path)const char *selinux_default_context_path (void ) {return get_path (DEFAULT_CONTEXTS ); } -hidden_def (selinux_default_context_path)const char *selinux_securetty_types_path (void ) {return get_path (SECURETTY_TYPES ); } -hidden_def (selinux_securetty_types_path)const char *selinux_failsafe_context_path (void ) {return get_path (FAILSAFE_CONTEXT ); } -hidden_def (selinux_failsafe_context_path)const char *selinux_removable_context_path (void ) {return get_path (REMOVABLE_CONTEXT ); } -hidden_def (selinux_removable_context_path)const char *selinux_binary_policy_path (void ) {return get_path (BINPOLICY ); } -hidden_def (selinux_binary_policy_path)const char *selinux_current_policy_path (void ) {
@@ -365,35 +355,30 @@ const char *selinux_current_policy_path(void)return policy_path; } -hidden_def (selinux_current_policy_path)const char *selinux_file_context_path (void ) {return get_path (FILE_CONTEXTS ); } -hidden_def (selinux_file_context_path)const char *selinux_homedir_context_path (void ) {return get_path (HOMEDIR_CONTEXTS ); } -hidden_def (selinux_homedir_context_path)const char *selinux_media_context_path (void ) {return get_path (MEDIA_CONTEXTS ); } -hidden_def (selinux_media_context_path)const char *selinux_customizable_types_path (void ) {return get_path (CUSTOMIZABLE_TYPES ); } -hidden_def (selinux_customizable_types_path)const char *selinux_contexts_path (void ) {
@@ -405,7 +390,6 @@ const char *selinux_user_contexts_path(void)return get_path (USER_CONTEXTS ); } -hidden_def (selinux_user_contexts_path)/* Deprecated as local policy booleans no longer supported. */ const char *selinux_booleans_path (void )
@@ -413,7 +397,6 @@ const char *selinux_booleans_path(void)return get_path (BOOLEANS ); } -hidden_def (selinux_booleans_path)/* Deprecated as no longer supported. */ const char *selinux_users_path (void )
@@ -421,127 +404,108 @@ const char *selinux_users_path(void)return get_path (USERS_DIR ); } -hidden_def (selinux_users_path)const char *selinux_usersconf_path (void ) {return get_path (SEUSERS ); } -hidden_def (selinux_usersconf_path)const char *selinux_translations_path (void ) {return get_path (TRANSLATIONS ); } -hidden_def (selinux_translations_path)const char *selinux_colors_path (void ) {return get_path (COLORS ); } -hidden_def (selinux_colors_path)const char *selinux_netfilter_context_path (void ) {return get_path (NETFILTER_CONTEXTS ); } -hidden_def (selinux_netfilter_context_path)const char *selinux_file_context_homedir_path (void ) {return get_path (FILE_CONTEXTS_HOMEDIR ); } -hidden_def (selinux_file_context_homedir_path)const char *selinux_file_context_local_path (void ) {return get_path (FILE_CONTEXTS_LOCAL ); } -hidden_def (selinux_file_context_local_path)const char *selinux_x_context_path (void ) {return get_path (X_CONTEXTS ); } -hidden_def (selinux_x_context_path)const char *selinux_virtual_domain_context_path (void ) {return get_path (VIRTUAL_DOMAIN ); } -hidden_def (selinux_virtual_domain_context_path)const char *selinux_virtual_image_context_path (void ) {return get_path (VIRTUAL_IMAGE ); } -hidden_def (selinux_virtual_image_context_path)const char *selinux_lxc_contexts_path (void ) {return get_path (LXC_CONTEXTS ); } -hidden_def (selinux_lxc_contexts_path)const char *selinux_openrc_contexts_path (void ) {return get_path (OPENRC_CONTEXTS ); } -hidden_def (selinux_openrc_contexts_path)const char *selinux_openssh_contexts_path (void ) {return get_path (OPENSSH_CONTEXTS ); } -hidden_def (selinux_openssh_contexts_path)const char *selinux_snapperd_contexts_path (void ) {return get_path (SNAPPERD_CONTEXTS ); } -hidden_def (selinux_snapperd_contexts_path)const char *selinux_systemd_contexts_path (void ) {return get_path (SYSTEMD_CONTEXTS ); } -hidden_def (selinux_systemd_contexts_path)const char *selinux_booleans_subs_path (void ) {return get_path (BOOLEAN_SUBS ); } -hidden_def (selinux_booleans_subs_path)const char *selinux_file_context_subs_path (void ) {return get_path (FILE_CONTEXT_SUBS ); } -hidden_def (selinux_file_context_subs_path)const char *selinux_file_context_subs_dist_path (void ) {return get_path (FILE_CONTEXT_SUBS_DIST ); } -hidden_def (selinux_file_context_subs_dist_path)const char *selinux_sepgsql_context_path (void ) {return get_path (SEPGSQL_CONTEXTS ); } -hidden_def (selinux_sepgsql_context_path)
libselinux/src/selinux_internal.h +5 -112
125 lines not on this page · raw message
libselinux/src/setenforce.c +0 -1
@@ -34,4 +34,3 @@ int security_setenforce(int value)return 0 ; } -hidden_def (security_setenforce)
libselinux/src/setfilecon.c +0 -1
@@ -25,7 +25,6 @@ int setfilecon_raw(const char *path, const char * context)return rc; } -hidden_def (setfilecon_raw)int setfilecon (const char *path,const char *context) {
libselinux/src/setrans_client.c +1 -7
@@ -19,7 +19,6 @@#include <ctype.h> #include <unistd.h> #include <sys/uio.h> -#include "dso.h" #include "selinux_internal.h" #include "setrans_internal.h"
@@ -260,7 +259,7 @@ static void setrans_thread_destructor(void __attribute__((unused)) *unused)void __attribute__((destructor))setrans_lib_destructor (void ); -void hidden __attribute__((destructor)) setrans_lib_destructor(void) +void __attribute__((destructor))setrans_lib_destructor (void ) {if (!has_setrans)return ;
@@ -327,7 +326,6 @@ int selinux_trans_to_raw_context(const char * trans,return *rawp ?0 :-1 ; } -hidden_def (selinux_trans_to_raw_context)int selinux_raw_to_trans_context (const char * raw,char ** transp)
@@ -369,7 +367,6 @@ int selinux_raw_to_trans_context(const char * raw,return *transp ?0 :-1 ; } -hidden_def (selinux_raw_to_trans_context)int selinux_raw_context_to_color (const char * raw,char **transp) {
@@ -410,7 +407,6 @@ int selinux_raw_context_to_color(const char * raw, char **transp)return *transp ?0 :-1 ; } -hidden_def(selinux_raw_context_to_color)#else /*DISABLE_SETRANS*/ int selinux_trans_to_raw_context(const char * trans,
@@ -426,7 +422,6 @@ int selinux_trans_to_raw_context(const char * trans,return *rawp ?0 :-1 ; } -hidden_def (selinux_trans_to_raw_context)int selinux_raw_to_trans_context (const char * raw,char ** transp)
@@ -440,5 +435,4 @@ int selinux_raw_to_trans_context(const char * raw, return *transp ? 0 : -1; } -hidden_def(selinux_raw_to_trans_context)#endif /*DISABLE_SETRANS*/
libselinux/src/seusers.c +1 -1
@@ -88,7 +88,7 @@ static int process_seusers(const char *buffer,return -2 ;/* error */ } -int require_seusers hidden = 0; +int require_seusers =0 ;#include <pwd.h> #include <grp.h>
libselinux/src/sha1.c +3 -4
@@ -23,7 +23,6 @@/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "sha1.h" -#include "dso.h" #include <memory.h> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -126,7 +125,7 @@ void// // Initialises an SHA1 Context. Use this to initialise/reset a context. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Initialise ( Sha1Context* Context
@@ -148,7 +147,7 @@ void hidden// Adds data to the SHA1 context. This will process the data and update the internal state of the context. Keep on // calling this function until all the data has been added. Then call Sha1Finalise to calculate the hash. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Update ( Sha1Context* Context,
@@ -191,7 +190,7 @@ void hidden// Performs the final calculation of the hash and returns the digest (20 byte buffer containing 160bit hash). After // calling this, Sha1Initialised must be used to reuse the context. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Finalise ( Sha1Context* Context,
libselinux/src/stringrep.c +0 -1
@@ -180,7 +180,6 @@ void selinux_flush_class_cache(void) discover_class_cache =NULL ; } -hidden_def (selinux_flush_class_cache)security_class_t string_to_security_class (const char *s) {
libselinux/src/validatetrans.c +0 -2
@@ -57,7 +57,6 @@ out:return ret; } -hidden_def(security_validatetrans_raw) int security_validatetrans(const char *scon, const char *tcon,
@@ -91,4 +90,3 @@ out:return ret; } -hidden_def (security_validatetrans)
Signature · 1 line
2.17.1
PATCH v4 2/4 Makefile: add -fno-semantic-interposition
In reply to [email protected]From: William Roberts <[email protected]>
Add -fno-semantic-interposition to CFLAGS. This will restore the DSO infrastructures protections to insure internal callers of exported symbols call into libselinux and not something laoding first in the library list.
Clang has this enabled by default.
--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/Makefile +1 -1
@@ -65,7 +65,7 @@ EXTRA_CFLAGS = -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nan -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 \ - -Wstrict-overflow=5 + -Wstrict-overflow=5 -fno-semantic-interposition else EXTRA_CFLAGS = -Wunused-command-line-argument endif
Signature · 1 line
2.17.1
PATCH v4 3/4 Makefile: add linker script to minimize exports
In reply to [email protected]From: William Roberts <[email protected]>
Add a linker script that exports only what was previosly exported by libselinux.
This was checked by generating an old export map (from master):
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > old.map
Then creating a new one for this library after this patch is applied:
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > new.map
And diffing them:
diff old.map new.map
--- libselinux/src/Makefile | 2 +- libselinux/src/libselinux.map | 249 ++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 libselinux/src/libselinux.map
libselinux/src/Makefile +1 -1
@@ -90,7 +90,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi -Werror -Wno-aggregate-return -Wno-redundant-decls \ $(EXTRA_CFLAGS) -LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro +LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,defs,-z,relro ifeq ($(OS), Darwin) override CFLAGS += -I/opt/local/include
libselinux/src/libselinux.map new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 4/4 libselinux: drop symbols from map
In reply to [email protected]From: William Roberts <[email protected]>
Previously, libselinux was exporting the following symbols:
- dir_xattr_list;
- map_class;
- map_decision;
- map_perm;
- myprintf_compat;
- unmap_class;
- unmap_perm;
However, these appear to be unused and can safely be dropped.
This is done as a seperate commit to so it can easily be reverted seperately for any reasons.
--- libselinux/src/libselinux.map | 7 ------- 1 file changed, 7 deletions(-)
libselinux/src/libselinux.map +0 -7
@@ -37,7 +37,6 @@ LIBSELINUX_1.0 { context_type_set; context_user_get; context_user_set; - dir_xattr_list; fgetfilecon; fgetfilecon_raw; fini_selinuxmnt;
@@ -80,9 +79,6 @@ LIBSELINUX_1.0 { lsetfilecon; lsetfilecon_raw; manual_user_enter_context; - map_class; - map_decision; - map_perm; matchmediacon; matchpathcon; matchpathcon_checkmatches;
@@ -94,7 +90,6 @@ LIBSELINUX_1.0 { matchpathcon_init; matchpathcon_init_prefix; mode_to_security_class; - myprintf_compat; print_access_vector; query_user_context; realpath_not_final;
@@ -242,8 +237,6 @@ LIBSELINUX_1.0 { sidput; string_to_av_perm; string_to_security_class; - unmap_class; - unmap_perm; local: *; };
Signature · 1 line
2.17.1
Stephen Smalley
maintainerQuoted 37 lines · On Mon, Mar 2, 2020 at 11:41 AM <[email protected]> wrote:
Version 4:
- Fix linker option warnings.
- Move map file to begining of options.Version 3:
- Add more symbols that should be dropped from the dso:
-map_class;
-map_decision;
-map_perm;Version 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso:
-dir_xattr_list
-myprintf_compat
-unmap_class
-unmap_permThis four part patch series drops the
dso.hand hidden_* macros.The old
dso.hfunctionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
Quoted 7 lines
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition[PATCH v4 1/4] dso: drop
hidden_protoandhidden_def[PATCH v4 2/4]Makefile: add -fno-semantic-interposition [PATCH v4 3/4]Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from map
This looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
Quoted 41 lines · Stephen Smalley
Quoted 40 lines · On Mon, Mar 2, 2020 at 11:41 AM <[email protected]> wrote:
Version 4:
- Fix linker option warnings.
- Move map file to begining of options.Version 3:
- Add more symbols that should be dropped from the dso:
-map_class;
-map_decision;
-map_perm;Version 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso:
-dir_xattr_list
-myprintf_compat
-unmap_class
-unmap_permThis four part patch series drops the
dso.hand hidden_* macros.The old
dso.hfunctionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition
Quoted 7 lines
Quoted 4 lines
[PATCH v4 1/4] dso: drop
hidden_protoandhidden_def[PATCH v4 2/4]Makefile: add -fno-semantic-interposition [PATCH v4 3/4]Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from mapThis looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
FWIW, I scanned all Fedora (32) packages that Require: libselinux using this script and it seems that nothing is using the symbols mentioned in patch 4/4 on Fedora:
https://gitlab.com/omos/selinux-misc/-/blob/master/scan_imports.sh
BTW, the same dso.h infrastructure is used also in libsepol and libsemanage - are there plans to do the same thing for those two?
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
<snip>
Quoted 11 lines
Quoted 2 lines
This looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
FWIW, I scanned all Fedora (32) packages that Require: libselinux using this script and it seems that nothing is using the symbols mentioned in patch 4/4 on Fedora:
https://gitlab.com/omos/selinux-misc/-/blob/master/scan_imports.sh
BTW, the same
dso.hinfrastructure is used also in libsepol and libsemanage - are there plans to do the same thing for those two?
Yes I can queue that up. I'd like to get through some of the other updates first.
Quoted 41 lines · Stephen Smalley
Quoted 40 lines · On Mon, Mar 2, 2020 at 11:41 AM <[email protected]> wrote:
Version 4:
- Fix linker option warnings.
- Move map file to begining of options.Version 3:
- Add more symbols that should be dropped from the dso:
-map_class;
-map_decision;
-map_perm;Version 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso:
-dir_xattr_list
-myprintf_compat
-unmap_class
-unmap_permThis four part patch series drops the
dso.hand hidden_* macros.The old
dso.hfunctionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition
Quoted 7 lines
Quoted 4 lines
[PATCH v4 1/4] dso: drop
hidden_protoandhidden_def[PATCH v4 2/4]Makefile: add -fno-semantic-interposition [PATCH v4 3/4]Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from mapThis looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
On it. I'll provide a feedback later today or tomorrow.
Petr Lautrbach
Acked-byQuoted 41 lines · Stephen Smalley
Quoted 40 lines · On Mon, Mar 2, 2020 at 11:41 AM <[email protected]> wrote:
Version 4:
- Fix linker option warnings.
- Move map file to begining of options.Version 3:
- Add more symbols that should be dropped from the dso:
-map_class;
-map_decision;
-map_perm;Version 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso:
-dir_xattr_list
-myprintf_compat
-unmap_class
-unmap_permThis four part patch series drops the
dso.hand hidden_* macros.The old
dso.hfunctionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition
Quoted 7 lines
Quoted 4 lines
[PATCH v4 1/4] dso: drop
hidden_protoandhidden_def[PATCH v4 2/4]Makefile: add -fno-semantic-interposition [PATCH v4 3/4]Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from mapThis looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
Quoted 50 lines · Petr Lautrbach
Quoted 46 lines · Stephen Smalley
Quoted 44 lines · On Mon, Mar 2, 2020 at 11:41 AM <[email protected]> wrote:
Version 4:
- Fix linker option warnings.
- Move map file to begining of options.Version 3:
- Add more symbols that should be dropped from the dso:
-map_class;
-map_decision;
-map_perm;Version 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso:
-dir_xattr_list
-myprintf_compat
-unmap_class
-unmap_permThis four part patch series drops the
dso.hand hidden_* macros.The old
dso.hfunctionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition[PATCH v4 1/4] dso: drop
hidden_protoandhidden_def[PATCH v4 2/4]Makefile: add -fno-semantic-interposition [PATCH v4 3/4]Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from map
Quoted 5 lines
Quoted 2 lines
This looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
Acked-by Petr Lautrbach <[email protected]>
Thanks staged:
https://github.com/SELinuxProject/selinux/pull/205
Quoted 52 lines · William Roberts
Quoted 50 lines · Petr Lautrbach
Quoted 46 lines · Stephen Smalley
Quoted 44 lines · On Mon, Mar 2, 2020 at 11:41 AM <[email protected]> wrote:
Version 4:
- Fix linker option warnings.
- Move map file to begining of options.Version 3:
- Add more symbols that should be dropped from the dso:
-map_class;
-map_decision;
-map_perm;Version 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso:
-dir_xattr_list
-myprintf_compat
-unmap_class
-unmap_permThis four part patch series drops the
dso.hand hidden_* macros.The old
dso.hfunctionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition[PATCH v4 1/4] dso: drop
hidden_protoandhidden_def[PATCH v4 2/4]Makefile: add -fno-semantic-interposition [PATCH v4 3/4]Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from map
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
Acked-by Petr Lautrbach <[email protected]>Thanks staged:
https://github.com/SELinuxProject/selinux/pull/205
merged.
Since folks have interest in doing the same for libsepol and libsemanage, im going to roll those before updating the attribute deprecated patches.
Thanks,
Bill
Stephen Smalley
maintainerQuoted 18 lines · William Roberts
Quoted 15 lines · William Roberts
Quoted 13 lines · Petr Lautrbach
Quoted 8 lines · Stephen Smalley
Quoted 4 lines · On Mon, Mar 2, 2020 at 11:41 AM <[email protected]> wrote:
[PATCH v4 1/4] dso: drop
hidden_protoandhidden_def[PATCH v4 2/4]Makefile: add -fno-semantic-interposition [PATCH v4 3/4]Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from mapThis looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Acked-by Petr Lautrbach <[email protected]>Thanks staged:
https://github.com/SELinuxProject/selinux/pull/205merged.
I've noticed a change since this was applied; if I build userspace against the updated libselinux, the dynamic loader will print a warning if it is run on a system with the older libselinux, ala:
$ /sbin/restorecon -v /etc /sbin/restorecon: /lib64/libselinux.so.1: no version information available (required by /sbin/restorecon) It still works since there was no real change in the ABI but I don't know if this is a concern for distros.
Quoted 28 lines · Stephen Smalley
Quoted 18 lines · William Roberts
Quoted 15 lines · William Roberts
Quoted 13 lines · Petr Lautrbach
Quoted 8 lines · Stephen Smalley
Quoted 4 lines · On Mon, Mar 2, 2020 at 11:41 AM <[email protected]> wrote:
[PATCH v4 1/4] dso: drop
hidden_protoandhidden_def[PATCH v4 2/4]Makefile: add -fno-semantic-interposition [PATCH v4 3/4]Makefile: add linker script to minimize exports [PATCH v4 4/4] libselinux: drop symbols from mapThis looks fine to me but I'd like at least one of the distro maintainers to ack it (especially the last one).
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Acked-by Petr Lautrbach <[email protected]>Thanks staged:
https://github.com/SELinuxProject/selinux/pull/205merged.
Quoted 8 lines
I've noticed a change since this was applied; if I build userspace against the updated libselinux, the dynamic loader will print a warning if it is run on a system with the older libselinux, ala:
$ /sbin/restorecon -v /etc /sbin/restorecon: /lib64/libselinux.so.1: no version information available (required by /sbin/restorecon) It still works since there was no real change in the ABI but I don't know if this is a concern for distros.
I replicated this and looked into it, AFAICT its relatively harmless since, as you point out, we're not breaking ABI.
But If I understand your comment (paraphrasing), "userspace should all
be updated together"
from:
- https://lore.kernel.org/selinux/CAEjxPJ4UPBWSP0E4pjR+F6uKMZNHK9J7LTL1gVznpwyJh9UWNA@mail.gmail.com/
Then it really shouldn't be an issue.
A lot of what I read on the version stuff was written by Urlich, so he might weigh in with more
information and perhaps a way to correct this.
PATCH 3/3 Makefile: add linker script to minimize exports
In reply to [email protected]From: William Roberts <[email protected]>
Add a linker script that exports only what was previosly exported by libselinux.
This was checked by generating an old export map (from master):
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > old.map
Then creating a new one for this library after this patch is applied:
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > new.map
And diffing them:
diff old.map new.map
--- libselinux/src/Makefile | 2 +- libselinux/src/libselinux.map | 249 ++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 libselinux/src/libselinux.map
libselinux/src/Makefile +1 -1
@@ -90,7 +90,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi -Werror -Wno-aggregate-return -Wno-redundant-decls \ $(EXTRA_CFLAGS) -LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro-Wl,--version-script=libselinux.map ifeq ($(OS), Darwin) override CFLAGS += -I/opt/local/include
libselinux/src/libselinux.map new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
2.17.1
Stephen Smalley
maintainerRe: [PATCH 3/3] Makefile: add linker script to minimize exports
Quoted 31 lines · On Thu, Feb 27, 2020 at 6:01 PM <[email protected]> wrote:
From: William Roberts <[email protected]>
Add a linker script that exports only what was previosly exported by libselinux.
This was checked by generating an old export map (from master):
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > old.mapThen creating a new one for this library after this patch is applied:
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > new.mapAnd diffing them:
diff old.map new.mapFixes #179Signed-off-by William Roberts <[email protected]>--- libselinux/src/Makefile | 2 +- libselinux/src/libselinux.map | 249 ++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 libselinux/src/libselinux.maplibselinux/src/libselinux.map new file +0
-0
libselinux/src/libselinux.map line 2
Quoted 2 lines
libselinux/src/libselinux.map new file +2
-0@@ -0,0 +1,249 @@ +{ + global:
Our other map files (for libsepol and libsemanage) have a versioned symbolic name before the {, ala
LIBSELINUX_1.0 {
libselinux/src/libselinux.map line 40
Quoted 1 line
libselinux/src/libselinux.map new file +1
-0+ dir_xattr_list;
I doubt this was intentionally made public and certainly isn't declared in the public headers. Can we hide it?
libselinux/src/libselinux.map line 85
Quoted 3 lines
libselinux/src/libselinux.map new file +3
-0+ map_class; + map_decision; + map_perm;
Ditto for these three.
libselinux/src/libselinux.map line 97
Quoted 1 line
libselinux/src/libselinux.map new file +1
-0+ myprintf_compat;
And again.
libselinux/src/libselinux.map line 246
Quoted 2 lines
libselinux/src/libselinux.map new file +2
-0+ unmap_class; + unmap_perm;
Likewise.
Re: [PATCH 3/3] Makefile: add linker script to minimize exports
Quoted 27 lines · Stephen Smalley
Quoted 24 lines · On Thu, Feb 27, 2020 at 6:01 PM <[email protected]> wrote:
From: William Roberts <[email protected]>
Add a linker script that exports only what was previosly exported by libselinux.
This was checked by generating an old export map (from master):
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > old.mapThen creating a new one for this library after this patch is applied:
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > new.mapAnd diffing them:
diff old.map new.mapFixes #179Signed-off-by William Roberts <[email protected]>--- libselinux/src/Makefile | 2 +- libselinux/src/libselinux.map | 249 ++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 libselinux/src/libselinux.map
Quoted 12 lines
libselinux/src/libselinux.map line 2
Quoted 8 lines
libselinux/src/libselinux.map new file +2
-0@@ -0,0 +1,249 @@ +{ + global:Our other map files (for libsepol and libsemanage) have a versioned symbolic name before the {, ala
LIBSELINUX_1.0 {
Ok will add.
Quoted 12 lines
libselinux/src/libselinux.map line 40
Quoted 2 lines
libselinux/src/libselinux.map new file +1
-0+ dir_xattr_list;I doubt this was intentionally made public and certainly isn't declared in the public headers. Can we hide it?
libselinux/src/libselinux.map line 85
Quoted 3 lines
libselinux/src/libselinux.map new file +3
-0+ map_class; + map_decision; + map_perm;Ditto for these three.
Quoted 8 lines
libselinux/src/libselinux.map line 97
Quoted 1 line
libselinux/src/libselinux.map new file +1
-0+ myprintf_compat;And again.
libselinux/src/libselinux.map line 246
Quoted 2 lines
libselinux/src/libselinux.map new file +2
-0+ unmap_class; + unmap_perm;Likewise.
Perfect, I was wondering if this was overzealous, but I didn't want to break things.
Will drop these. This provides evidence that opting in to hide symbols, wasn't doing what we expected.
PATCH v2 1/1 libselinux: drop dso.h
In reply to Stephen SmalleyVersion 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso.
- dir_xattr_list
- myprintf_compat
- unmap_class
- unmap_perm
This four part patch series drops the dso.h and hidden_* macros.
The old dso.h functionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.
The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition
[PATCH v2 1/4] dso: drop hidden_proto and hidden_def [PATCH v2 2/4] Makefile: add -fno-semantic-interposition [PATCH v2 3/4] Makefile: add linker script to minimize exports [PATCH v2 4/4] libselinux: drop symbols from map
PATCH v2 1/4 dso: drop hidden_proto and hidden_def
From: William Roberts <[email protected]>
--- libselinux/src/avc.c | 5 - libselinux/src/avc_internal.h | 52 ++++---- libselinux/src/avc_sidtab.h | 11 +- libselinux/src/booleans.c | 5 - libselinux/src/callbacks.h | 11 +- libselinux/src/canonicalize_context.c | 2 - libselinux/src/checkAccess.c | 1 - libselinux/src/check_context.c | 2 - libselinux/src/checkreqprot.c | 1 - libselinux/src/compute_av.c | 4 - libselinux/src/compute_create.c | 4 - libselinux/src/compute_member.c | 1 - libselinux/src/compute_relabel.c | 1 - libselinux/src/compute_user.c | 2 - libselinux/src/context.c | 9 +- libselinux/src/context_internal.h | 12 -- libselinux/src/deny_unknown.c | 1 - libselinux/src/disable.c | 1 - libselinux/src/dso.h | 23 ---- libselinux/src/enabled.c | 2 - libselinux/src/fgetfilecon.c | 1 - libselinux/src/freecon.c | 1 - libselinux/src/freeconary.c | 1 - libselinux/src/fsetfilecon.c | 1 - libselinux/src/get_context_list.c | 3 - libselinux/src/get_context_list_internal.h | 4 - libselinux/src/get_default_type_internal.h | 2 - libselinux/src/get_initial_context.c | 2 - libselinux/src/getenforce.c | 1 - libselinux/src/getfilecon.c | 2 - libselinux/src/getpeercon.c | 1 - libselinux/src/init.c | 4 - libselinux/src/label_internal.h | 19 ++- libselinux/src/label_support.c | 6 +- libselinux/src/lgetfilecon.c | 1 - libselinux/src/load_policy.c | 2 - libselinux/src/lsetfilecon.c | 1 - libselinux/src/matchpathcon.c | 3 +- libselinux/src/policyvers.c | 2 - libselinux/src/procattr.c | 21 +--- libselinux/src/regex.h | 21 ++-- libselinux/src/reject_unknown.c | 1 - .../src/selinux_check_securetty_context.c | 1 - libselinux/src/selinux_config.c | 36 ------ libselinux/src/selinux_internal.h | 117 +----------------- libselinux/src/setenforce.c | 1 - libselinux/src/setfilecon.c | 1 - libselinux/src/setrans_client.c | 8 +- libselinux/src/seusers.c | 2 +- libselinux/src/sha1.c | 7 +- libselinux/src/stringrep.c | 1 - libselinux/src/validatetrans.c | 2 - 52 files changed, 69 insertions(+), 357 deletions(-) delete mode 100644 libselinux/src/dso.h
libselinux/src/avc.c +0 -5
@@ -294,7 +294,6 @@ void avc_av_stats(void) slots_used, AVC_CACHE_SLOTS, max_chain_len); } -hidden_def (avc_av_stats)static inline struct avc_node *avc_reclaim_node (void ) {
@@ -494,7 +493,6 @@ void avc_cleanup(void) { } -hidden_def (avc_cleanup)int avc_reset (void ) {
@@ -539,7 +537,6 @@ int avc_reset(void)return rc; } -hidden_def (avc_reset)void avc_destroy (void ) {
@@ -733,7 +730,6 @@ void avc_audit(security_id_t ssid, security_id_t tsid,avc_release_lock (avc_log_lock); } -hidden_def (avc_audit)static void avd_init (struct av_decision *avd)
@@ -825,7 +821,6 @@ int avc_has_perm_noaudit(security_id_t ssid,return rc; } -hidden_def(avc_has_perm_noaudit) int avc_has_perm(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t requested,
libselinux/src/avc_internal.h +23 -29
85 lines not on this page · raw message
libselinux/src/avc_sidtab.h +5 -6
@@ -7,7 +7,6 @@#include <selinux/selinux.h> #include <selinux/avc.h> -#include "dso.h" struct sidtab_node {struct security_id sid_s;
@@ -24,13 +23,13 @@ struct sidtab { unsigned nel; }; -int sidtab_init(struct sidtab *s) hidden; -int sidtab_insert(struct sidtab *s, const char * ctx) hidden; +int sidtab_init (struct sidtab *s) ; +int sidtab_insert (struct sidtab *s,const char * ctx) ;int sidtab_context_to_sid (struct sidtab *s, - const char * ctx, security_id_t * sid) hidden; +const char * ctx,security_id_t * sid) ; -void sidtab_sid_stats(struct sidtab *s, char *buf, int buflen) hidden; -void sidtab_destroy(struct sidtab *s) hidden; +void sidtab_sid_stats (struct sidtab *s,char *buf,int buflen) ; +void sidtab_destroy (struct sidtab *s) ;#endif /* _SELINUX_AVC_SIDTAB_H_ */
libselinux/src/booleans.c +0 -5
@@ -414,8 +414,3 @@ char *selinux_boolean_sub(const char *name __attribute__((unused))) }#endif -hidden_def(security_get_boolean_names) -hidden_def(selinux_boolean_sub) -hidden_def(security_get_boolean_active) -hidden_def(security_set_boolean) -hidden_def(security_commit_booleans)
libselinux/src/callbacks.h +5 -6
@@ -9,22 +9,21 @@#include <stdlib.h> #include <string.h> #include <selinux/selinux.h> -#include "dso.h" /* callback pointers */ extern int __attribute__ ((format (printf,2 ,3 ))) -(*selinux_log) (int type, const char *, ...) hidden; +(*selinux_log) (int type,const char *, ...) ;extern int -(*selinux_audit) (void *, security_class_t, char *, size_t) hidden; +(*selinux_audit) (void *,security_class_t ,char *,size_t ) ;extern int -(*selinux_validate)(char **ctx) hidden; +(*selinux_validate)(char **ctx) ;extern int -(*selinux_netlink_setenforce) (int enforcing) hidden; +(*selinux_netlink_setenforce) (int enforcing) ;extern int -(*selinux_netlink_policyload) (int seqno) hidden; +(*selinux_netlink_policyload) (int seqno) ;#endif /* _SELINUX_CALLBACKS_H_ */
libselinux/src/canonicalize_context.c +0 -2
@@ -60,7 +60,6 @@ int security_canonicalize_context_raw(const char * con,return ret; } -hidden_def (security_canonicalize_context_raw)int security_canonicalize_context (const char * con,char ** canoncon)
@@ -83,4 +82,3 @@ int security_canonicalize_context(const char * con,return ret; } -hidden_def (security_canonicalize_context)
libselinux/src/checkAccess.c +0 -1
@@ -99,7 +99,6 @@ int selinux_check_passwd_access(access_vector_t requested)return status; } -hidden_def (selinux_check_passwd_access)int checkPasswdAccess (access_vector_t requested) {
libselinux/src/check_context.c +0 -2
@@ -31,7 +31,6 @@ int security_check_context_raw(const char * con)return 0 ; } -hidden_def (security_check_context_raw)int security_check_context (const char * con) {
@@ -48,4 +47,3 @@ int security_check_context(const char * con)return ret; } -hidden_def (security_check_context)
libselinux/src/checkreqprot.c +0 -1
@@ -37,4 +37,3 @@ int security_get_checkreqprot(void)return checkreqprot; } -hidden_def (security_get_checkreqprot);
libselinux/src/compute_av.c +0 -4
@@ -80,7 +80,6 @@ int security_compute_av_flags_raw(const char * scon,return ret; } -hidden_def(security_compute_av_flags_raw) int security_compute_av_raw(const char * scon, const char * tcon,
@@ -107,7 +106,6 @@ int security_compute_av_raw(const char * scon,return ret; } -hidden_def(security_compute_av_raw) int security_compute_av_flags(const char * scon, const char * tcon,
@@ -134,7 +132,6 @@ int security_compute_av_flags(const char * scon,return ret; } -hidden_def(security_compute_av_flags) int security_compute_av(const char * scon, const char * tcon,
@@ -162,4 +159,3 @@ int security_compute_av(const char * scon,return ret; } -hidden_def (security_compute_av)
libselinux/src/compute_create.c +0 -4
@@ -105,7 +105,6 @@ int security_compute_create_name_raw(const char * scon,close (fd);return ret; } -hidden_def(security_compute_create_name_raw) int security_compute_create_raw(const char * scon, const char * tcon,
@@ -115,7 +114,6 @@ int security_compute_create_raw(const char * scon,return security_compute_create_name_raw (scon, tcon, tclass,NULL , newcon); } -hidden_def(security_compute_create_raw) int security_compute_create_name(const char * scon, const char * tcon,
@@ -146,7 +144,6 @@ int security_compute_create_name(const char * scon,return ret; } -hidden_def(security_compute_create_name) int security_compute_create(const char * scon, const char * tcon,
@@ -155,4 +152,3 @@ int security_compute_create(const char * scon, {return security_compute_create_name (scon, tcon, tclass,NULL , newcon); } -hidden_def (security_compute_create)
libselinux/src/compute_member.c +0 -1
@@ -60,7 +60,6 @@ int security_compute_member_raw(const char * scon,return ret; } -hidden_def(security_compute_member_raw) int security_compute_member(const char * scon, const char * tcon,
libselinux/src/compute_relabel.c +0 -1
@@ -60,7 +60,6 @@ int security_compute_relabel_raw(const char * scon,return ret; } -hidden_def(security_compute_relabel_raw) int security_compute_relabel(const char * scon, const char * tcon,
libselinux/src/compute_user.c +0 -2
@@ -80,7 +80,6 @@ int security_compute_user_raw(const char * scon,return ret; } -hidden_def (security_compute_user_raw)int security_compute_user (const char * scon,const char *user,char *** con)
@@ -110,4 +109,3 @@ int security_compute_user(const char * scon,return ret; } -hidden_def (security_compute_user)
libselinux/src/context.c +2 -7
@@ -82,7 +82,6 @@ context_t context_new(const char *str)return 0 ; } -hidden_def (context_new)static void conditional_free (char **v) {
@@ -113,7 +112,6 @@ void context_free(context_t context) } } -hidden_def (context_free)/* * Return a pointer to the string value of the context.
@@ -144,7 +142,6 @@ char *context_str(context_t context)return n->current_str; } -hidden_def (context_str)/* Returns nonzero iff failed */ static int set_comp (context_private_t * n,int idx,const char *str)
@@ -176,8 +173,7 @@ const char * context_ ## name ## _get(context_t context) \ { \context_private_t *n = context->ptr; \return n->component[tag]; \ -} \ -hidden_def(context_ ## name ## _get) +} def_get(type, COMP_TYPE)def_get (user,COMP_USER )
@@ -187,8 +183,7 @@ def_get(type, COMP_TYPE) int context_ ## name ## _set(context_t context, const char* str) \ { \ return set_comp(context->ptr,tag,str);\ -} \ -hidden_def(context_ ## name ## _set) +} def_set(type, COMP_TYPE) def_set(role, COMP_ROLE)def_set (user,COMP_USER )
libselinux/src/context_internal.h +0 -12
@@ -1,14 +1,2 @@#include <selinux/context.h> -#include "dso.h" -hidden_proto(context_new) - hidden_proto(context_free) - hidden_proto(context_str) - hidden_proto(context_type_set) - hidden_proto(context_type_get) - hidden_proto(context_role_set) - hidden_proto(context_role_get) - hidden_proto(context_user_set) - hidden_proto(context_user_get) - hidden_proto(context_range_set) - hidden_proto(context_range_get)
libselinux/src/deny_unknown.c +0 -1
@@ -37,4 +37,3 @@ int security_deny_unknown(void)return deny_unknown; } -hidden_def (security_deny_unknown);
libselinux/src/disable.c +0 -1
@@ -35,4 +35,3 @@ int security_disable(void)return 0 ; } -hidden_def (security_disable)
libselinux/src/dso.h deleted +0 -23
@@ -1,23 +0,0 @@ -#ifndef _SELINUX_DSO_H -#define _SELINUX_DSO_H 1 - -#ifdef SHARED -# define hidden __attribute__ ((visibility ("hidden"))) -# define hidden_proto (fct) __hidden_proto (fct, fct##_internal) -# define __hidden_proto (fct, internal) \ - extern __typeof (fct) internal; \ - extern __typeof (fct) fct __asm (#internal) hidden; -# if defined(__alpha__) || defined(__mips__) -# define hidden_def (fct) \ - asm (".globl " #fct "\n" #fct " = " #fct "_internal"); -# else -# define hidden_def (fct) \ - asm (".globl " #fct "\n.set " #fct ", " #fct "_internal"); -#endif -#else -# define hidden -# define hidden_proto (fct) -# define hidden_def (fct) -#endif - -#endif
libselinux/src/enabled.c +0 -2
@@ -20,7 +20,6 @@ int is_selinux_enabled(void)#endif } -hidden_def (is_selinux_enabled)/* * Function: is_selinux_mls_enabled()
@@ -55,4 +54,3 @@ int is_selinux_mls_enabled(void)return enabled; } -hidden_def (is_selinux_mls_enabled)
libselinux/src/fgetfilecon.c +0 -1
@@ -49,7 +49,6 @@ int fgetfilecon_raw(int fd, char ** context)return ret; } -hidden_def (fgetfilecon_raw)int fgetfilecon (int fd,char ** context) {
libselinux/src/freecon.c +0 -1
@@ -8,4 +8,3 @@ void freecon(char * con)free (con); } -hidden_def (freecon)
libselinux/src/freeconary.c +0 -1
@@ -16,4 +16,3 @@ void freeconary(char ** con)free (con); } -hidden_def (freeconary)
libselinux/src/fsetfilecon.c +0 -1
@@ -25,7 +25,6 @@ int fsetfilecon_raw(int fd, const char * context)return rc; } -hidden_def (fsetfilecon_raw)int fsetfilecon (int fd,const char *context) {
libselinux/src/get_context_list.c +0 -3
@@ -52,7 +52,6 @@ int get_default_context_with_role(const char *user,return rc; } -hidden_def(get_default_context_with_role) int get_default_context_with_rolelevel(const char *user, const char *role,
@@ -385,7 +384,6 @@ int get_ordered_context_list_with_level(const char *user,return rc; } -hidden_def(get_ordered_context_list_with_level) int get_default_context_with_level(const char *user, const char *level,
@@ -497,4 +495,3 @@ int get_ordered_context_list(const char *user, goto out; } -hidden_def (get_ordered_context_list)
libselinux/src/get_context_list_internal.h +0 -4
@@ -1,6 +1,2 @@#include <selinux/get_context_list.h> -#include "dso.h" -hidden_proto(get_ordered_context_list) - hidden_proto(get_ordered_context_list_with_level) - hidden_proto(get_default_context_with_role)
libselinux/src/get_default_type_internal.h +0 -2
@@ -1,4 +1,2 @@#include <selinux/get_default_type.h> -#include "dso.h" -hidden_proto (selinux_default_type_path)
libselinux/src/get_initial_context.c +0 -2
@@ -53,7 +53,6 @@ int security_get_initial_context_raw(const char * name, char ** con)return ret; } -hidden_def (security_get_initial_context_raw)int security_get_initial_context (const char * name,char ** con) {
@@ -69,4 +68,3 @@ int security_get_initial_context(const char * name, char ** con)return ret; } -hidden_def (security_get_initial_context)
libselinux/src/getenforce.c +0 -1
@@ -37,4 +37,3 @@ int security_getenforce(void)return !!enforce; } -hidden_def (security_getenforce)
libselinux/src/getfilecon.c +0 -2
@@ -49,7 +49,6 @@ int getfilecon_raw(const char *path, char ** context)return ret; } -hidden_def (getfilecon_raw)int getfilecon (const char *path,char ** context) {
@@ -70,4 +69,3 @@ int getfilecon(const char *path, char ** context)return ret; } -hidden_def (getfilecon)
libselinux/src/getpeercon.c +0 -1
@@ -43,7 +43,6 @@ int getpeercon_raw(int fd, char ** context)return ret; } -hidden_def (getpeercon_raw)int getpeercon (int fd,char ** context) {
libselinux/src/init.c +0 -4
@@ -12,7 +12,6 @@#include <stdint.h> #include <limits.h> -#include "dso.h" #include "policy.h" #include "selinux_internal.h" #include "setrans_internal.h"
@@ -79,7 +78,6 @@ int selinuxfs_exists(void)fclose (fp);return exists; } -hidden_def (selinuxfs_exists)static void init_selinuxmnt (void ) {
@@ -138,14 +136,12 @@ void fini_selinuxmnt(void) selinux_mnt =NULL ; } -hidden_def (fini_selinuxmnt)void set_selinuxmnt (const char *mnt) { selinux_mnt =strdup (mnt); } -hidden_def (set_selinuxmnt)static void init_lib (void ) __attribute__ ((constructor));static void init_lib (void )
libselinux/src/label_internal.h +9 -10
@@ -13,7 +13,6 @@#include <stdio.h> #include <selinux/selinux.h> #include <selinux/label.h> -#include "dso.h" #include "sha1.h" #if defined(ANDROID ) || defined(__APPLE__)
@@ -26,22 +25,22 @@*/ int selabel_file_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_media_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_x_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_db_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_property_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_service_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;/* * Labeling internal structures
@@ -120,14 +119,14 @@ struct selabel_handle {*/ extern int selabel_validate (struct selabel_handle *rec, - struct selabel_lookup_rec *contexts) hidden; +struct selabel_lookup_rec *contexts) ;/* * Compatibility support */ extern int myprintf_compat;extern void __attribute__ ((format (printf,1 ,2 ))) -(*myprintf) (const char *fmt, ...) hidden; +(*myprintf) (const char *fmt, ...) ; #define COMPAT_LOG(type, fmt...) if (myprintf_compat) \ myprintf(fmt); \
@@ -137,7 +136,7 @@ extern void __attribute__ ((format(printf, 1, 2)))extern int compat_validate (struct selabel_handle *rec,struct selabel_lookup_rec *contexts, - const char *path, unsigned lineno) hidden; +const char *path,unsigned lineno) ;/* * The read_spec_entries function may be used to
libselinux/src/label_support.c +3 -3
@@ -63,7 +63,7 @@ static inline int read_spec_entry(char **entry, char **ptr, int *len, const char* This function calls read_spec_entry() to do the actual string processing. * As such, can return anything from that function as well. */ -int hidden read_spec_entries(char *line_buf, const char **errbuf, int num_args, ...) +int read_spec_entries (char *line_buf,const char **errbuf,int num_args, ...) {char **spec_entry, *buf_p;int len, rc, items, entry_len =0 ;
@@ -113,7 +113,7 @@ int hidden read_spec_entries(char *line_buf, const char **errbuf, int num_args, }/* Once all the specfiles are in the hash_buf, generate the hash. */ -void hidden digest_gen_hash(struct selabel_digest *digest) +void digest_gen_hash (struct selabel_digest *digest) {Sha1Context context;
@@ -141,7 +141,7 @@ void hidden digest_gen_hash(struct selabel_digest *digest)* * Return %0 on success, -%1 with @errno set on failure. */ -int hidden digest_add_specfile(struct selabel_digest *digest, FILE *fp, +int digest_add_specfile (struct selabel_digest *digest,FILE *fp,char *from_addr,size_t buf_len,const char *path) {
libselinux/src/lgetfilecon.c +0 -1
@@ -49,7 +49,6 @@ int lgetfilecon_raw(const char *path, char ** context)return ret; } -hidden_def (lgetfilecon_raw)int lgetfilecon (const char *path,char ** context) {
libselinux/src/load_policy.c +0 -2
@@ -45,7 +45,6 @@ int security_load_policy(void *data, size_t len)return 0 ; } -hidden_def(security_load_policy)#ifndef ANDROID #undef max
@@ -213,7 +212,6 @@ int selinux_mkload_policy(int preservebools __attribute__((unused)))return rc; } -hidden_def (selinux_mkload_policy)/* * Mount point for selinuxfs.
libselinux/src/lsetfilecon.c +0 -1
@@ -25,7 +25,6 @@ int lsetfilecon_raw(const char *path, const char * context)return rc; } -hidden_def (lsetfilecon_raw)int lsetfilecon (const char *path,const char *context) {
libselinux/src/matchpathcon.c +1 -2
@@ -322,7 +322,7 @@ static void matchpathcon_thread_destructor(void __attribute__((unused)) *ptr)void __attribute__((destructor))matchpathcon_lib_destructor (void ); -void hidden __attribute__((destructor)) matchpathcon_lib_destructor(void) +void __attribute__((destructor))matchpathcon_lib_destructor (void ) {if (destructor_key_initialized)__selinux_key_delete (destructor_key);
@@ -351,7 +351,6 @@ int matchpathcon_init_prefix(const char *path, const char *subset)return hnd ?0 :-1 ; } -hidden_def (matchpathcon_init_prefix)int matchpathcon_init (const char *path) {
libselinux/src/policyvers.c +0 -2
@@ -7,7 +7,6 @@#include "selinux_internal.h" #include <stdio.h> #include "policy.h" -#include "dso.h" #include <limits.h> int security_policyvers (void )
@@ -42,4 +41,3 @@ int security_policyvers(void)return vers; } -hidden_def (security_policyvers)
libselinux/src/procattr.c +1 -20
@@ -57,7 +57,7 @@ static void procattr_thread_destructor(void __attribute__((unused)) *unused)void __attribute__((destructor))procattr_destructor (void ); -void hidden __attribute__((destructor)) procattr_destructor(void) +void __attribute__((destructor))procattr_destructor (void ) {if (destructor_key_initialized)__selinux_key_delete (destructor_key);
@@ -345,22 +345,3 @@ all_selfattr_def(con, current) all_selfattr_def(sockcreatecon, sockcreate)all_selfattr_def (keycreatecon, keycreate) - hidden_def(getcon_raw) - hidden_def(getcon) - hidden_def(getexeccon_raw) - hidden_def(getfilecon_raw) - hidden_def(getfilecon) - hidden_def(getfscreatecon_raw) - hidden_def(getkeycreatecon_raw) - hidden_def(getpeercon_raw) - hidden_def(getpidcon_raw) - hidden_def(getprevcon_raw) - hidden_def(getprevcon) - hidden_def(getsockcreatecon_raw) - hidden_def(setcon_raw) - hidden_def(setexeccon_raw) - hidden_def(setexeccon) - hidden_def(setfilecon_raw) - hidden_def(setfscreatecon_raw) - hidden_def(setkeycreatecon_raw) - hidden_def(setsockcreatecon_raw)
libselinux/src/regex.h +10 -11
@@ -10,7 +10,6 @@#include <pcre.h> #endif -#include "dso.h" enum {REGEX_MATCH ,REGEX_MATCH_PARTIAL ,
@@ -42,7 +41,7 @@ struct mmap_area;* expressions are not portable across architectures that do not have a * matching arch-string. */ -char const *regex_arch_string (void ) hidden; +char const *regex_arch_string (void ) ;/** * regex_verison returns the version string of the underlying regular
@@ -55,12 +54,12 @@ char const *regex_arch_string(void) hidden;* * It may return NULL on error. */ -char const *regex_version (void ) hidden; +char const *regex_version (void ) ;/** * This constructor function allocates a buffer for a regex_data structure. * The buffer is being initialized with zeroes. */ -struct regex_data *regex_data_create (void ) hidden; +struct regex_data *regex_data_create (void ) ;/** * This complementary destructor function frees the a given regex_data buffer. * It also frees any non NULL member pointers with the appropriate pcreX_X_free
@@ -68,7 +67,7 @@ struct regex_data *regex_data_create(void) hidden;* the pcre_extra data conditionally. Calling this function on a NULL pointer is * save. */ -void regex_data_free(struct regex_data *regex) hidden; +void regex_data_free (struct regex_data *regex) ;/** * This function compiles the regular expression. Additionally, it prepares * data structures required by the different underlying engines. For PCRE
@@ -88,7 +87,7 @@ void regex_data_free(struct regex_data *regex) hidden;* @retval -1 on error */ int regex_prepare_data (struct regex_data **regex,char const *pattern_string, - struct regex_error_data *errordata) hidden; +struct regex_error_data *errordata) ;/** * This function loads a serialized precompiled pattern from a contiguous * data region given by map_area.
@@ -109,7 +108,7 @@ int regex_prepare_data(struct regex_data **regex, char const *pattern_string,int regex_load_mmap (struct mmap_area *map_area,struct regex_data **regex,int do_load_precompregex, - bool *regex_compiled) hidden; +bool *regex_compiled) ;/** * This function stores a precompiled regular expression to a file. * In the case of PCRE, it just dumps the binary representation of the
@@ -122,7 +121,7 @@ int regex_load_mmap(struct mmap_area *map_area,* the output file (ignored by PCRE1 back-end). */ int regex_writef (struct regex_data *regex,FILE *fp, - int do_write_precompregex) hidden; +int do_write_precompregex) ;/** * This function applies a precompiled pattern to a subject string and * returns whether or not a match was found.
@@ -139,7 +138,7 @@ int regex_writef(struct regex_data *regex, FILE *fp,* regular expression */ int regex_match (struct regex_data *regex,char const *subject, - int partial) hidden; +int partial) ;/** * This function compares two compiled regular expressions (regex1 and regex2). * It compares the binary representations of the compiled patterns. It is a very
@@ -150,7 +149,7 @@ int regex_match(struct regex_data *regex, char const *subject,* the same * @retval SELABEL_INCOMPARABLE otherwise */ -int regex_cmp(struct regex_data *regex1, struct regex_data *regex2) hidden; +int regex_cmp (struct regex_data *regex1,struct regex_data *regex2) ;/** * This function takes the error data returned by regex_prepare_data and turns * it in to a human readable error message.
@@ -163,5 +162,5 @@ int regex_cmp(struct regex_data *regex1, struct regex_data *regex2) hidden;* @arg buf_size Total size of the given buffer in bytes. */ void regex_format_error (struct regex_error_data const *error_data,char *buffer, - size_t buf_size) hidden; +size_t buf_size) ;#endif /* SRC_REGEX_H_ */
libselinux/src/reject_unknown.c +0 -1
@@ -37,4 +37,3 @@ int security_reject_unknown(void)return reject_unknown; } -hidden_def (security_reject_unknown);
libselinux/src/selinux_check_securetty_context.c +0 -1
@@ -50,4 +50,3 @@ int selinux_check_securetty_context(const char * tty_context)return found; } -hidden_def (selinux_check_securetty_context)
libselinux/src/selinux_config.c +0 -36
@@ -128,7 +128,6 @@ int selinux_getenforcemode(int *enforce)return ret; } -hidden_def (selinux_getenforcemode)static char *selinux_policytype;
@@ -141,7 +140,6 @@ int selinux_getpolicytype(char **type)return *type ?0 :-1 ; } -hidden_def (selinux_getpolicytype)static int setpolicytype (const char *type) {
@@ -249,7 +247,6 @@ void selinux_reset_config(void)init_selinux_config (); } -hidden_def (selinux_reset_config)static const char *get_path (int idx) {
@@ -262,7 +259,6 @@ const char *selinux_default_type_path(void)return get_path (DEFAULT_TYPE ); } -hidden_def (selinux_default_type_path)const char *selinux_policy_root (void ) {
@@ -305,42 +301,36 @@ const char *selinux_path(void)return selinux_rootpath; } -hidden_def (selinux_path)const char *selinux_default_context_path (void ) {return get_path (DEFAULT_CONTEXTS ); } -hidden_def (selinux_default_context_path)const char *selinux_securetty_types_path (void ) {return get_path (SECURETTY_TYPES ); } -hidden_def (selinux_securetty_types_path)const char *selinux_failsafe_context_path (void ) {return get_path (FAILSAFE_CONTEXT ); } -hidden_def (selinux_failsafe_context_path)const char *selinux_removable_context_path (void ) {return get_path (REMOVABLE_CONTEXT ); } -hidden_def (selinux_removable_context_path)const char *selinux_binary_policy_path (void ) {return get_path (BINPOLICY ); } -hidden_def (selinux_binary_policy_path)const char *selinux_current_policy_path (void ) {
@@ -365,35 +355,30 @@ const char *selinux_current_policy_path(void)return policy_path; } -hidden_def (selinux_current_policy_path)const char *selinux_file_context_path (void ) {return get_path (FILE_CONTEXTS ); } -hidden_def (selinux_file_context_path)const char *selinux_homedir_context_path (void ) {return get_path (HOMEDIR_CONTEXTS ); } -hidden_def (selinux_homedir_context_path)const char *selinux_media_context_path (void ) {return get_path (MEDIA_CONTEXTS ); } -hidden_def (selinux_media_context_path)const char *selinux_customizable_types_path (void ) {return get_path (CUSTOMIZABLE_TYPES ); } -hidden_def (selinux_customizable_types_path)const char *selinux_contexts_path (void ) {
@@ -405,7 +390,6 @@ const char *selinux_user_contexts_path(void)return get_path (USER_CONTEXTS ); } -hidden_def (selinux_user_contexts_path)/* Deprecated as local policy booleans no longer supported. */ const char *selinux_booleans_path (void )
@@ -413,7 +397,6 @@ const char *selinux_booleans_path(void)return get_path (BOOLEANS ); } -hidden_def (selinux_booleans_path)/* Deprecated as no longer supported. */ const char *selinux_users_path (void )
@@ -421,127 +404,108 @@ const char *selinux_users_path(void)return get_path (USERS_DIR ); } -hidden_def (selinux_users_path)const char *selinux_usersconf_path (void ) {return get_path (SEUSERS ); } -hidden_def (selinux_usersconf_path)const char *selinux_translations_path (void ) {return get_path (TRANSLATIONS ); } -hidden_def (selinux_translations_path)const char *selinux_colors_path (void ) {return get_path (COLORS ); } -hidden_def (selinux_colors_path)const char *selinux_netfilter_context_path (void ) {return get_path (NETFILTER_CONTEXTS ); } -hidden_def (selinux_netfilter_context_path)const char *selinux_file_context_homedir_path (void ) {return get_path (FILE_CONTEXTS_HOMEDIR ); } -hidden_def (selinux_file_context_homedir_path)const char *selinux_file_context_local_path (void ) {return get_path (FILE_CONTEXTS_LOCAL ); } -hidden_def (selinux_file_context_local_path)const char *selinux_x_context_path (void ) {return get_path (X_CONTEXTS ); } -hidden_def (selinux_x_context_path)const char *selinux_virtual_domain_context_path (void ) {return get_path (VIRTUAL_DOMAIN ); } -hidden_def (selinux_virtual_domain_context_path)const char *selinux_virtual_image_context_path (void ) {return get_path (VIRTUAL_IMAGE ); } -hidden_def (selinux_virtual_image_context_path)const char *selinux_lxc_contexts_path (void ) {return get_path (LXC_CONTEXTS ); } -hidden_def (selinux_lxc_contexts_path)const char *selinux_openrc_contexts_path (void ) {return get_path (OPENRC_CONTEXTS ); } -hidden_def (selinux_openrc_contexts_path)const char *selinux_openssh_contexts_path (void ) {return get_path (OPENSSH_CONTEXTS ); } -hidden_def (selinux_openssh_contexts_path)const char *selinux_snapperd_contexts_path (void ) {return get_path (SNAPPERD_CONTEXTS ); } -hidden_def (selinux_snapperd_contexts_path)const char *selinux_systemd_contexts_path (void ) {return get_path (SYSTEMD_CONTEXTS ); } -hidden_def (selinux_systemd_contexts_path)const char *selinux_booleans_subs_path (void ) {return get_path (BOOLEAN_SUBS ); } -hidden_def (selinux_booleans_subs_path)const char *selinux_file_context_subs_path (void ) {return get_path (FILE_CONTEXT_SUBS ); } -hidden_def (selinux_file_context_subs_path)const char *selinux_file_context_subs_dist_path (void ) {return get_path (FILE_CONTEXT_SUBS_DIST ); } -hidden_def (selinux_file_context_subs_dist_path)const char *selinux_sepgsql_context_path (void ) {return get_path (SEPGSQL_CONTEXTS ); } -hidden_def (selinux_sepgsql_context_path)
libselinux/src/selinux_internal.h +5 -112
125 lines not on this page · raw message
libselinux/src/setenforce.c +0 -1
@@ -34,4 +34,3 @@ int security_setenforce(int value)return 0 ; } -hidden_def (security_setenforce)
libselinux/src/setfilecon.c +0 -1
@@ -25,7 +25,6 @@ int setfilecon_raw(const char *path, const char * context)return rc; } -hidden_def (setfilecon_raw)int setfilecon (const char *path,const char *context) {
libselinux/src/setrans_client.c +1 -7
@@ -19,7 +19,6 @@#include <ctype.h> #include <unistd.h> #include <sys/uio.h> -#include "dso.h" #include "selinux_internal.h" #include "setrans_internal.h"
@@ -260,7 +259,7 @@ static void setrans_thread_destructor(void __attribute__((unused)) *unused)void __attribute__((destructor))setrans_lib_destructor (void ); -void hidden __attribute__((destructor)) setrans_lib_destructor(void) +void __attribute__((destructor))setrans_lib_destructor (void ) {if (!has_setrans)return ;
@@ -327,7 +326,6 @@ int selinux_trans_to_raw_context(const char * trans,return *rawp ?0 :-1 ; } -hidden_def (selinux_trans_to_raw_context)int selinux_raw_to_trans_context (const char * raw,char ** transp)
@@ -369,7 +367,6 @@ int selinux_raw_to_trans_context(const char * raw,return *transp ?0 :-1 ; } -hidden_def (selinux_raw_to_trans_context)int selinux_raw_context_to_color (const char * raw,char **transp) {
@@ -410,7 +407,6 @@ int selinux_raw_context_to_color(const char * raw, char **transp)return *transp ?0 :-1 ; } -hidden_def(selinux_raw_context_to_color)#else /*DISABLE_SETRANS*/ int selinux_trans_to_raw_context(const char * trans,
@@ -426,7 +422,6 @@ int selinux_trans_to_raw_context(const char * trans,return *rawp ?0 :-1 ; } -hidden_def (selinux_trans_to_raw_context)int selinux_raw_to_trans_context (const char * raw,char ** transp)
@@ -440,5 +435,4 @@ int selinux_raw_to_trans_context(const char * raw, return *transp ? 0 : -1; } -hidden_def(selinux_raw_to_trans_context)#endif /*DISABLE_SETRANS*/
libselinux/src/seusers.c +1 -1
@@ -88,7 +88,7 @@ static int process_seusers(const char *buffer,return -2 ;/* error */ } -int require_seusers hidden = 0; +int require_seusers =0 ;#include <pwd.h> #include <grp.h>
libselinux/src/sha1.c +3 -4
@@ -23,7 +23,6 @@/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "sha1.h" -#include "dso.h" #include <memory.h> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -126,7 +125,7 @@ void// // Initialises an SHA1 Context. Use this to initialise/reset a context. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Initialise ( Sha1Context* Context
@@ -148,7 +147,7 @@ void hidden// Adds data to the SHA1 context. This will process the data and update the internal state of the context. Keep on // calling this function until all the data has been added. Then call Sha1Finalise to calculate the hash. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Update ( Sha1Context* Context,
@@ -191,7 +190,7 @@ void hidden// Performs the final calculation of the hash and returns the digest (20 byte buffer containing 160bit hash). After // calling this, Sha1Initialised must be used to reuse the context. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Finalise ( Sha1Context* Context,
libselinux/src/stringrep.c +0 -1
@@ -180,7 +180,6 @@ void selinux_flush_class_cache(void) discover_class_cache =NULL ; } -hidden_def (selinux_flush_class_cache)security_class_t string_to_security_class (const char *s) {
libselinux/src/validatetrans.c +0 -2
@@ -57,7 +57,6 @@ out:return ret; } -hidden_def(security_validatetrans_raw) int security_validatetrans(const char *scon, const char *tcon,
@@ -91,4 +90,3 @@ out:return ret; } -hidden_def (security_validatetrans)
Signature · 1 line
2.17.1
PATCH v2 2/4 Makefile: add -fno-semantic-interposition
In reply to [email protected]From: William Roberts <[email protected]>
Add -fno-semantic-interposition to CFLAGS. This will restore the DSO infrastructures protections to insure internal callers of exported symbols call into libselinux and not something laoding first in the library list.
Clang has this enabled by default.
--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/Makefile +1 -1
@@ -65,7 +65,7 @@ EXTRA_CFLAGS = -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nan -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 \ - -Wstrict-overflow=5 + -Wstrict-overflow=5 -fno-semantic-interposition else EXTRA_CFLAGS = -Wunused-command-line-argument endif
Signature · 1 line
2.17.1
PATCH v2 3/4 Makefile: add linker script to minimize exports
In reply to [email protected]From: William Roberts <[email protected]>
Add a linker script that exports only what was previosly exported by libselinux.
This was checked by generating an old export map (from master):
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > old.map
Then creating a new one for this library after this patch is applied:
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > new.map
And diffing them:
diff old.map new.map
--- libselinux/src/Makefile | 2 +- libselinux/src/libselinux.map | 249 ++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 libselinux/src/libselinux.map
libselinux/src/Makefile +1 -1
@@ -90,7 +90,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi -Werror -Wno-aggregate-return -Wno-redundant-decls \ $(EXTRA_CFLAGS) -LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro-Wl,--version-script=libselinux.map ifeq ($(OS), Darwin) override CFLAGS += -I/opt/local/include
libselinux/src/libselinux.map new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 4/4 libselinux: drop symbols from map
In reply to [email protected]From: William Roberts <[email protected]>
Previously, libselinux was exporting the following symbols:
- dir_xattr_list;
- myprintf_compat;
- unmap_class;
- unmap_perm;
However, these appear to be unused and can safely be dropped.
This is done as a seperate commit to so it can easily be reverted seperately for any reasons.
--- libselinux/src/libselinux.map | 4 ---- 1 file changed, 4 deletions(-)
libselinux/src/libselinux.map +0 -4
@@ -37,7 +37,6 @@ LIBSELINUX_1.0 { context_type_set; context_user_get; context_user_set; - dir_xattr_list; fgetfilecon; fgetfilecon_raw; fini_selinuxmnt;
@@ -94,7 +93,6 @@ LIBSELINUX_1.0 { matchpathcon_init; matchpathcon_init_prefix; mode_to_security_class; - myprintf_compat; print_access_vector; query_user_context; realpath_not_final;
@@ -242,8 +240,6 @@ LIBSELINUX_1.0 { sidput; string_to_av_perm; string_to_security_class; - unmap_class; - unmap_perm; local: *; };
Signature · 1 line
2.17.1
Stephen Smalley
maintainerRe: [PATCH v2 4/4] libselinux: drop symbols from map
Quoted 8 lines · On Fri, Feb 28, 2020 at 9:05 AM <[email protected]> wrote:
From: William Roberts <[email protected]>
Previously, libselinux was exporting the following symbols:
-dir_xattr_list;
-myprintf_compat;
-unmap_class;
-unmap_perm;
I had also suggested removing map_class, map_decision, map_perm.
Re: [PATCH v2 4/4] libselinux: drop symbols from map
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · On Fri, Feb 28, 2020 at 9:05 AM <[email protected]> wrote:
From: William Roberts <[email protected]>
Quoted 7 lines
Quoted 5 lines
Previously, libselinux was exporting the following symbols:
-dir_xattr_list;
-myprintf_compat;
-unmap_class;
-unmap_perm;I had also suggested removing
map_class,map_decision,map_perm.
Yes you did, I can't believe I skipped over them.
PATCH v3 1/1 libselinux: drop dso.h
In reply to [email protected]Version 3:
- Add more symbols that should be dropped from the dso:
- map_class;
- map_decision;
- map_perm;
Version 2:
- adds a version to the linker script LIBSELINUX_1.0
- Adds a patch to drop some additional symbols from the dso:
- dir_xattr_list
- myprintf_compat
- unmap_class
- unmap_perm
This four part patch series drops the dso.h and hidden_* macros.
The old dso.h functionality provided libselinux with both control over external exported symbols as well as ensuring internal callers call into libselinux and not a symbol with the same name loaded by the linker earlier in the library list.
The functionality is replaced by a linker script that requires public API to explicitly be opt-in. The old method required that internal API be explicitly annotated, and everything else is public. This should help make it easier to control libselinux DSO hygene going forward.
The second functionality is replaced by compiler option -fno-semantic-interposition
Note that clang has this enabled by default, and thus doesn't need it.
See:
- https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition
[PATCH v3 1/4] dso: drop hidden_proto and hidden_def [PATCH v3 2/4] Makefile: add -fno-semantic-interposition [PATCH v3 3/4] Makefile: add linker script to minimize exports [PATCH v3 4/4] libselinux: drop symbols from map
PATCH v3 1/4 dso: drop hidden_proto and hidden_def
From: William Roberts <[email protected]>
--- libselinux/src/avc.c | 5 - libselinux/src/avc_internal.h | 52 ++++---- libselinux/src/avc_sidtab.h | 11 +- libselinux/src/booleans.c | 5 - libselinux/src/callbacks.h | 11 +- libselinux/src/canonicalize_context.c | 2 - libselinux/src/checkAccess.c | 1 - libselinux/src/check_context.c | 2 - libselinux/src/checkreqprot.c | 1 - libselinux/src/compute_av.c | 4 - libselinux/src/compute_create.c | 4 - libselinux/src/compute_member.c | 1 - libselinux/src/compute_relabel.c | 1 - libselinux/src/compute_user.c | 2 - libselinux/src/context.c | 9 +- libselinux/src/context_internal.h | 12 -- libselinux/src/deny_unknown.c | 1 - libselinux/src/disable.c | 1 - libselinux/src/dso.h | 23 ---- libselinux/src/enabled.c | 2 - libselinux/src/fgetfilecon.c | 1 - libselinux/src/freecon.c | 1 - libselinux/src/freeconary.c | 1 - libselinux/src/fsetfilecon.c | 1 - libselinux/src/get_context_list.c | 3 - libselinux/src/get_context_list_internal.h | 4 - libselinux/src/get_default_type_internal.h | 2 - libselinux/src/get_initial_context.c | 2 - libselinux/src/getenforce.c | 1 - libselinux/src/getfilecon.c | 2 - libselinux/src/getpeercon.c | 1 - libselinux/src/init.c | 4 - libselinux/src/label_internal.h | 19 ++- libselinux/src/label_support.c | 6 +- libselinux/src/lgetfilecon.c | 1 - libselinux/src/load_policy.c | 2 - libselinux/src/lsetfilecon.c | 1 - libselinux/src/matchpathcon.c | 3 +- libselinux/src/policyvers.c | 2 - libselinux/src/procattr.c | 21 +--- libselinux/src/regex.h | 21 ++-- libselinux/src/reject_unknown.c | 1 - .../src/selinux_check_securetty_context.c | 1 - libselinux/src/selinux_config.c | 36 ------ libselinux/src/selinux_internal.h | 117 +----------------- libselinux/src/setenforce.c | 1 - libselinux/src/setfilecon.c | 1 - libselinux/src/setrans_client.c | 8 +- libselinux/src/seusers.c | 2 +- libselinux/src/sha1.c | 7 +- libselinux/src/stringrep.c | 1 - libselinux/src/validatetrans.c | 2 - 52 files changed, 69 insertions(+), 357 deletions(-) delete mode 100644 libselinux/src/dso.h
libselinux/src/avc.c +0 -5
@@ -294,7 +294,6 @@ void avc_av_stats(void) slots_used, AVC_CACHE_SLOTS, max_chain_len); } -hidden_def (avc_av_stats)static inline struct avc_node *avc_reclaim_node (void ) {
@@ -494,7 +493,6 @@ void avc_cleanup(void) { } -hidden_def (avc_cleanup)int avc_reset (void ) {
@@ -539,7 +537,6 @@ int avc_reset(void)return rc; } -hidden_def (avc_reset)void avc_destroy (void ) {
@@ -733,7 +730,6 @@ void avc_audit(security_id_t ssid, security_id_t tsid,avc_release_lock (avc_log_lock); } -hidden_def (avc_audit)static void avd_init (struct av_decision *avd)
@@ -825,7 +821,6 @@ int avc_has_perm_noaudit(security_id_t ssid,return rc; } -hidden_def(avc_has_perm_noaudit) int avc_has_perm(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t requested,
libselinux/src/avc_internal.h +23 -29
85 lines not on this page · raw message
libselinux/src/avc_sidtab.h +5 -6
@@ -7,7 +7,6 @@#include <selinux/selinux.h> #include <selinux/avc.h> -#include "dso.h" struct sidtab_node {struct security_id sid_s;
@@ -24,13 +23,13 @@ struct sidtab { unsigned nel; }; -int sidtab_init(struct sidtab *s) hidden; -int sidtab_insert(struct sidtab *s, const char * ctx) hidden; +int sidtab_init (struct sidtab *s) ; +int sidtab_insert (struct sidtab *s,const char * ctx) ;int sidtab_context_to_sid (struct sidtab *s, - const char * ctx, security_id_t * sid) hidden; +const char * ctx,security_id_t * sid) ; -void sidtab_sid_stats(struct sidtab *s, char *buf, int buflen) hidden; -void sidtab_destroy(struct sidtab *s) hidden; +void sidtab_sid_stats (struct sidtab *s,char *buf,int buflen) ; +void sidtab_destroy (struct sidtab *s) ;#endif /* _SELINUX_AVC_SIDTAB_H_ */
libselinux/src/booleans.c +0 -5
@@ -414,8 +414,3 @@ char *selinux_boolean_sub(const char *name __attribute__((unused))) }#endif -hidden_def(security_get_boolean_names) -hidden_def(selinux_boolean_sub) -hidden_def(security_get_boolean_active) -hidden_def(security_set_boolean) -hidden_def(security_commit_booleans)
libselinux/src/callbacks.h +5 -6
@@ -9,22 +9,21 @@#include <stdlib.h> #include <string.h> #include <selinux/selinux.h> -#include "dso.h" /* callback pointers */ extern int __attribute__ ((format (printf,2 ,3 ))) -(*selinux_log) (int type, const char *, ...) hidden; +(*selinux_log) (int type,const char *, ...) ;extern int -(*selinux_audit) (void *, security_class_t, char *, size_t) hidden; +(*selinux_audit) (void *,security_class_t ,char *,size_t ) ;extern int -(*selinux_validate)(char **ctx) hidden; +(*selinux_validate)(char **ctx) ;extern int -(*selinux_netlink_setenforce) (int enforcing) hidden; +(*selinux_netlink_setenforce) (int enforcing) ;extern int -(*selinux_netlink_policyload) (int seqno) hidden; +(*selinux_netlink_policyload) (int seqno) ;#endif /* _SELINUX_CALLBACKS_H_ */
libselinux/src/canonicalize_context.c +0 -2
@@ -60,7 +60,6 @@ int security_canonicalize_context_raw(const char * con,return ret; } -hidden_def (security_canonicalize_context_raw)int security_canonicalize_context (const char * con,char ** canoncon)
@@ -83,4 +82,3 @@ int security_canonicalize_context(const char * con,return ret; } -hidden_def (security_canonicalize_context)
libselinux/src/checkAccess.c +0 -1
@@ -99,7 +99,6 @@ int selinux_check_passwd_access(access_vector_t requested)return status; } -hidden_def (selinux_check_passwd_access)int checkPasswdAccess (access_vector_t requested) {
libselinux/src/check_context.c +0 -2
@@ -31,7 +31,6 @@ int security_check_context_raw(const char * con)return 0 ; } -hidden_def (security_check_context_raw)int security_check_context (const char * con) {
@@ -48,4 +47,3 @@ int security_check_context(const char * con)return ret; } -hidden_def (security_check_context)
libselinux/src/checkreqprot.c +0 -1
@@ -37,4 +37,3 @@ int security_get_checkreqprot(void)return checkreqprot; } -hidden_def (security_get_checkreqprot);
libselinux/src/compute_av.c +0 -4
@@ -80,7 +80,6 @@ int security_compute_av_flags_raw(const char * scon,return ret; } -hidden_def(security_compute_av_flags_raw) int security_compute_av_raw(const char * scon, const char * tcon,
@@ -107,7 +106,6 @@ int security_compute_av_raw(const char * scon,return ret; } -hidden_def(security_compute_av_raw) int security_compute_av_flags(const char * scon, const char * tcon,
@@ -134,7 +132,6 @@ int security_compute_av_flags(const char * scon,return ret; } -hidden_def(security_compute_av_flags) int security_compute_av(const char * scon, const char * tcon,
@@ -162,4 +159,3 @@ int security_compute_av(const char * scon,return ret; } -hidden_def (security_compute_av)
libselinux/src/compute_create.c +0 -4
@@ -105,7 +105,6 @@ int security_compute_create_name_raw(const char * scon,close (fd);return ret; } -hidden_def(security_compute_create_name_raw) int security_compute_create_raw(const char * scon, const char * tcon,
@@ -115,7 +114,6 @@ int security_compute_create_raw(const char * scon,return security_compute_create_name_raw (scon, tcon, tclass,NULL , newcon); } -hidden_def(security_compute_create_raw) int security_compute_create_name(const char * scon, const char * tcon,
@@ -146,7 +144,6 @@ int security_compute_create_name(const char * scon,return ret; } -hidden_def(security_compute_create_name) int security_compute_create(const char * scon, const char * tcon,
@@ -155,4 +152,3 @@ int security_compute_create(const char * scon, {return security_compute_create_name (scon, tcon, tclass,NULL , newcon); } -hidden_def (security_compute_create)
libselinux/src/compute_member.c +0 -1
@@ -60,7 +60,6 @@ int security_compute_member_raw(const char * scon,return ret; } -hidden_def(security_compute_member_raw) int security_compute_member(const char * scon, const char * tcon,
libselinux/src/compute_relabel.c +0 -1
@@ -60,7 +60,6 @@ int security_compute_relabel_raw(const char * scon,return ret; } -hidden_def(security_compute_relabel_raw) int security_compute_relabel(const char * scon, const char * tcon,
libselinux/src/compute_user.c +0 -2
@@ -80,7 +80,6 @@ int security_compute_user_raw(const char * scon,return ret; } -hidden_def (security_compute_user_raw)int security_compute_user (const char * scon,const char *user,char *** con)
@@ -110,4 +109,3 @@ int security_compute_user(const char * scon,return ret; } -hidden_def (security_compute_user)
libselinux/src/context.c +2 -7
@@ -82,7 +82,6 @@ context_t context_new(const char *str)return 0 ; } -hidden_def (context_new)static void conditional_free (char **v) {
@@ -113,7 +112,6 @@ void context_free(context_t context) } } -hidden_def (context_free)/* * Return a pointer to the string value of the context.
@@ -144,7 +142,6 @@ char *context_str(context_t context)return n->current_str; } -hidden_def (context_str)/* Returns nonzero iff failed */ static int set_comp (context_private_t * n,int idx,const char *str)
@@ -176,8 +173,7 @@ const char * context_ ## name ## _get(context_t context) \ { \context_private_t *n = context->ptr; \return n->component[tag]; \ -} \ -hidden_def(context_ ## name ## _get) +} def_get(type, COMP_TYPE)def_get (user,COMP_USER )
@@ -187,8 +183,7 @@ def_get(type, COMP_TYPE) int context_ ## name ## _set(context_t context, const char* str) \ { \ return set_comp(context->ptr,tag,str);\ -} \ -hidden_def(context_ ## name ## _set) +} def_set(type, COMP_TYPE) def_set(role, COMP_ROLE)def_set (user,COMP_USER )
libselinux/src/context_internal.h +0 -12
@@ -1,14 +1,2 @@#include <selinux/context.h> -#include "dso.h" -hidden_proto(context_new) - hidden_proto(context_free) - hidden_proto(context_str) - hidden_proto(context_type_set) - hidden_proto(context_type_get) - hidden_proto(context_role_set) - hidden_proto(context_role_get) - hidden_proto(context_user_set) - hidden_proto(context_user_get) - hidden_proto(context_range_set) - hidden_proto(context_range_get)
libselinux/src/deny_unknown.c +0 -1
@@ -37,4 +37,3 @@ int security_deny_unknown(void)return deny_unknown; } -hidden_def (security_deny_unknown);
libselinux/src/disable.c +0 -1
@@ -35,4 +35,3 @@ int security_disable(void)return 0 ; } -hidden_def (security_disable)
libselinux/src/dso.h deleted +0 -23
@@ -1,23 +0,0 @@ -#ifndef _SELINUX_DSO_H -#define _SELINUX_DSO_H 1 - -#ifdef SHARED -# define hidden __attribute__ ((visibility ("hidden"))) -# define hidden_proto (fct) __hidden_proto (fct, fct##_internal) -# define __hidden_proto (fct, internal) \ - extern __typeof (fct) internal; \ - extern __typeof (fct) fct __asm (#internal) hidden; -# if defined(__alpha__) || defined(__mips__) -# define hidden_def (fct) \ - asm (".globl " #fct "\n" #fct " = " #fct "_internal"); -# else -# define hidden_def (fct) \ - asm (".globl " #fct "\n.set " #fct ", " #fct "_internal"); -#endif -#else -# define hidden -# define hidden_proto (fct) -# define hidden_def (fct) -#endif - -#endif
libselinux/src/enabled.c +0 -2
@@ -20,7 +20,6 @@ int is_selinux_enabled(void)#endif } -hidden_def (is_selinux_enabled)/* * Function: is_selinux_mls_enabled()
@@ -55,4 +54,3 @@ int is_selinux_mls_enabled(void)return enabled; } -hidden_def (is_selinux_mls_enabled)
libselinux/src/fgetfilecon.c +0 -1
@@ -49,7 +49,6 @@ int fgetfilecon_raw(int fd, char ** context)return ret; } -hidden_def (fgetfilecon_raw)int fgetfilecon (int fd,char ** context) {
libselinux/src/freecon.c +0 -1
@@ -8,4 +8,3 @@ void freecon(char * con)free (con); } -hidden_def (freecon)
libselinux/src/freeconary.c +0 -1
@@ -16,4 +16,3 @@ void freeconary(char ** con)free (con); } -hidden_def (freeconary)
libselinux/src/fsetfilecon.c +0 -1
@@ -25,7 +25,6 @@ int fsetfilecon_raw(int fd, const char * context)return rc; } -hidden_def (fsetfilecon_raw)int fsetfilecon (int fd,const char *context) {
libselinux/src/get_context_list.c +0 -3
@@ -52,7 +52,6 @@ int get_default_context_with_role(const char *user,return rc; } -hidden_def(get_default_context_with_role) int get_default_context_with_rolelevel(const char *user, const char *role,
@@ -385,7 +384,6 @@ int get_ordered_context_list_with_level(const char *user,return rc; } -hidden_def(get_ordered_context_list_with_level) int get_default_context_with_level(const char *user, const char *level,
@@ -497,4 +495,3 @@ int get_ordered_context_list(const char *user, goto out; } -hidden_def (get_ordered_context_list)
libselinux/src/get_context_list_internal.h +0 -4
@@ -1,6 +1,2 @@#include <selinux/get_context_list.h> -#include "dso.h" -hidden_proto(get_ordered_context_list) - hidden_proto(get_ordered_context_list_with_level) - hidden_proto(get_default_context_with_role)
libselinux/src/get_default_type_internal.h +0 -2
@@ -1,4 +1,2 @@#include <selinux/get_default_type.h> -#include "dso.h" -hidden_proto (selinux_default_type_path)
libselinux/src/get_initial_context.c +0 -2
@@ -53,7 +53,6 @@ int security_get_initial_context_raw(const char * name, char ** con)return ret; } -hidden_def (security_get_initial_context_raw)int security_get_initial_context (const char * name,char ** con) {
@@ -69,4 +68,3 @@ int security_get_initial_context(const char * name, char ** con)return ret; } -hidden_def (security_get_initial_context)
libselinux/src/getenforce.c +0 -1
@@ -37,4 +37,3 @@ int security_getenforce(void)return !!enforce; } -hidden_def (security_getenforce)
libselinux/src/getfilecon.c +0 -2
@@ -49,7 +49,6 @@ int getfilecon_raw(const char *path, char ** context)return ret; } -hidden_def (getfilecon_raw)int getfilecon (const char *path,char ** context) {
@@ -70,4 +69,3 @@ int getfilecon(const char *path, char ** context)return ret; } -hidden_def (getfilecon)
libselinux/src/getpeercon.c +0 -1
@@ -43,7 +43,6 @@ int getpeercon_raw(int fd, char ** context)return ret; } -hidden_def (getpeercon_raw)int getpeercon (int fd,char ** context) {
libselinux/src/init.c +0 -4
@@ -12,7 +12,6 @@#include <stdint.h> #include <limits.h> -#include "dso.h" #include "policy.h" #include "selinux_internal.h" #include "setrans_internal.h"
@@ -79,7 +78,6 @@ int selinuxfs_exists(void)fclose (fp);return exists; } -hidden_def (selinuxfs_exists)static void init_selinuxmnt (void ) {
@@ -138,14 +136,12 @@ void fini_selinuxmnt(void) selinux_mnt =NULL ; } -hidden_def (fini_selinuxmnt)void set_selinuxmnt (const char *mnt) { selinux_mnt =strdup (mnt); } -hidden_def (set_selinuxmnt)static void init_lib (void ) __attribute__ ((constructor));static void init_lib (void )
libselinux/src/label_internal.h +9 -10
@@ -13,7 +13,6 @@#include <stdio.h> #include <selinux/selinux.h> #include <selinux/label.h> -#include "dso.h" #include "sha1.h" #if defined(ANDROID ) || defined(__APPLE__)
@@ -26,22 +25,22 @@*/ int selabel_file_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_media_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_x_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_db_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_property_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;int selabel_service_init (struct selabel_handle *rec,const struct selinux_opt *opts, - unsigned nopts) hidden; +unsigned nopts) ;/* * Labeling internal structures
@@ -120,14 +119,14 @@ struct selabel_handle {*/ extern int selabel_validate (struct selabel_handle *rec, - struct selabel_lookup_rec *contexts) hidden; +struct selabel_lookup_rec *contexts) ;/* * Compatibility support */ extern int myprintf_compat;extern void __attribute__ ((format (printf,1 ,2 ))) -(*myprintf) (const char *fmt, ...) hidden; +(*myprintf) (const char *fmt, ...) ; #define COMPAT_LOG(type, fmt...) if (myprintf_compat) \ myprintf(fmt); \
@@ -137,7 +136,7 @@ extern void __attribute__ ((format(printf, 1, 2)))extern int compat_validate (struct selabel_handle *rec,struct selabel_lookup_rec *contexts, - const char *path, unsigned lineno) hidden; +const char *path,unsigned lineno) ;/* * The read_spec_entries function may be used to
libselinux/src/label_support.c +3 -3
@@ -63,7 +63,7 @@ static inline int read_spec_entry(char **entry, char **ptr, int *len, const char* This function calls read_spec_entry() to do the actual string processing. * As such, can return anything from that function as well. */ -int hidden read_spec_entries(char *line_buf, const char **errbuf, int num_args, ...) +int read_spec_entries (char *line_buf,const char **errbuf,int num_args, ...) {char **spec_entry, *buf_p;int len, rc, items, entry_len =0 ;
@@ -113,7 +113,7 @@ int hidden read_spec_entries(char *line_buf, const char **errbuf, int num_args, }/* Once all the specfiles are in the hash_buf, generate the hash. */ -void hidden digest_gen_hash(struct selabel_digest *digest) +void digest_gen_hash (struct selabel_digest *digest) {Sha1Context context;
@@ -141,7 +141,7 @@ void hidden digest_gen_hash(struct selabel_digest *digest)* * Return %0 on success, -%1 with @errno set on failure. */ -int hidden digest_add_specfile(struct selabel_digest *digest, FILE *fp, +int digest_add_specfile (struct selabel_digest *digest,FILE *fp,char *from_addr,size_t buf_len,const char *path) {
libselinux/src/lgetfilecon.c +0 -1
@@ -49,7 +49,6 @@ int lgetfilecon_raw(const char *path, char ** context)return ret; } -hidden_def (lgetfilecon_raw)int lgetfilecon (const char *path,char ** context) {
libselinux/src/load_policy.c +0 -2
@@ -45,7 +45,6 @@ int security_load_policy(void *data, size_t len)return 0 ; } -hidden_def(security_load_policy)#ifndef ANDROID #undef max
@@ -213,7 +212,6 @@ int selinux_mkload_policy(int preservebools __attribute__((unused)))return rc; } -hidden_def (selinux_mkload_policy)/* * Mount point for selinuxfs.
libselinux/src/lsetfilecon.c +0 -1
@@ -25,7 +25,6 @@ int lsetfilecon_raw(const char *path, const char * context)return rc; } -hidden_def (lsetfilecon_raw)int lsetfilecon (const char *path,const char *context) {
libselinux/src/matchpathcon.c +1 -2
@@ -322,7 +322,7 @@ static void matchpathcon_thread_destructor(void __attribute__((unused)) *ptr)void __attribute__((destructor))matchpathcon_lib_destructor (void ); -void hidden __attribute__((destructor)) matchpathcon_lib_destructor(void) +void __attribute__((destructor))matchpathcon_lib_destructor (void ) {if (destructor_key_initialized)__selinux_key_delete (destructor_key);
@@ -351,7 +351,6 @@ int matchpathcon_init_prefix(const char *path, const char *subset)return hnd ?0 :-1 ; } -hidden_def (matchpathcon_init_prefix)int matchpathcon_init (const char *path) {
libselinux/src/policyvers.c +0 -2
@@ -7,7 +7,6 @@#include "selinux_internal.h" #include <stdio.h> #include "policy.h" -#include "dso.h" #include <limits.h> int security_policyvers (void )
@@ -42,4 +41,3 @@ int security_policyvers(void)return vers; } -hidden_def (security_policyvers)
libselinux/src/procattr.c +1 -20
@@ -57,7 +57,7 @@ static void procattr_thread_destructor(void __attribute__((unused)) *unused)void __attribute__((destructor))procattr_destructor (void ); -void hidden __attribute__((destructor)) procattr_destructor(void) +void __attribute__((destructor))procattr_destructor (void ) {if (destructor_key_initialized)__selinux_key_delete (destructor_key);
@@ -345,22 +345,3 @@ all_selfattr_def(con, current) all_selfattr_def(sockcreatecon, sockcreate)all_selfattr_def (keycreatecon, keycreate) - hidden_def(getcon_raw) - hidden_def(getcon) - hidden_def(getexeccon_raw) - hidden_def(getfilecon_raw) - hidden_def(getfilecon) - hidden_def(getfscreatecon_raw) - hidden_def(getkeycreatecon_raw) - hidden_def(getpeercon_raw) - hidden_def(getpidcon_raw) - hidden_def(getprevcon_raw) - hidden_def(getprevcon) - hidden_def(getsockcreatecon_raw) - hidden_def(setcon_raw) - hidden_def(setexeccon_raw) - hidden_def(setexeccon) - hidden_def(setfilecon_raw) - hidden_def(setfscreatecon_raw) - hidden_def(setkeycreatecon_raw) - hidden_def(setsockcreatecon_raw)
libselinux/src/regex.h +10 -11
@@ -10,7 +10,6 @@#include <pcre.h> #endif -#include "dso.h" enum {REGEX_MATCH ,REGEX_MATCH_PARTIAL ,
@@ -42,7 +41,7 @@ struct mmap_area;* expressions are not portable across architectures that do not have a * matching arch-string. */ -char const *regex_arch_string (void ) hidden; +char const *regex_arch_string (void ) ;/** * regex_verison returns the version string of the underlying regular
@@ -55,12 +54,12 @@ char const *regex_arch_string(void) hidden;* * It may return NULL on error. */ -char const *regex_version (void ) hidden; +char const *regex_version (void ) ;/** * This constructor function allocates a buffer for a regex_data structure. * The buffer is being initialized with zeroes. */ -struct regex_data *regex_data_create (void ) hidden; +struct regex_data *regex_data_create (void ) ;/** * This complementary destructor function frees the a given regex_data buffer. * It also frees any non NULL member pointers with the appropriate pcreX_X_free
@@ -68,7 +67,7 @@ struct regex_data *regex_data_create(void) hidden;* the pcre_extra data conditionally. Calling this function on a NULL pointer is * save. */ -void regex_data_free(struct regex_data *regex) hidden; +void regex_data_free (struct regex_data *regex) ;/** * This function compiles the regular expression. Additionally, it prepares * data structures required by the different underlying engines. For PCRE
@@ -88,7 +87,7 @@ void regex_data_free(struct regex_data *regex) hidden;* @retval -1 on error */ int regex_prepare_data (struct regex_data **regex,char const *pattern_string, - struct regex_error_data *errordata) hidden; +struct regex_error_data *errordata) ;/** * This function loads a serialized precompiled pattern from a contiguous * data region given by map_area.
@@ -109,7 +108,7 @@ int regex_prepare_data(struct regex_data **regex, char const *pattern_string,int regex_load_mmap (struct mmap_area *map_area,struct regex_data **regex,int do_load_precompregex, - bool *regex_compiled) hidden; +bool *regex_compiled) ;/** * This function stores a precompiled regular expression to a file. * In the case of PCRE, it just dumps the binary representation of the
@@ -122,7 +121,7 @@ int regex_load_mmap(struct mmap_area *map_area,* the output file (ignored by PCRE1 back-end). */ int regex_writef (struct regex_data *regex,FILE *fp, - int do_write_precompregex) hidden; +int do_write_precompregex) ;/** * This function applies a precompiled pattern to a subject string and * returns whether or not a match was found.
@@ -139,7 +138,7 @@ int regex_writef(struct regex_data *regex, FILE *fp,* regular expression */ int regex_match (struct regex_data *regex,char const *subject, - int partial) hidden; +int partial) ;/** * This function compares two compiled regular expressions (regex1 and regex2). * It compares the binary representations of the compiled patterns. It is a very
@@ -150,7 +149,7 @@ int regex_match(struct regex_data *regex, char const *subject,* the same * @retval SELABEL_INCOMPARABLE otherwise */ -int regex_cmp(struct regex_data *regex1, struct regex_data *regex2) hidden; +int regex_cmp (struct regex_data *regex1,struct regex_data *regex2) ;/** * This function takes the error data returned by regex_prepare_data and turns * it in to a human readable error message.
@@ -163,5 +162,5 @@ int regex_cmp(struct regex_data *regex1, struct regex_data *regex2) hidden;* @arg buf_size Total size of the given buffer in bytes. */ void regex_format_error (struct regex_error_data const *error_data,char *buffer, - size_t buf_size) hidden; +size_t buf_size) ;#endif /* SRC_REGEX_H_ */
libselinux/src/reject_unknown.c +0 -1
@@ -37,4 +37,3 @@ int security_reject_unknown(void)return reject_unknown; } -hidden_def (security_reject_unknown);
libselinux/src/selinux_check_securetty_context.c +0 -1
@@ -50,4 +50,3 @@ int selinux_check_securetty_context(const char * tty_context)return found; } -hidden_def (selinux_check_securetty_context)
libselinux/src/selinux_config.c +0 -36
@@ -128,7 +128,6 @@ int selinux_getenforcemode(int *enforce)return ret; } -hidden_def (selinux_getenforcemode)static char *selinux_policytype;
@@ -141,7 +140,6 @@ int selinux_getpolicytype(char **type)return *type ?0 :-1 ; } -hidden_def (selinux_getpolicytype)static int setpolicytype (const char *type) {
@@ -249,7 +247,6 @@ void selinux_reset_config(void)init_selinux_config (); } -hidden_def (selinux_reset_config)static const char *get_path (int idx) {
@@ -262,7 +259,6 @@ const char *selinux_default_type_path(void)return get_path (DEFAULT_TYPE ); } -hidden_def (selinux_default_type_path)const char *selinux_policy_root (void ) {
@@ -305,42 +301,36 @@ const char *selinux_path(void)return selinux_rootpath; } -hidden_def (selinux_path)const char *selinux_default_context_path (void ) {return get_path (DEFAULT_CONTEXTS ); } -hidden_def (selinux_default_context_path)const char *selinux_securetty_types_path (void ) {return get_path (SECURETTY_TYPES ); } -hidden_def (selinux_securetty_types_path)const char *selinux_failsafe_context_path (void ) {return get_path (FAILSAFE_CONTEXT ); } -hidden_def (selinux_failsafe_context_path)const char *selinux_removable_context_path (void ) {return get_path (REMOVABLE_CONTEXT ); } -hidden_def (selinux_removable_context_path)const char *selinux_binary_policy_path (void ) {return get_path (BINPOLICY ); } -hidden_def (selinux_binary_policy_path)const char *selinux_current_policy_path (void ) {
@@ -365,35 +355,30 @@ const char *selinux_current_policy_path(void)return policy_path; } -hidden_def (selinux_current_policy_path)const char *selinux_file_context_path (void ) {return get_path (FILE_CONTEXTS ); } -hidden_def (selinux_file_context_path)const char *selinux_homedir_context_path (void ) {return get_path (HOMEDIR_CONTEXTS ); } -hidden_def (selinux_homedir_context_path)const char *selinux_media_context_path (void ) {return get_path (MEDIA_CONTEXTS ); } -hidden_def (selinux_media_context_path)const char *selinux_customizable_types_path (void ) {return get_path (CUSTOMIZABLE_TYPES ); } -hidden_def (selinux_customizable_types_path)const char *selinux_contexts_path (void ) {
@@ -405,7 +390,6 @@ const char *selinux_user_contexts_path(void)return get_path (USER_CONTEXTS ); } -hidden_def (selinux_user_contexts_path)/* Deprecated as local policy booleans no longer supported. */ const char *selinux_booleans_path (void )
@@ -413,7 +397,6 @@ const char *selinux_booleans_path(void)return get_path (BOOLEANS ); } -hidden_def (selinux_booleans_path)/* Deprecated as no longer supported. */ const char *selinux_users_path (void )
@@ -421,127 +404,108 @@ const char *selinux_users_path(void)return get_path (USERS_DIR ); } -hidden_def (selinux_users_path)const char *selinux_usersconf_path (void ) {return get_path (SEUSERS ); } -hidden_def (selinux_usersconf_path)const char *selinux_translations_path (void ) {return get_path (TRANSLATIONS ); } -hidden_def (selinux_translations_path)const char *selinux_colors_path (void ) {return get_path (COLORS ); } -hidden_def (selinux_colors_path)const char *selinux_netfilter_context_path (void ) {return get_path (NETFILTER_CONTEXTS ); } -hidden_def (selinux_netfilter_context_path)const char *selinux_file_context_homedir_path (void ) {return get_path (FILE_CONTEXTS_HOMEDIR ); } -hidden_def (selinux_file_context_homedir_path)const char *selinux_file_context_local_path (void ) {return get_path (FILE_CONTEXTS_LOCAL ); } -hidden_def (selinux_file_context_local_path)const char *selinux_x_context_path (void ) {return get_path (X_CONTEXTS ); } -hidden_def (selinux_x_context_path)const char *selinux_virtual_domain_context_path (void ) {return get_path (VIRTUAL_DOMAIN ); } -hidden_def (selinux_virtual_domain_context_path)const char *selinux_virtual_image_context_path (void ) {return get_path (VIRTUAL_IMAGE ); } -hidden_def (selinux_virtual_image_context_path)const char *selinux_lxc_contexts_path (void ) {return get_path (LXC_CONTEXTS ); } -hidden_def (selinux_lxc_contexts_path)const char *selinux_openrc_contexts_path (void ) {return get_path (OPENRC_CONTEXTS ); } -hidden_def (selinux_openrc_contexts_path)const char *selinux_openssh_contexts_path (void ) {return get_path (OPENSSH_CONTEXTS ); } -hidden_def (selinux_openssh_contexts_path)const char *selinux_snapperd_contexts_path (void ) {return get_path (SNAPPERD_CONTEXTS ); } -hidden_def (selinux_snapperd_contexts_path)const char *selinux_systemd_contexts_path (void ) {return get_path (SYSTEMD_CONTEXTS ); } -hidden_def (selinux_systemd_contexts_path)const char *selinux_booleans_subs_path (void ) {return get_path (BOOLEAN_SUBS ); } -hidden_def (selinux_booleans_subs_path)const char *selinux_file_context_subs_path (void ) {return get_path (FILE_CONTEXT_SUBS ); } -hidden_def (selinux_file_context_subs_path)const char *selinux_file_context_subs_dist_path (void ) {return get_path (FILE_CONTEXT_SUBS_DIST ); } -hidden_def (selinux_file_context_subs_dist_path)const char *selinux_sepgsql_context_path (void ) {return get_path (SEPGSQL_CONTEXTS ); } -hidden_def (selinux_sepgsql_context_path)
libselinux/src/selinux_internal.h +5 -112
125 lines not on this page · raw message
libselinux/src/setenforce.c +0 -1
@@ -34,4 +34,3 @@ int security_setenforce(int value)return 0 ; } -hidden_def (security_setenforce)
libselinux/src/setfilecon.c +0 -1
@@ -25,7 +25,6 @@ int setfilecon_raw(const char *path, const char * context)return rc; } -hidden_def (setfilecon_raw)int setfilecon (const char *path,const char *context) {
libselinux/src/setrans_client.c +1 -7
@@ -19,7 +19,6 @@#include <ctype.h> #include <unistd.h> #include <sys/uio.h> -#include "dso.h" #include "selinux_internal.h" #include "setrans_internal.h"
@@ -260,7 +259,7 @@ static void setrans_thread_destructor(void __attribute__((unused)) *unused)void __attribute__((destructor))setrans_lib_destructor (void ); -void hidden __attribute__((destructor)) setrans_lib_destructor(void) +void __attribute__((destructor))setrans_lib_destructor (void ) {if (!has_setrans)return ;
@@ -327,7 +326,6 @@ int selinux_trans_to_raw_context(const char * trans,return *rawp ?0 :-1 ; } -hidden_def (selinux_trans_to_raw_context)int selinux_raw_to_trans_context (const char * raw,char ** transp)
@@ -369,7 +367,6 @@ int selinux_raw_to_trans_context(const char * raw,return *transp ?0 :-1 ; } -hidden_def (selinux_raw_to_trans_context)int selinux_raw_context_to_color (const char * raw,char **transp) {
@@ -410,7 +407,6 @@ int selinux_raw_context_to_color(const char * raw, char **transp)return *transp ?0 :-1 ; } -hidden_def(selinux_raw_context_to_color)#else /*DISABLE_SETRANS*/ int selinux_trans_to_raw_context(const char * trans,
@@ -426,7 +422,6 @@ int selinux_trans_to_raw_context(const char * trans,return *rawp ?0 :-1 ; } -hidden_def (selinux_trans_to_raw_context)int selinux_raw_to_trans_context (const char * raw,char ** transp)
@@ -440,5 +435,4 @@ int selinux_raw_to_trans_context(const char * raw, return *transp ? 0 : -1; } -hidden_def(selinux_raw_to_trans_context)#endif /*DISABLE_SETRANS*/
libselinux/src/seusers.c +1 -1
@@ -88,7 +88,7 @@ static int process_seusers(const char *buffer,return -2 ;/* error */ } -int require_seusers hidden = 0; +int require_seusers =0 ;#include <pwd.h> #include <grp.h>
libselinux/src/sha1.c +3 -4
@@ -23,7 +23,6 @@/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "sha1.h" -#include "dso.h" #include <memory.h> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -126,7 +125,7 @@ void// // Initialises an SHA1 Context. Use this to initialise/reset a context. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Initialise ( Sha1Context* Context
@@ -148,7 +147,7 @@ void hidden// Adds data to the SHA1 context. This will process the data and update the internal state of the context. Keep on // calling this function until all the data has been added. Then call Sha1Finalise to calculate the hash. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Update ( Sha1Context* Context,
@@ -191,7 +190,7 @@ void hidden// Performs the final calculation of the hash and returns the digest (20 byte buffer containing 160bit hash). After // calling this, Sha1Initialised must be used to reuse the context. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void hidden +void Sha1Finalise ( Sha1Context* Context,
libselinux/src/stringrep.c +0 -1
@@ -180,7 +180,6 @@ void selinux_flush_class_cache(void) discover_class_cache =NULL ; } -hidden_def (selinux_flush_class_cache)security_class_t string_to_security_class (const char *s) {
libselinux/src/validatetrans.c +0 -2
@@ -57,7 +57,6 @@ out:return ret; } -hidden_def(security_validatetrans_raw) int security_validatetrans(const char *scon, const char *tcon,
@@ -91,4 +90,3 @@ out:return ret; } -hidden_def (security_validatetrans)
Signature · 1 line
2.17.1
PATCH v3 2/4 Makefile: add -fno-semantic-interposition
In reply to [email protected]From: William Roberts <[email protected]>
Add -fno-semantic-interposition to CFLAGS. This will restore the DSO infrastructures protections to insure internal callers of exported symbols call into libselinux and not something laoding first in the library list.
Clang has this enabled by default.
--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/Makefile +1 -1
@@ -65,7 +65,7 @@ EXTRA_CFLAGS = -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nan -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 \ - -Wstrict-overflow=5 + -Wstrict-overflow=5 -fno-semantic-interposition else EXTRA_CFLAGS = -Wunused-command-line-argument endif
Signature · 1 line
2.17.1
PATCH v3 3/4 Makefile: add linker script to minimize exports
In reply to [email protected]From: William Roberts <[email protected]>
Add a linker script that exports only what was previosly exported by libselinux.
This was checked by generating an old export map (from master):
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > old.map
Then creating a new one for this library after this patch is applied:
nm --defined-only -g ./src/libselinux.so | cut -d' ' -f 3-3 | grep -v '^_' > new.map
And diffing them:
diff old.map new.map
--- libselinux/src/Makefile | 2 +- libselinux/src/libselinux.map | 249 ++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 libselinux/src/libselinux.map
libselinux/src/Makefile +1 -1
@@ -90,7 +90,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi -Werror -Wno-aggregate-return -Wno-redundant-decls \ $(EXTRA_CFLAGS) -LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro-Wl,--version-script=libselinux.map ifeq ($(OS), Darwin) override CFLAGS += -I/opt/local/include
libselinux/src/libselinux.map new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): CAEjxPJ7CuMf5QeW_jjEonRN=kfcpTV8c4UnUMyEjyb2hee1YXg@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAFftDdpeP39qvXNTe06EWkc3Kp_TMu5bGOf8WN6Q-k2Cehn_3w@mail.gmail.com
Stephen Smalley
maintainerRe: [PATCH v3 3/4] Makefile: add linker script to minimize exports
Quoted 21 lines · William Roberts
Quoted 10 lines · Stephen Smalley
Quoted 8 lines · On Fri, Feb 28, 2020 at 10:49 AM <[email protected]> wrote:
libselinux/src/Makefile +0
-0@@ -90,7 +90,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi -Werror -Wno-aggregate-return -Wno-redundant-decls \ $(EXTRA_CFLAGS)Quoted 7 lines
libselinux/src/Makefile CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi · line 93
Quoted 2 lines
libselinux/src/Makefile +1
-1-LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro-Wl,--version-script=libselinux.map
/usr/bin/ld: warning: -z relro-Wl ignored
I guess you meant relro,-Wl but you don't want that either. -Wl has to precede all the flags and it is already pre-pended later in theMakefile.
Quoted 3 lines
Grumble, did I ever say I *hate* Makefiles! v4 coming, im going to hold them so I can coalesce any other feedback
into v4.
(restored cc; I accidentally only replied to you)
Re: [PATCH v3 3/4] Makefile: add linker script to minimize exports
Quoted 24 lines · Stephen Smalley
Quoted 21 lines · William Roberts
Quoted 17 lines · Stephen Smalley
libselinux/src/Makefile CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi · line 93
Quoted 10 lines · On Fri, Feb 28, 2020 at 10:49 AM <[email protected]> wrote:
libselinux/src/Makefile +1
-1@@ -90,7 +90,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi -Werror -Wno-aggregate-return -Wno-redundant-decls \ $(EXTRA_CFLAGS) -LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro-Wl,--version-script=libselinux.map
/usr/bin/ld: warning: -z relro-Wl ignored
I guess you meant relro,-Wl but you don't want that either. -Wl has to precede all the flags and it is already pre-pended later in theMakefile.
Quoted 5 lines
Quoted 3 lines
Grumble, did I ever say I *hate* Makefiles! v4 coming, im going to hold them so I can coalesce any other feedback
into v4.(restored cc; I accidentally only replied to you)
While at it, I personally prefer if options -soname and --version-script come first (like in libsepol/src/Makefile). This way, it is "easier" for packagers to make a difference between options that are really required and the options that could be removed if the need arises (-z,defs,-z,relro). But this is nitpicking, so feel free to ignore my comment.
Thanks,
Nicolas
PATCH v3 4/4 libselinux: drop symbols from map
In reply to [email protected]From: William Roberts <[email protected]>
Previously, libselinux was exporting the following symbols:
- dir_xattr_list;
- map_class;
- map_decision;
- map_perm;
- myprintf_compat;
- unmap_class;
- unmap_perm;
However, these appear to be unused and can safely be dropped.
This is done as a seperate commit to so it can easily be reverted seperately for any reasons.
--- libselinux/src/libselinux.map | 7 ------- 1 file changed, 7 deletions(-)
libselinux/src/libselinux.map +0 -7
@@ -37,7 +37,6 @@ LIBSELINUX_1.0 { context_type_set; context_user_get; context_user_set; - dir_xattr_list; fgetfilecon; fgetfilecon_raw; fini_selinuxmnt;
@@ -80,9 +79,6 @@ LIBSELINUX_1.0 { lsetfilecon; lsetfilecon_raw; manual_user_enter_context; - map_class; - map_decision; - map_perm; matchmediacon; matchpathcon; matchpathcon_checkmatches;
@@ -94,7 +90,6 @@ LIBSELINUX_1.0 { matchpathcon_init; matchpathcon_init_prefix; mode_to_security_class; - myprintf_compat; print_access_vector; query_user_context; realpath_not_final;
@@ -242,8 +237,6 @@ LIBSELINUX_1.0 { sidput; string_to_av_perm; string_to_security_class; - unmap_class; - unmap_perm; local: *; };
Signature · 1 line
2.17.1