SELinux: remove all unneeded AVC callback code
Subsystems (2)
Eric Paris
maintainerPATCH 1/1 SELinux: remove all unneeded AVC callback code
We do 2 things with the AVC callback code.
1) register a function when policy is reloaded
2) update a node to add permissions
These are unrelated, but we use some of the same callback stuff as if they were related. There was other callback stuff which was completely unused. Split them and remove the other callback stuff.
Signed-off-by Eric Paris <[email protected]>
---
include/linux/audit.h | 6 ++++ security/selinux/avc.c | 60 ++++++++++------------------------------ security/selinux/include/avc.h | 11 +------ security/selinux/netif.c | 13 ++++----- security/selinux/netnode.c | 13 ++++----- security/selinux/netport.c | 13 ++++----- security/selinux/ss/services.c | 15 +--------- 7 files changed, 42 insertions(+), 89 deletions(-)
include/linux/audit.h +6 -0
@@ -718,6 +718,12 @@ extern int audit_enabled;#define audit_log_key (b, k) do { ; } while (0)#define audit_log_secctx (b,s) do { ; } while (0)#define audit_enabled 0 + +static inline int audit_update_lsm_rules (void ) +{ +return 0 ; +} +#endif #endif #endif
security/selinux/avc.c +15 -45
110 lines not on this page · raw message
security/selinux/include/avc.h +1 -10
@@ -161,16 +161,7 @@ static inline int avc_has_perm(u32 ssid, u32 tsid,u32 avc_policy_seqno (void ); -#define AVC_CALLBACK_GRANT 1 -#define AVC_CALLBACK_TRY_REVOKE 2 -#define AVC_CALLBACK_REVOKE 4 -#define AVC_CALLBACK_RESET 8 -#define AVC_CALLBACK_AUDITALLOW_ENABLE 16 -#define AVC_CALLBACK_AUDITALLOW_DISABLE 32 -#define AVC_CALLBACK_AUDITDENY_ENABLE 64 -#define AVC_CALLBACK_AUDITDENY_DISABLE 128 - -int avc_add_callback (int (*callback)(u32 event),u32 events); +int avc_add_reset_callback (int (*callback)(void ));/* Exported to selinuxfs */ int avc_get_hash_stats (char *page);
security/selinux/netif.c +6 -7
@@ -252,12 +252,11 @@ static void sel_netif_flush(void)spin_unlock_bh (&sel_netif_lock); } -static int sel_netif_avc_callback (u32 event) +static int sel_netif_avc_callback (void ) { -if (event ==AVC_CALLBACK_RESET ) { -sel_netif_flush (); -synchronize_net (); - } +sel_netif_flush (); +synchronize_net (); +return 0 ; }
@@ -291,9 +290,9 @@ static __init int sel_netif_init(void)register_netdevice_notifier (&sel_netif_netdev_notifier); - err =avc_add_callback (sel_netif_avc_callback,AVC_CALLBACK_RESET ); + err =avc_add_reset_callback (sel_netif_avc_callback);if (err) -panic ("avc_add_callback() failed, error %d\n" , err); +panic ("avc_add_reset_callback() failed, error %d\n" , err);return err; }
security/selinux/netnode.c +6 -7
@@ -297,12 +297,11 @@ static void sel_netnode_flush(void)spin_unlock_bh (&sel_netnode_lock); } -static int sel_netnode_avc_callback (u32 event) +static int sel_netnode_avc_callback (void ) { -if (event ==AVC_CALLBACK_RESET ) { -sel_netnode_flush (); -synchronize_net (); - } +sel_netnode_flush (); +synchronize_net (); +return 0 ; }
@@ -319,9 +318,9 @@ static __init int sel_netnode_init(void) sel_netnode_hash[iter].size =0 ; } - ret =avc_add_callback (sel_netnode_avc_callback,AVC_CALLBACK_RESET ); + ret =avc_add_reset_callback (sel_netnode_avc_callback);if (ret !=0 ) -panic ("avc_add_callback() failed, error %d\n" , ret); +panic ("avc_add_reset_callback() failed, error %d\n" , ret);return ret; }
security/selinux/netport.c +6 -7
@@ -234,12 +234,11 @@ static void sel_netport_flush(void)spin_unlock_bh (&sel_netport_lock); } -static int sel_netport_avc_callback (u32 event) +static int sel_netport_avc_callback (void ) { -if (event ==AVC_CALLBACK_RESET ) { -sel_netport_flush (); -synchronize_net (); - } +sel_netport_flush (); +synchronize_net (); +return 0 ; }
@@ -256,9 +255,9 @@ static __init int sel_netport_init(void) sel_netport_hash[iter].size =0 ; } - ret =avc_add_callback (sel_netport_avc_callback,AVC_CALLBACK_RESET ); + ret =avc_add_reset_callback (sel_netport_avc_callback);if (ret !=0 ) -panic ("avc_add_callback() failed, error %d\n" , ret); +panic ("avc_add_reset_callback() failed, error %d\n" , ret);return ret; }
security/selinux/ss/services.c +2 -13
@@ -3045,24 +3045,13 @@ out:return match; } -static int (*aurule_callback)(void ) = audit_update_lsm_rules; - -static int aurule_avc_callback (u32 event) -{ -int err =0 ; - -if (event ==AVC_CALLBACK_RESET && aurule_callback) - err =aurule_callback (); -return err; -} -static int __init aurule_init (void ) {int err; - err =avc_add_callback (aurule_avc_callback,AVC_CALLBACK_RESET ); + err =avc_add_reset_callback (audit_update_lsm_rules);if (err) -panic ("avc_add_callback() failed, error %d\n" , err); +panic ("avc_add_reset_callback() failed, error %d\n" , err);return err; }
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.