Skip to content

Commit 7383c0f

Browse files
stephensmalleypcmoore
authored andcommitted
selinux: log error messages on required process class / permissions
In general SELinux no longer treats undefined object classes or permissions in the policy as a fatal error, instead handling them in accordance with handle_unknown. However, the process class and process transition and dyntransition permissions are still required to be defined due to dependencies on these definitions for default labeling behaviors, role and range transitions in older policy versions that lack an explicit class field, and role allow checking. Log error messages in these cases since otherwise the policy load will fail silently with no indication to the user as to the underlying cause. While here, fix the checking for process transition / dyntransition so that omitting either permission is handled as an error; both are needed in order to ensure that role allow checking is consistently applied. Reported-by: bauen1 <[email protected]> Signed-off-by: Stephen Smalley <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 382c2b5 commit 7383c0f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

security/selinux/ss/policydb.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,7 @@ int policydb_read(struct policydb *p, void *fp)
23762376
struct role_trans_datum *rtd = NULL;
23772377
int i, j, rc;
23782378
__le32 buf[4];
2379-
u32 len, nprim, nel;
2379+
u32 len, nprim, nel, perm;
23802380

23812381
char *policydb_str;
23822382
struct policydb_compat_info *info;
@@ -2519,8 +2519,10 @@ int policydb_read(struct policydb *p, void *fp)
25192519

25202520
rc = -EINVAL;
25212521
p->process_class = string_to_security_class(p, "process");
2522-
if (!p->process_class)
2522+
if (!p->process_class) {
2523+
pr_err("SELinux: process class is required, not defined in policy\n");
25232524
goto bad;
2525+
}
25242526

25252527
rc = avtab_read(&p->te_avtab, fp, p);
25262528
if (rc)
@@ -2618,10 +2620,18 @@ int policydb_read(struct policydb *p, void *fp)
26182620
goto bad;
26192621

26202622
rc = -EINVAL;
2621-
p->process_trans_perms = string_to_av_perm(p, p->process_class, "transition");
2622-
p->process_trans_perms |= string_to_av_perm(p, p->process_class, "dyntransition");
2623-
if (!p->process_trans_perms)
2623+
perm = string_to_av_perm(p, p->process_class, "transition");
2624+
if (!perm) {
2625+
pr_err("SELinux: process transition permission is required, not defined in policy\n");
2626+
goto bad;
2627+
}
2628+
p->process_trans_perms = perm;
2629+
perm = string_to_av_perm(p, p->process_class, "dyntransition");
2630+
if (!perm) {
2631+
pr_err("SELinux: process dyntransition permission is required, not defined in policy\n");
26242632
goto bad;
2633+
}
2634+
p->process_trans_perms |= perm;
26252635

26262636
rc = ocontext_read(p, info, fp);
26272637
if (rc)

0 commit comments

Comments
 (0)