Skip to content

Commit

Permalink
selinux: don't require auditing
Browse files Browse the repository at this point in the history
Audit is bad. It affects performance under all circumstances. It's also
dirty.

From LWN: "Andy submitted a patch to fix this particular problem, but he
didn't stop there. He has come to the conclusion that the audit
subsystem is beyond repair, so his patch marks the whole thing as being
broken, making it generally inaccessible. He cited a number of problems
beyond this security issue: it hurts performance even when it is not
being used, it is not (in his mind) reliable, it has problems with
various architectures, and "its approach to freeing memory is
terrifying." All told, Andy said, we're better off without it"

Signed-off-by: kdrag0n <[email protected]>
Signed-off-by: Park Ju Hyung <[email protected]>
Signed-off-by: engstk <[email protected]>
  • Loading branch information
kdrag0n authored and engstk committed Aug 3, 2020
1 parent 44b8e09 commit 07d90b1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion security/selinux/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config SECURITY_SELINUX
bool "NSA SELinux Support"
depends on SECURITY_NETWORK && AUDIT && NET && INET
depends on SECURITY_NETWORK && NET && INET
select NETWORK_SECMARK
default n
help
Expand Down
10 changes: 9 additions & 1 deletion security/selinux/avc.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static inline int avc_hash(u32 ssid, u32 tsid, u16 tclass)
{
return (ssid ^ (tsid<<2) ^ (tclass<<4)) & (AVC_CACHE_SLOTS - 1);
}

#ifdef CONFIG_AUDIT
/**
* avc_dump_av - Display an access vector in human-readable form.
* @tclass: target security class
Expand Down Expand Up @@ -168,6 +168,7 @@ static void avc_dump_query(struct audit_buffer *ab, u32 ssid, u32 tsid, u16 tcla
BUG_ON(!tclass || tclass >= ARRAY_SIZE(secclass_map));
audit_log_format(ab, " tclass=%s", secclass_map[tclass-1].name);
}
#endif

/**
* avc_init - Initialize the AVC.
Expand Down Expand Up @@ -470,6 +471,7 @@ static inline int avc_xperms_audit(u32 ssid, u32 tsid, u16 tclass,
u8 perm, int result,
struct common_audit_data *ad)
{
#ifdef CONFIG_AUDIT
u32 audited, denied;

audited = avc_xperms_audit_required(
Expand All @@ -478,6 +480,9 @@ static inline int avc_xperms_audit(u32 ssid, u32 tsid, u16 tclass,
return 0;
return slow_avc_audit(ssid, tsid, tclass, requested,
audited, denied, result, ad, 0);
#else
return 0;
#endif
}

static void avc_node_free(struct rcu_head *rhead)
Expand Down Expand Up @@ -698,6 +703,7 @@ static struct avc_node *avc_insert(u32 ssid, u32 tsid, u16 tclass,
return node;
}

#ifdef CONFIG_AUDIT
/**
* avc_audit_pre_callback - SELinux specific information
* will be called by generic audit code
Expand Down Expand Up @@ -733,6 +739,7 @@ static void avc_audit_post_callback(struct audit_buffer *ab, void *a)
}
}


/* This is the slow part of avc audit with big stack footprint */
noinline int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass,
u32 requested, u32 audited, u32 denied, int result,
Expand Down Expand Up @@ -775,6 +782,7 @@ noinline int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass,
common_lsm_audit(a, avc_audit_pre_callback, avc_audit_post_callback);
return 0;
}
#endif

/**
* avc_add_callback - Register a callback for security events.
Expand Down
2 changes: 2 additions & 0 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,7 @@ static noinline int audit_inode_permission(struct inode *inode,
int result,
unsigned flags)
{
#ifdef CONFIG_AUDIT
struct common_audit_data ad;
struct inode_security_struct *isec = inode->i_security;
int rc;
Expand All @@ -3086,6 +3087,7 @@ static noinline int audit_inode_permission(struct inode *inode,
audited, denied, result, &ad, flags);
if (rc)
return rc;
#endif
return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions security/selinux/include/avc.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,17 @@ static inline int avc_audit(u32 ssid, u32 tsid,
struct common_audit_data *a,
int flags)
{
#ifdef CONFIG_AUDIT
u32 audited, denied;
audited = avc_audit_required(requested, avd, result, 0, &denied);
if (likely(!audited))
return 0;
return slow_avc_audit(ssid, tsid, tclass,
requested, audited, denied, result,
a, flags);
#else
return 0;
#endif
}

#define AVC_STRICT 1 /* Ignore permissive mode. */
Expand Down
2 changes: 2 additions & 0 deletions security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -3363,6 +3363,7 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
return match;
}

#ifdef CONFIG_AUDIT
static int (*aurule_callback)(void) = audit_update_lsm_rules;

static int aurule_avc_callback(u32 event)
Expand All @@ -3385,6 +3386,7 @@ static int __init aurule_init(void)
return err;
}
__initcall(aurule_init);
#endif

#ifdef CONFIG_NETLABEL
/**
Expand Down

0 comments on commit 07d90b1

Please sign in to comment.