diff options
| author | peter enderborg <peter.enderborg@sony.com> | 2018-06-12 04:09:02 -0400 |
|---|---|---|
| committer | Paul Moore <paul@paul-moore.com> | 2018-06-19 12:38:48 -0400 |
| commit | 9ffdd49e3d735a5d12b5b31151893049e7075332 (patch) | |
| tree | 01345e5b0edb88a9340d0ccccc2a8dad2b2eb021 | |
| parent | 180cfc58cd9a8bf836dccde0c9e8af0d3073e4bd (diff) | |
selinux: Cleanup printk logging in policydb
Replace printk with pr_* to avoid checkpatch warnings and
replace KERN_CONT with 2 longer prints.
Signed-off-by: Peter Enderborg <peter.enderborg@sony.com>
[PM: fixed some missing newlines identified by Joe Perches]
Signed-off-by: Paul Moore <paul@paul-moore.com>
| -rw-r--r-- | security/selinux/ss/policydb.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 6e8c8056d7ad..e9394e7adc84 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c | |||
| @@ -504,7 +504,7 @@ static void hash_eval(struct hashtab *h, const char *hash_name) | |||
| 504 | struct hashtab_info info; | 504 | struct hashtab_info info; |
| 505 | 505 | ||
| 506 | hashtab_stat(h, &info); | 506 | hashtab_stat(h, &info); |
| 507 | printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets used, " | 507 | pr_debug("SELinux: %s: %d entries and %d/%d buckets used, " |
| 508 | "longest chain length %d\n", hash_name, h->nel, | 508 | "longest chain length %d\n", hash_name, h->nel, |
| 509 | info.slots_used, h->size, info.max_chain_len); | 509 | info.slots_used, h->size, info.max_chain_len); |
| 510 | } | 510 | } |
| @@ -533,15 +533,17 @@ static int policydb_index(struct policydb *p) | |||
| 533 | { | 533 | { |
| 534 | int i, rc; | 534 | int i, rc; |
| 535 | 535 | ||
| 536 | printk(KERN_DEBUG "SELinux: %d users, %d roles, %d types, %d bools", | ||
| 537 | p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, p->p_bools.nprim); | ||
| 538 | if (p->mls_enabled) | 536 | if (p->mls_enabled) |
| 539 | printk(KERN_CONT ", %d sens, %d cats", p->p_levels.nprim, | 537 | pr_debug("SELinux: %d users, %d roles, %d types, %d bools, %d sens, %d cats\n", |
| 540 | p->p_cats.nprim); | 538 | p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, |
| 541 | printk(KERN_CONT "\n"); | 539 | p->p_bools.nprim, p->p_levels.nprim, p->p_cats.nprim); |
| 540 | else | ||
| 541 | pr_debug("SELinux: %d users, %d roles, %d types, %d bools\n", | ||
| 542 | p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, | ||
| 543 | p->p_bools.nprim); | ||
| 542 | 544 | ||
| 543 | printk(KERN_DEBUG "SELinux: %d classes, %d rules\n", | 545 | pr_debug("SELinux: %d classes, %d rules\n", |
| 544 | p->p_classes.nprim, p->te_avtab.nel); | 546 | p->p_classes.nprim, p->te_avtab.nel); |
| 545 | 547 | ||
| 546 | #ifdef DEBUG_HASHES | 548 | #ifdef DEBUG_HASHES |
| 547 | avtab_hash_eval(&p->te_avtab, "rules"); | 549 | avtab_hash_eval(&p->te_avtab, "rules"); |
| @@ -897,7 +899,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) | |||
| 897 | 899 | ||
| 898 | rc = sidtab_init(s); | 900 | rc = sidtab_init(s); |
| 899 | if (rc) { | 901 | if (rc) { |
| 900 | printk(KERN_ERR "SELinux: out of memory on SID table init\n"); | 902 | pr_err("SELinux: out of memory on SID table init\n"); |
| 901 | goto out; | 903 | goto out; |
| 902 | } | 904 | } |
| 903 | 905 | ||
| @@ -905,14 +907,14 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) | |||
| 905 | for (c = head; c; c = c->next) { | 907 | for (c = head; c; c = c->next) { |
| 906 | rc = -EINVAL; | 908 | rc = -EINVAL; |
| 907 | if (!c->context[0].user) { | 909 | if (!c->context[0].user) { |
| 908 | printk(KERN_ERR "SELinux: SID %s was never defined.\n", | 910 | pr_err("SELinux: SID %s was never defined.\n", |
| 909 | c->u.name); | 911 | c->u.name); |
| 910 | goto out; | 912 | goto out; |
| 911 | } | 913 | } |
| 912 | 914 | ||
| 913 | rc = sidtab_insert(s, c->sid[0], &c->context[0]); | 915 | rc = sidtab_insert(s, c->sid[0], &c->context[0]); |
| 914 | if (rc) { | 916 | if (rc) { |
| 915 | printk(KERN_ERR "SELinux: unable to load initial SID %s.\n", | 917 | pr_err("SELinux: unable to load initial SID %s.\n", |
| 916 | c->u.name); | 918 | c->u.name); |
| 917 | goto out; | 919 | goto out; |
| 918 | } | 920 | } |
| @@ -1005,13 +1007,13 @@ static int mls_read_range_helper(struct mls_range *r, void *fp) | |||
| 1005 | rc = -EINVAL; | 1007 | rc = -EINVAL; |
| 1006 | items = le32_to_cpu(buf[0]); | 1008 | items = le32_to_cpu(buf[0]); |
| 1007 | if (items > ARRAY_SIZE(buf)) { | 1009 | if (items > ARRAY_SIZE(buf)) { |
| 1008 | printk(KERN_ERR "SELinux: mls: range overflow\n"); | 1010 | pr_err("SELinux: mls: range overflow\n"); |
| 1009 | goto out; | 1011 | goto out; |
| 1010 | } | 1012 | } |
| 1011 | 1013 | ||
| 1012 | rc = next_entry(buf, fp, sizeof(u32) * items); | 1014 | rc = next_entry(buf, fp, sizeof(u32) * items); |
| 1013 | if (rc) { | 1015 | if (rc) { |
| 1014 | printk(KERN_ERR "SELinux: mls: truncated range\n"); | 1016 | pr_err("SELinux: mls: truncated range\n"); |
| 1015 | goto out; | 1017 | goto out; |
| 1016 | } | 1018 | } |
| 1017 | 1019 | ||
| @@ -1023,19 +1025,19 @@ static int mls_read_range_helper(struct mls_range *r, void *fp) | |||
| 1023 | 1025 | ||
| 1024 | rc = ebitmap_read(&r->level[0].cat, fp); | 1026 | rc = ebitmap_read(&r->level[0].cat, fp); |
| 1025 | if (rc) { | 1027 | if (rc) { |
| 1026 | printk(KERN_ERR "SELinux: mls: error reading low categories\n"); | 1028 | pr_err("SELinux: mls: error reading low categories\n"); |
| 1027 | goto out; | 1029 | goto out; |
| 1028 | } | 1030 | } |
| 1029 | if (items > 1) { | 1031 | if (items > 1) { |
| 1030 | rc = ebitmap_read(&r->level[1].cat, fp); | 1032 | rc = ebitmap_read(&r->level[1].cat, fp); |
| 1031 | if (rc) { | 1033 | if (rc) { |
| 1032 | printk(KERN_ERR "SELinux: mls: error reading high categories\n"); | 1034 | pr_err("SELinux: mls: error reading high categories\n"); |
| 1033 | goto bad_high; | 1035 | goto bad_high; |
| 1034 | } | 1036 | } |
| 1035 | } else { | 1037 | } else { |
| 1036 | rc = ebitmap_cpy(&r->level[1].cat, &r->level[0].cat); | 1038 | rc = ebitmap_cpy(&r->level[1].cat, &r->level[0].cat); |
| 1037 | if (rc) { | 1039 | if (rc) { |
| 1038 | printk(KERN_ERR "SELinux: mls: out of memory\n"); | 1040 | pr_err("SELinux: mls: out of memory\n"); |
| 1039 | goto bad_high; | 1041 | goto bad_high; |
| 1040 | } | 1042 | } |
| 1041 | } | 1043 | } |
| @@ -1060,7 +1062,7 @@ static int context_read_and_validate(struct context *c, | |||
| 1060 | 1062 | ||
| 1061 | rc = next_entry(buf, fp, sizeof buf); | 1063 | rc = next_entry(buf, fp, sizeof buf); |
| 1062 | if (rc) { | 1064 | if (rc) { |
| 1063 | printk(KERN_ERR "SELinux: context truncated\n"); | 1065 | pr_err("SELinux: context truncated\n"); |
| 1064 | goto out; | 1066 | goto out; |
| 1065 | } | 1067 | } |
| 1066 | c->user = le32_to_cpu(buf[0]); | 1068 | c->user = le32_to_cpu(buf[0]); |
| @@ -1069,14 +1071,14 @@ static int context_read_and_validate(struct context *c, | |||
| 1069 | if (p->policyvers >= POLICYDB_VERSION_MLS) { | 1071 | if (p->policyvers >= POLICYDB_VERSION_MLS) { |
| 1070 | rc = mls_read_range_helper(&c->range, fp); | 1072 | rc = mls_read_range_helper(&c->range, fp); |
| 1071 | if (rc) { | 1073 | if (rc) { |
| 1072 | printk(KERN_ERR "SELinux: error reading MLS range of context\n"); | 1074 | pr_err("SELinux: error reading MLS range of context\n"); |
| 1073 | goto out; | 1075 | goto out; |
| 1074 | } | 1076 | } |
| 1075 | } | 1077 | } |
| 1076 | 1078 | ||
| 1077 | rc = -EINVAL; | 1079 | rc = -EINVAL; |
| 1078 | if (!policydb_context_isvalid(p, c)) { | 1080 | if (!policydb_context_isvalid(p, c)) { |
| 1079 | printk(KERN_ERR "SELinux: invalid security context\n"); | 1081 | pr_err("SELinux: invalid security context\n"); |
| 1080 | context_destroy(c); | 1082 | context_destroy(c); |
| 1081 | goto out; | 1083 | goto out; |
| 1082 | } | 1084 | } |
| @@ -1352,7 +1354,8 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp) | |||
| 1352 | rc = -EINVAL; | 1354 | rc = -EINVAL; |
| 1353 | cladatum->comdatum = hashtab_search(p->p_commons.table, cladatum->comkey); | 1355 | cladatum->comdatum = hashtab_search(p->p_commons.table, cladatum->comkey); |
| 1354 | if (!cladatum->comdatum) { | 1356 | if (!cladatum->comdatum) { |
| 1355 | printk(KERN_ERR "SELinux: unknown common %s\n", cladatum->comkey); | 1357 | pr_err("SELinux: unknown common %s\n", |
| 1358 | cladatum->comkey); | ||
| 1356 | goto bad; | 1359 | goto bad; |
| 1357 | } | 1360 | } |
| 1358 | } | 1361 | } |
| @@ -1444,7 +1447,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp) | |||
| 1444 | if (strcmp(key, OBJECT_R) == 0) { | 1447 | if (strcmp(key, OBJECT_R) == 0) { |
| 1445 | rc = -EINVAL; | 1448 | rc = -EINVAL; |
| 1446 | if (role->value != OBJECT_R_VAL) { | 1449 | if (role->value != OBJECT_R_VAL) { |
| 1447 | printk(KERN_ERR "SELinux: Role %s has wrong value %d\n", | 1450 | pr_err("SELinux: Role %s has wrong value %d\n", |
| 1448 | OBJECT_R, role->value); | 1451 | OBJECT_R, role->value); |
| 1449 | goto bad; | 1452 | goto bad; |
| 1450 | } | 1453 | } |
| @@ -1522,14 +1525,14 @@ static int mls_read_level(struct mls_level *lp, void *fp) | |||
| 1522 | 1525 | ||
| 1523 | rc = next_entry(buf, fp, sizeof buf); | 1526 | rc = next_entry(buf, fp, sizeof buf); |
| 1524 | if (rc) { | 1527 | if (rc) { |
| 1525 | printk(KERN_ERR "SELinux: mls: truncated level\n"); | 1528 | pr_err("SELinux: mls: truncated level\n"); |
| 1526 | return rc; | 1529 | return rc; |
| 1527 | } | 1530 | } |
| 1528 | lp->sens = le32_to_cpu(buf[0]); | 1531 | lp->sens = le32_to_cpu(buf[0]); |
| 1529 | 1532 | ||
| 1530 | rc = ebitmap_read(&lp->cat, fp); | 1533 | rc = ebitmap_read(&lp->cat, fp); |
| 1531 | if (rc) { | ||
