aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/auditsc.c
diff options
context:
space:
mode:
authorCasey Schaufler <casey@schaufler-ca.com>2024-10-09 10:32:10 -0700
committerPaul Moore <paul@paul-moore.com>2024-10-11 14:34:12 -0400
commit870b7fdc660b38c4e1bd8bf48e62aa352ddf8f42 (patch)
tree6895925c59b98edee5d7813c3ad2004507394af6 /kernel/auditsc.c
parentlsm: add the lsm_prop data structure (diff)
downloadlinux-870b7fdc660b38c4e1bd8bf48e62aa352ddf8f42.tar.gz
linux-870b7fdc660b38c4e1bd8bf48e62aa352ddf8f42.zip
lsm: use lsm_prop in security_audit_rule_match
Change the secid parameter of security_audit_rule_match to a lsm_prop structure pointer. Pass the entry from the lsm_prop structure for the approprite slot to the LSM hook. Change the users of security_audit_rule_match to use the lsm_prop instead of a u32. The scaffolding function lsmprop_init() fills the structure with the value of the old secid, ensuring that it is available to the appropriate module hook. The sources of the secid, security_task_getsecid() and security_inode_getsecid(), will be converted to use the lsm_prop structure later in the series. At that point the use of lsmprop_init() is dropped. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> [PM: subject line tweak] Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'kernel/auditsc.c')
-rw-r--r--kernel/auditsc.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index cd57053b4a69..aaf672a962d6 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -471,6 +471,7 @@ static int audit_filter_rules(struct task_struct *tsk,
const struct cred *cred;
int i, need_sid = 1;
u32 sid;
+ struct lsm_prop prop = { };
unsigned int sessionid;
if (ctx && rule->prio <= ctx->prio)
@@ -681,7 +682,10 @@ static int audit_filter_rules(struct task_struct *tsk,
security_current_getsecid_subj(&sid);
need_sid = 0;
}
- result = security_audit_rule_match(sid, f->type,
+ /* scaffolding */
+ prop.scaffold.secid = sid;
+ result = security_audit_rule_match(&prop,
+ f->type,
f->op,
f->lsm_rule);
}
@@ -696,15 +700,19 @@ static int audit_filter_rules(struct task_struct *tsk,
if (f->lsm_rule) {
/* Find files that match */
if (name) {
+ /* scaffolding */
+ prop.scaffold.secid = name->osid;
result = security_audit_rule_match(
- name->osid,
+ &prop,
f->type,
f->op,
f->lsm_rule);
} else if (ctx) {
list_for_each_entry(n, &ctx->names_list, list) {
+ /* scaffolding */
+ prop.scaffold.secid = n->osid;
if (security_audit_rule_match(
- n->osid,
+ &prop,
f->type,
f->op,
f->lsm_rule)) {
@@ -716,7 +724,9 @@ static int audit_filter_rules(struct task_struct *tsk,
/* Find ipc objects that match */
if (!ctx || ctx->type != AUDIT_IPC)
break;
- if (security_audit_rule_match(ctx->ipc.osid,
+ /* scaffolding */
+ prop.scaffold.secid = ctx->ipc.osid;
+ if (security_audit_rule_match(&prop,
f->type, f->op,
f->lsm_rule))
++result;