Skip to content

Commit ee5de60

Browse files
WOnder93pcmoore
authored andcommitted
selinuxfs: unify policy load error reporting
Let's drop the pr_err()s from sel_make_policy_nodes() and just add one pr_warn_ratelimited() call to the sel_make_policy_nodes() error path in sel_write_load(). Changing from error to warning makes sense, since after 02a52c5 ("selinux: move policy commit after updating selinuxfs"), this error path no longer leads to a broken selinuxfs tree (it's just kept in the original state and policy load is aborted). I also added _ratelimited to be consistent with the other prtin in the same function (it's probably not necessary, but can't really hurt... there are likely more important error messages to be printed when filesystem entry creation starts erroring out). Suggested-by: Paul Moore <[email protected]> Signed-off-by: Ondrej Mosnacek <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 6406887 commit ee5de60

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

security/selinux/selinuxfs.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,17 +563,13 @@ static int sel_make_policy_nodes(struct selinux_fs_info *fsi,
563563

564564
ret = sel_make_bools(newpolicy, tmp_bool_dir, &tmp_bool_num,
565565
&tmp_bool_names, &tmp_bool_values);
566-
if (ret) {
567-
pr_err("SELinux: failed to load policy booleans\n");
566+
if (ret)
568567
goto out;
569-
}
570568

571569
ret = sel_make_classes(newpolicy, tmp_class_dir,
572570
&fsi->last_class_ino);
573-
if (ret) {
574-
pr_err("SELinux: failed to load policy classes\n");
571+
if (ret)
575572
goto out;
576-
}
577573

578574
/* booleans */
579575
old_dentry = fsi->bool_dir;
@@ -650,6 +646,7 @@ static ssize_t sel_write_load(struct file *file, const char __user *buf,
650646

651647
length = sel_make_policy_nodes(fsi, load_state.policy);
652648
if (length) {
649+
pr_warn_ratelimited("SELinux: failed to initialize selinuxfs\n");
653650
selinux_policy_cancel(fsi->state, &load_state);
654651
goto out;
655652
}

0 commit comments

Comments
 (0)