History

security,lockdown,selinux: implement SELinux lockdown

Implement a SELinux hook for lockdown. If the lockdown module is also enabled, then a denial by the lockdown module will take precedence over SELinux, so SELinux can only further restrict lockdown decisions. The SELinux hook only distinguishes at the granularity of integrity versus confidentiality similar to the lockdown module, but includes the full lockdown reason as part of the audit record as a hint in diagnosing what triggered the denial. To support this auditing, move the lockdown_reasons[] string array from being private to the lockdown module to the security framework so that it can be used by the lsm audit code and so that it is always available even when the lockdown module is disabled. Note that the SELinux implementation allows the integrity and confidentiality reasons to be controlled independently from one another. Thus, in an SELinux policy, one could allow operations that specify an integrity reason while blocking operations that specify a confidentiality reason. The SELinux hook implementation is stricter than the lockdown module in validating the provided reason value. Sample AVC audit output from denials: avc: denied { integrity } for pid=3402 comm="fwupd" lockdown_reason="/dev/mem,kmem,port" scontext=system_u:system_r:fwupd_t:s0 tcontext=system_u:system_r:fwupd_t:s0 tclass=lockdown permissive=0 avc: denied { confidentiality } for pid=4628 comm="cp" lockdown_reason="/proc/kcore access" scontext=unconfined_u:unconfined_r:test_lockdown_integrity_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:test_lockdown_integrity_t:s0-s0:c0.c1023 tclass=lockdown permissive=0

Stephen Smalley committed 6 years ago

Commit 59438b41 parent d97bd237 files · +74 −27Browse files

Showing the changes to include/linux (2 of 7 files). Show all

Unified · Split

2 files
  1. include/linux/lsm_audit.h +2 −0
  2. include/linux/security.h +2 −0
include/linux/lsm_audit.h+2−0
@@ -74,6 +74,7 @@ struct common_audit_data { · 73 unmodified lines
7474 #define LSM_AUDIT_DATA_FILE 12
7575 #define LSM_AUDIT_DATA_IBPKEY 13
7676 #define LSM_AUDIT_DATA_IBENDPORT 14
77+#define LSM_AUDIT_DATA_LOCKDOWN 15
7778 union {
7879 struct path path;
7980 struct dentry *dentry;
@@ -93,6 +94,7 @@ struct common_audit_data { · 13 unmodified lines
9394 struct file *file;
9495 struct lsm_ibpkey_audit *ibpkey;
9596 struct lsm_ibendport_audit *ibendport;
97+ int reason;
9698 } u;
9799 /* this union contains LSM specific data */
98100 union {
include/linux/security.h+2−0
@@ -128,6 +128,8 @@ enum lockdown_reason { · 127 unmodified lines
128128 LOCKDOWN_CONFIDENTIALITY_MAX,
129129 };
130130
131+extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
132+
131133 /* These functions are in security/commoncap.c */
132134 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
133135 int cap, unsigned int opts);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t