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
74#define LSM_AUDIT_DATA_FILE 1274#define LSM_AUDIT_DATA_FILE 12
75#define LSM_AUDIT_DATA_IBPKEY 1375#define LSM_AUDIT_DATA_IBPKEY 13
76#define LSM_AUDIT_DATA_IBENDPORT 1476#define LSM_AUDIT_DATA_IBENDPORT 14
77#define LSM_AUDIT_DATA_LOCKDOWN 15
77 union {78 union {
78 struct path path;79 struct path path;
79 struct dentry *dentry;80 struct dentry *dentry;
@@ -93,6 +94,7 @@ struct common_audit_data { · 13 unmodified lines
93 struct file *file;94 struct file *file;
94 struct lsm_ibpkey_audit *ibpkey;95 struct lsm_ibpkey_audit *ibpkey;
95 struct lsm_ibendport_audit *ibendport;96 struct lsm_ibendport_audit *ibendport;
97 int reason;
96 } u;98 } u;
97 /* this union contains LSM specific data */99 /* this union contains LSM specific data */
98 union {100 union {
include/linux/security.h+2−0
@@ -128,6 +128,8 @@ enum lockdown_reason { · 127 unmodified lines
128 LOCKDOWN_CONFIDENTIALITY_MAX,128 LOCKDOWN_CONFIDENTIALITY_MAX,
129};129};
130 130
131extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
132
131/* These functions are in security/commoncap.c */133/* These functions are in security/commoncap.c */
132extern int cap_capable(const struct cred *cred, struct user_namespace *ns,134extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
133 int cap, unsigned int opts);135 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