Skip to content

Commit e0a8dcb

Browse files
cschauflerpcmoore
authored andcommitted
audit: use an lsm_prop in audit_names
Replace the osid field in the audit_names structure with a lsm_prop structure. This accommodates the use of an lsm_prop in security_audit_rule_match() and security_inode_getsecid(). Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> [PM: subj line tweak] Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 07f9d2c commit e0a8dcb

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

kernel/audit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct audit_names {
8282
kuid_t uid;
8383
kgid_t gid;
8484
dev_t rdev;
85-
u32 osid;
85+
struct lsm_prop oprop;
8686
struct audit_cap_data fcap;
8787
unsigned int fcap_ver;
8888
unsigned char type; /* record type */

kernel/auditsc.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -698,19 +698,15 @@ static int audit_filter_rules(struct task_struct *tsk,
698698
if (f->lsm_rule) {
699699
/* Find files that match */
700700
if (name) {
701-
/* scaffolding */
702-
prop.scaffold.secid = name->osid;
703701
result = security_audit_rule_match(
704-
&prop,
702+
&name->oprop,
705703
f->type,
706704
f->op,
707705
f->lsm_rule);
708706
} else if (ctx) {
709707
list_for_each_entry(n, &ctx->names_list, list) {
710-
/* scaffolding */
711-
prop.scaffold.secid = n->osid;
712708
if (security_audit_rule_match(
713-
&prop,
709+
&n->oprop,
714710
f->type,
715711
f->op,
716712
f->lsm_rule)) {
@@ -1562,13 +1558,11 @@ static void audit_log_name(struct audit_context *context, struct audit_names *n,
15621558
from_kgid(&init_user_ns, n->gid),
15631559
MAJOR(n->rdev),
15641560
MINOR(n->rdev));
1565-
if (n->osid != 0) {
1561+
if (lsmprop_is_set(&n->oprop)) {
15661562
char *ctx = NULL;
15671563
u32 len;
15681564

1569-
if (security_secid_to_secctx(
1570-
n->osid, &ctx, &len)) {
1571-
audit_log_format(ab, " osid=%u", n->osid);
1565+
if (security_lsmprop_to_secctx(&n->oprop, &ctx, &len)) {
15721566
if (call_panic)
15731567
*call_panic = 2;
15741568
} else {
@@ -2276,17 +2270,13 @@ static void audit_copy_inode(struct audit_names *name,
22762270
const struct dentry *dentry,
22772271
struct inode *inode, unsigned int flags)
22782272
{
2279-
struct lsm_prop prop;
2280-
22812273
name->ino = inode->i_ino;
22822274
name->dev = inode->i_sb->s_dev;
22832275
name->mode = inode->i_mode;
22842276
name->uid = inode->i_uid;
22852277
name->gid = inode->i_gid;
22862278
name->rdev = inode->i_rdev;
2287-
security_inode_getlsmprop(inode, &prop);
2288-
/* scaffolding */
2289-
name->osid = prop.scaffold.secid;
2279+
security_inode_getlsmprop(inode, &name->oprop);
22902280
if (flags & AUDIT_INODE_NOEVAL) {
22912281
name->fcap_ver = -1;
22922282
return;

0 commit comments

Comments
 (0)