diff options
author | peter enderborg <peter.enderborg@sony.com> | 2018-06-12 04:09:03 -0400 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2018-06-19 12:58:23 -0400 |
commit | c103a91e8916540c774805af11ed4bc3ba75f874 (patch) | |
tree | e770c55327fd000469a6216199198aed3ff540a0 /security/selinux/hooks.c | |
parent | 9ffdd49e3d735a5d12b5b31151893049e7075332 (diff) |
selinux: Cleanup printk logging in hooks
Replace printk with pr_* to avoid checkpatch warnings.
Signed-off-by: Peter Enderborg <peter.enderborg@sony.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 2b5ee5fbd652..f78318af8254 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -530,7 +530,7 @@ static int sb_finish_set_opts(struct super_block *sb) | |||
530 | the first boot of the SELinux kernel before we have | 530 | the first boot of the SELinux kernel before we have |
531 | assigned xattr values to the filesystem. */ | 531 | assigned xattr values to the filesystem. */ |
532 | if (!(root_inode->i_opflags & IOP_XATTR)) { | 532 | if (!(root_inode->i_opflags & IOP_XATTR)) { |
533 | printk(KERN_WARNING "SELinux: (dev %s, type %s) has no " | 533 | pr_warn("SELinux: (dev %s, type %s) has no " |
534 | "xattr support\n", sb->s_id, sb->s_type->name); | 534 | "xattr support\n", sb->s_id, sb->s_type->name); |
535 | rc = -EOPNOTSUPP; | 535 | rc = -EOPNOTSUPP; |
536 | goto out; | 536 | goto out; |
@@ -539,11 +539,11 @@ static int sb_finish_set_opts(struct super_block *sb) | |||
539 | rc = __vfs_getxattr(root, root_inode, XATTR_NAME_SELINUX, NULL, 0); | 539 | rc = __vfs_getxattr(root, root_inode, XATTR_NAME_SELINUX, NULL, 0); |
540 | if (rc < 0 && rc != -ENODATA) { | 540 | if (rc < 0 && rc != -ENODATA) { |
541 | if (rc == -EOPNOTSUPP) | 541 | if (rc == -EOPNOTSUPP) |
542 | printk(KERN_WARNING "SELinux: (dev %s, type " | 542 | pr_warn("SELinux: (dev %s, type " |
543 | "%s) has no security xattr handler\n", | 543 | "%s) has no security xattr handler\n", |
544 | sb->s_id, sb->s_type->name); | 544 | sb->s_id, sb->s_type->name); |
545 | else | 545 | else |
546 | printk(KERN_WARNING "SELinux: (dev %s, type " | 546 | pr_warn("SELinux: (dev %s, type " |
547 | "%s) getxattr errno %d\n", sb->s_id, | 547 | "%s) getxattr errno %d\n", sb->s_id, |
548 | sb->s_type->name, -rc); | 548 | sb->s_type->name, -rc); |
549 | goto out; | 549 | goto out; |
@@ -742,7 +742,7 @@ static int selinux_set_mnt_opts(struct super_block *sb, | |||
742 | goto out; | 742 | goto out; |
743 | } | 743 | } |
744 | rc = -EINVAL; | 744 | rc = -EINVAL; |
745 | printk(KERN_WARNING "SELinux: Unable to set superblock options " | 745 | pr_warn("SELinux: Unable to set superblock options " |
746 | "before the security server is initialized\n"); | 746 | "before the security server is initialized\n"); |
747 | goto out; | 747 | goto out; |
748 | } | 748 | } |
@@ -784,7 +784,7 @@ static int selinux_set_mnt_opts(struct super_block *sb, | |||
784 | mount_options[i], &sid, | 784 | mount_options[i], &sid, |
785 | GFP_KERNEL); | 785 | GFP_KERNEL); |
786 | if (rc) { | 786 | if (rc) { |
787 | printk(KERN_WARNING "SELinux: security_context_str_to_sid" | 787 | pr_warn("SELinux: security_context_str_to_sid" |
788 | "(%s) failed for (dev %s, type %s) errno=%d\n", | 788 | "(%s) failed for (dev %s, type %s) errno=%d\n", |
789 | mount_options[i], sb->s_id, name, rc); | 789 | mount_options[i], sb->s_id, name, rc); |
790 | goto out; | 790 | goto out; |
@@ -860,8 +860,7 @@ static int selinux_set_mnt_opts(struct super_block *sb, | |||
860 | */ | 860 | */ |
861 | rc = security_fs_use(&selinux_state, sb); | 861 | rc = security_fs_use(&selinux_state, sb); |
862 | if (rc) { | 862 | if (rc) { |
863 | printk(KERN_WARNING | 863 | pr_warn("%s: security_fs_use(%s) returned %d\n", |
864 | "%s: security_fs_use(%s) returned %d\n", | ||
865 | __func__, sb->s_type->name, rc); | 864 | __func__, sb->s_type->name, rc); |
866 | goto out; | 865 | goto out; |
867 | } | 866 | } |
@@ -947,7 +946,7 @@ static int selinux_set_mnt_opts(struct super_block *sb, | |||
947 | if (sbsec->behavior != SECURITY_FS_USE_XATTR && | 946 | if (sbsec->behavior != SECURITY_FS_USE_XATTR && |
948 | sbsec->behavior != SECURITY_FS_USE_NATIVE) { | 947 | sbsec->behavior != SECURITY_FS_USE_NATIVE) { |
949 | rc = -EINVAL; | 948 | rc = -EINVAL; |
950 | printk(KERN_WARNING "SELinux: defcontext option is " | 949 | pr_warn("SELinux: defcontext option is " |
951 | "invalid for this filesystem type\n"); | 950 | "invalid for this filesystem type\n"); |
952 | goto out; | 951 | goto out; |
953 | } | 952 | } |
@@ -969,7 +968,7 @@ out: | |||
969 | return rc; | 968 | return rc; |
970 | out_double_mount: | 969 | out_double_mount: |
971 | rc = -EINVAL; | 970 | rc = -EINVAL; |
972 | printk(KERN_WARNING "SELinux: mount invalid. Same superblock, different " | 971 | pr_warn("SELinux: mount invalid. Same superblock, different " |
973 | "security settings for (dev %s, type %s)\n", sb->s_id, name); | 972 | "security settings for (dev %s, type %s)\n", sb->s_id, name); |
974 | goto out; | 973 | goto out; |
975 | } | 974 | } |
@@ -998,7 +997,7 @@ static int selinux_cmp_sb_context(const struct super_block *oldsb, | |||
998 | } | 997 | } |
999 | return 0; | 998 | return 0; |
1000 | mismatch: | 999 | mismatch: |
1001 | printk(KERN_WARNING "SELinux: mount invalid. Same superblock, " | 1000 | pr_warn("SELinux: mount invalid. Same superblock, " |
1002 | "different security settings for (dev %s, " | 1001 | "different security settings for (dev %s, " |
1003 | "type %s)\n", newsb->s_id, newsb->s_type->name); | 1002 | "type %s)\n", newsb->s_id, newsb->s_type->name); |
1004 | return -EBUSY; | 1003 | return -EBUSY; |
@@ -1106,7 +1105,7 @@ static int selinux_parse_opts_str(char *options, | |||
1106 | case Opt_context: | 1105 | case Opt_context: |
1107 | if (context || defcontext) { | 1106 | if (context || defcontext) { |
1108 | rc = -EINVAL; | 1107 | rc = -EINVAL; |
1109 | printk(KERN_WARNING SEL_MOUNT_FAIL_MSG); | 1108 | pr_warn(SEL_MOUNT_FAIL_MSG); |
1110 | goto out_err; | 1109 | goto out_err; |
1111 | } | 1110 | } |
1112 | context = match_strdup(&args[0]); | 1111 | context = match_strdup(&args[0]); |
@@ -1119,7 +1118,7 @@ static int selinux_parse_opts_str(char *options, | |||
1119 | case Opt_fscontext: | 1118 | case Opt_fscontext: |
1120 | if (fscontext) { | 1119 | if (fscontext) { |
1121 | rc = -EINVAL; | 1120 | rc = -EINVAL; |
1122 | printk(KERN_WARNING SEL_MOUNT_FAIL_MSG); | 1121 | pr_warn(SEL_MOUNT_FAIL_MSG); |
1123 | goto out_err; | 1122 | goto out_err; |
1124 | } | 1123 | } |
1125 | fscontext = match_strdup(&args[0]); | 1124 | fscontext = match_strdup(&args[0]); |
@@ -1132,7 +1131,7 @@ static int selinux_parse_opts_str(char *options, | |||
1132 | case Opt_rootcontext: | 1131 | case Opt_rootcontext: |
1133 | if (rootcontext) { | 1132 | if (rootcontext) { |
1134 | rc = -EINVAL; | 1133 | rc = -EINVAL; |
1135 | printk(KERN_WARNING SEL_MOUNT_FAIL_MSG); | 1134 | pr_warn(SEL_MOUNT_FAIL_MSG); |
1136 | goto out_err; | 1135 | goto out_err; |
1137 | } | 1136 | } |
1138 | rootcontext = match_strdup(&args[0]); | 1137 | rootcontext = match_strdup(&args[0]); |
@@ -1145,7 +1144,7 @@ static int selinux_parse_opts_str(char *options, | |||
1145 | case Opt_defcontext: | 1144 | case Opt_defcontext: |
1146 | if (context || defcontext) { | 1145 | if (context || defcontext) { |
1147 | rc = -EINVAL; | 1146 | rc = -EINVAL; |
1148 | printk(KERN_WARNING SEL_MOUNT_FAIL_MSG); | 1147 | pr_warn(SEL_MOUNT_FAIL_MSG); |
1149 | goto out_err; | 1148 | goto out_err; |
1150 | } | 1149 | } |
1151 | defcontext = match_strdup(&args[0]); | 1150 | defcontext = match_strdup(&args[0]); |
@@ -1158,7 +1157,7 @@ static int selinux_parse_opts_str(char *options, | |||
1158 | break; | 1157 | break; |
1159 | default: | 1158 | default: |
1160 | rc = -EINVAL; | 1159 | rc = -EINVAL; |
1161 | printk(KERN_WARNING "SELinux: unknown mount option\n"); | 1160 | pr_warn("SELinux: unknown mount option\n"); |
1162 | goto out_err; | 1161 | goto out_err; |
1163 | 1162 | ||
1164 | } | 1163 | } |
@@ -1623,7 +1622,7 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent | |||
1623 | dput(dentry); | 1622 | dput(dentry); |
1624 | if (rc < 0) { | 1623 | if (rc < 0) { |
1625 | if (rc != -ENODATA) { | 1624 | if (rc != -ENODATA) { |
1626 | printk(KERN_WARNING "SELinux: %s: getxattr returned " | 1625 | pr_warn("SELinux: %s: getxattr returned " |
1627 | "%d for dev=%s ino=%ld\n", __func__, | 1626 | "%d for dev=%s ino=%ld\n", __func__, |
1628 | -rc, inode->i_sb->s_id, inode->i_ino); | 1627 | -rc, inode->i_sb->s_id, inode->i_ino); |
1629 | kfree(context); | 1628 | kfree(context); |
@@ -1643,11 +1642,11 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent | |||
1643 | 1642 | ||
1644 | if (rc == -EINVAL) { | 1643 | if (rc == -EINVAL) { |
1645 | if (printk_ratelimit()) | 1644 | if (printk_ratelimit()) |
1646 | printk(KERN_NOTICE "SELinux: inode=%lu on dev=%s was found to have an invalid " | 1645 | pr_notice("SELinux: inode=%lu on dev=%s was found to have an invalid " |
1647 | "context=%s. This indicates you may need to relabel the inode or the " | 1646 | "context=%s. This indicates you may need to relabel the inode or the " |
1648 | "filesystem in question.\n", ino, dev, context); | 1647 | "filesystem in question.\n", ino, dev, context); |
1649 | } else { | 1648 | } else { |
1650 | printk(KERN_WARNING "SELinux: %s: context_to_sid(%s) " | 1649 | pr_warn("SELinux: %s: context_to_sid(%s) " |
1651 | "returned %d for dev=%s ino=%ld\n", | 1650 | "returned %d for dev=%s ino=%ld\n", |
1652 | __func__, context, -rc, dev, ino); | 1651 | __func__, context, -rc, dev, ino); |
1653 | } | 1652 | } |
@@ -1785,8 +1784,7 @@ static int cred_has_capability(const struct cred *cred, | |||
1785 | sclass = initns ? SECCLASS_CAPABILITY2 : SECCLASS_CAP2_USERNS; | 1784 | sclass = initns ? SECCLASS_CAPABILITY2 : SECCLASS_CAP2_USERNS; |
1786 | break; | 1785 | break; |
1787 | default: | 1786 | default: |
1788 | printk(KERN_ERR | 1787 | pr_err("SELinux: out of range capability %d\n", cap); |
1789 | "SELinux: out of range capability %d\n", cap); | ||
1790 | BUG(); | 1788 | BUG(); |
1791 | return -EINVAL; | 1789 | return -EINVAL; |
1792 | } | 1790 | } |
@@ -2029,7 +2027,7 @@ static int may_link(struct inode *dir, | |||
2029 | av = DIR__RMDIR; | 2027 | av = DIR__RMDIR; |
2030 | break; | 2028 | break; |
2031 | default: | 2029 | default: |
2032 | printk(KERN_WARNING "SELinux: %s: unrecognized kind %d\n", | 2030 | pr_warn("SELinux: %s: unrecognized kind %d\n", |
2033 | __func__, kind); | 2031 | __func__, kind); |
2034 | return 0; | 2032 | return 0; |
2035 | } | 2033 | } |
@@ -2875,7 +2873,7 @@ static int selinux_sb_remount(struct super_block *sb, void *data) | |||
2875 | mount_options[i], &sid, | 2873 | mount_options[i], &sid, |
2876 | GFP_KERNEL); | 2874 | GFP_KERNEL); |
2877 | if (rc) { | 2875 | if (rc) { |
2878 | printk(KERN_WARNING "SELinux: security_context_str_to_sid" | 2876 | pr_warn("SELinux: security_context_str_to_sid" |
2879 | "(%s) failed for (dev %s, type %s) errno=%d\n", | 2877 | "(%s) failed for (dev %s, type %s) errno=%d\n", |
2880 | mount_options[i], sb->s_id, sb->s_type->name, rc); | 2878 | mount_options[i], sb->s_id, sb->s_type->name, rc); |
2881 | goto out_free_opts; | 2879 | goto out_free_opts; |
@@ -2914,7 +2912,7 @@ out_free_secdata: | |||
2914 | free_secdata(secdata); | 2912 | free_secdata(secdata); |
2915 | return rc; | 2913 | return rc; |
2916 | out_bad_option: | 2914 | out_bad_option: |
2917 | printk(KERN_WARNING "SELinux: unable to change security options " | 2915 | pr_warn("SELinux: unable to change security options " |
2918 | "during remount (dev %s, type=%s)\n", sb->s_id, | 2916 | "during remount (dev %s, type=%s)\n", sb->s_id, |
2919 | sb->s_type->name); | 2917 | sb->s_type->name); |
2920 | goto out_free_opts; | 2918 | goto out_free_opts; |
@@ -3357,7 +3355,7 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name, | |||
3357 | rc = security_context_to_sid_force(&selinux_state, value, size, | 3355 | rc = security_context_to_sid_force(&selinux_state, value, size, |
3358 | &newsid); | 3356 | &newsid); |
3359 | if (rc) { | 3357 | if (rc) { |
3360 | printk(KERN_ERR "SELinux: unable to map context to SID" | 3358 | pr_err("SELinux: unable to map context to SID" |
3361 | "for (%s, %lu), rc=%d\n", | 3359 | "for (%s, %lu), rc=%d\n", |
3362 | inode->i_sb->s_id, inode->i_ino, -rc); | 3360 | inode->i_sb->s_id, inode->i_ino, -rc); |
3363 | return; | 3361 | return; |
@@ -4420,7 +4418,7 @@ static int selinux_parse_skb(struct sk_buff *skb, struct common_audit_data *ad, | |||
4420 | } | 4418 | } |
4421 | 4419 | ||
4422 | parse_error: | 4420 | parse_error: |
4423 | printk(KERN_WARNING | 4421 | pr_warn( |
4424 | "SELinux: failure in selinux_parse_skb()," | 4422 | "SELinux: failure in selinux_parse_skb()," |
4425 | " unable to parse packet\n"); | 4423 | " unable to parse packet\n"); |
4426 | return ret; | 4424 | return ret; |
@@ -4463,7 +4461,7 @@ static int selinux_skb_peerlbl_sid(struct sk_buff *skb, u16 family, u32 *sid) | |||
4463 | err = security_net_peersid_resolve(&selinux_state, nlbl_sid, | 4461 | err = security_net_peersid_resolve(&selinux_state, nlbl_sid, |
4464 | nlbl_type, xfrm_sid, sid); | 4462 | nlbl_type, xfrm_sid, sid); |
4465 | if (unlikely(err)) { | 4463 | if (unlikely(err)) { |
4466 | printk(KERN_WARNING | 4464 | pr_warn( |
4467 | "SELinux: failure in selinux_skb_peerlbl_sid()," | 4465 | "SELinux: failure in selinux_skb_peerlbl_sid()," |
4468 | " unable to determine packet's peer label\n"); | 4466 | " unable to determine packet's peer label\n"); |
4469 | return -EACCES; | 4467 | return -EACCES; |
@@ -7126,11 +7124,11 @@ static __init int selinux_init(void) | |||
7126 | } | 7124 | } |
7127 | 7125 | ||
7128 | if (!selinux_enabled) { | 7126 | if (!selinux_enabled) { |
7129 | printk(KERN_INFO "SELinux: Disabled at boot.\n"); | 7127 | pr_info("SELinux: Disabled at boot.\n"); |
7130 | return 0; | 7128 | return 0; |
7131 | } | 7129 | } |
7132 | 7130 | ||
7133 | printk(KERN_INFO "SELinux: Initializing.\n"); | 7131 | pr_info("SELinux: Initializing.\n"); |
7134 | 7132 | ||
7135 | memset(&selinux_state, 0, sizeof(selinux_state)); | 7133 | memset(&selinux_state, 0, sizeof(selinux_state)); |
7136 | enforcing_set(&selinux_state, selinux_enforcing_boot); | 7134 | enforcing_set(&selinux_state, selinux_enforcing_boot); |
@@ -7166,9 +7164,9 @@ static __init int selinux_init(void) | |||
7166 | panic("SELinux: Unable to register AVC LSM notifier callback\n"); | 7164 | panic("SELinux: Unable to register AVC LSM notifier callback\n"); |
7167 | 7165 | ||
7168 | if (selinux_enforcing_boot) | 7166 | if (selinux_enforcing_boot) |
7169 | printk(KERN_DEBUG "SELinux: Starting in enforcing mode\n"); | 7167 | pr_debug("SELinux: Starting in enforcing mode\n"); |
7170 | else | 7168 | else |
7171 | printk(KERN_DEBUG "SELinux: Starting in permissive mode\n"); | 7169 | pr_debug("SELinux: Starting in permissive mode\n"); |
7172 | 7170 | ||
7173 | return 0; | 7171 | return 0; |
7174 | } | 7172 | } |
@@ -7180,10 +7178,10 @@ static void delayed_superblock_init(struct super_block *sb, void *unused) | |||
7180 | 7178 | ||
7181 | void selinux_complete_init(void) | 7179 | void selinux_complete_init(void) |
7182 | { | 7180 | { |
7183 | printk(KERN_DEBUG "SELinux: Completing initialization.\n"); | 7181 | pr_debug("SELinux: Completing initialization.\n"); |
7184 | 7182 | ||
7185 | /* Set up any superblocks initialized prior to the policy load. */ | 7183 | /* Set up any superblocks initialized prior to the policy load. */ |
7186 | printk(KERN_DEBUG "SELinux: Setting up existing superblocks.\n"); | 7184 | pr_debug("SELinux: Setting up existing superblocks.\n"); |
7187 | iterate_supers(delayed_superblock_init, NULL); | 7185 | iterate_supers(delayed_superblock_init, NULL); |
7188 | } | 7186 | } |
7189 | 7187 | ||
@@ -7258,7 +7256,7 @@ static int __init selinux_nf_ip_init(void) | |||
7258 | if (!selinux_enabled) | 7256 | if (!selinux_enabled) |
7259 | return 0; | 7257 | return 0; |
7260 | 7258 | ||
7261 | printk(KERN_DEBUG "SELinux: Registering netfilter hooks\n"); | 7259 | pr_debug("SELinux: Registering netfilter hooks\n"); |
7262 | 7260 | ||
7263 | err = register_pernet_subsys(&selinux_net_ops); | 7261 | err = register_pernet_subsys(&selinux_net_ops); |
7264 | if (err) | 7262 | if (err) |
@@ -7271,7 +7269,7 @@ __initcall(selinux_nf_ip_init); | |||
7271 | #ifdef CONFIG_SECURITY_SELINUX_DISABLE | 7269 | #ifdef CONFIG_SECURITY_SELINUX_DISABLE |
7272 | static void selinux_nf_ip_exit(void) | 7270 | static void selinux_nf_ip_exit(void) |
7273 | { | 7271 | { |
7274 | printk(KERN_DEBUG "SELinux: Unregistering netfilter hooks\n"); | 7272 | pr_debug("SELinux: Unregistering netfilter hooks\n"); |
7275 | 7273 | ||
7276 | unregister_pernet_subsys(&selinux_net_ops); | 7274 | unregister_pernet_subsys(&selinux_net_ops); |
7277 | } | 7275 | } |
@@ -7300,7 +7298,7 @@ int selinux_disable(struct selinux_state *state) | |||
7300 | 7298 | ||
7301 | state->disabled = 1; | 7299 | state->disabled = 1; |
7302 | 7300 | ||
7303 | printk(KERN_INFO "SELinux: Disabled at runtime.\n"); | 7301 | pr_info("SELinux: Disabled at runtime.\n"); |
7304 | 7302 | ||
7305 | selinux_enabled = 0; | 7303 | selinux_enabled = 0; |
7306 | 7304 | ||