Re: [PATCH 03/13] selinux: Cleanup printk logging in policydb
On Tue, Jun 19, 2018 at 12:45 PM Joe Perches wrote: > > On Tue, 2018-06-19 at 12:41 -0400, Paul Moore wrote: > > On Tue, Jun 12, 2018 at 4:09 AM Peter Enderborg > > wrote: > > > > > > Replace printk with pr_* to avoid checkpatch warnings and > > > replace KERN_CONT with 2 longer prints. > > > > > > Signed-off-by: Peter Enderborg > > > --- > > > security/selinux/ss/policydb.c | 91 > > > +- > > > 1 file changed, 46 insertions(+), 45 deletions(-) > > > > Merged, thank you. While removing the separate KERN_CONT message > > introduces some duplication, I think that's the right thing to do. > > > > > diff --git 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) > > > struct hashtab_info info; > > > > > > hashtab_stat(h, ); > > > - printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets > > > used, " > > > + pr_debug("SELinux: %s: %d entries and %d/%d buckets used, " > > >"longest chain length %d\n", hash_name, h->nel, > > >info.slots_used, h->size, info.max_chain_len); > > > } > > > @@ -533,15 +533,17 @@ static int policydb_index(struct policydb *p) > > > { > > > int i, rc; > > > > > > - printk(KERN_DEBUG "SELinux: %d users, %d roles, %d types, %d > > > bools", > > > - p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, > > > p->p_bools.nprim); > > > if (p->mls_enabled) > > > - printk(KERN_CONT ", %d sens, %d cats", p->p_levels.nprim, > > > - p->p_cats.nprim); > > > - printk(KERN_CONT "\n"); > > > + pr_debug("SELinux: %d users, %d roles, %d types, %d > > > bools, %d sens, %d cats", > > > +p->p_users.nprim, p->p_roles.nprim, > > > p->p_types.nprim, > > > +p->p_bools.nprim, p->p_levels.nprim, > > > p->p_cats.nprim); > > > + else > > > + pr_debug("SELinux: %d users, %d roles, %d types, %d > > > bools", > > > +p->p_users.nprim, p->p_roles.nprim, > > > p->p_types.nprim, > > > +p->p_bools.nprim); > > This lost the terminating newline on each pr_debug Good catch. I haven't pushed to selinux/next yet, and this is pretty minor, so I'll just fix that up in the merge. -- paul moore www.paul-moore.com ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov.
Re: [PATCH 03/13] selinux: Cleanup printk logging in policydb
On Tue, 2018-06-19 at 12:41 -0400, Paul Moore wrote: > On Tue, Jun 12, 2018 at 4:09 AM Peter Enderborg > wrote: > > > > Replace printk with pr_* to avoid checkpatch warnings and > > replace KERN_CONT with 2 longer prints. > > > > Signed-off-by: Peter Enderborg > > --- > > security/selinux/ss/policydb.c | 91 > > +- > > 1 file changed, 46 insertions(+), 45 deletions(-) > > Merged, thank you. While removing the separate KERN_CONT message > introduces some duplication, I think that's the right thing to do. > > > diff --git 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) > > struct hashtab_info info; > > > > hashtab_stat(h, ); > > - printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets used, > > " > > + pr_debug("SELinux: %s: %d entries and %d/%d buckets used, " > >"longest chain length %d\n", hash_name, h->nel, > >info.slots_used, h->size, info.max_chain_len); > > } > > @@ -533,15 +533,17 @@ static int policydb_index(struct policydb *p) > > { > > int i, rc; > > > > - printk(KERN_DEBUG "SELinux: %d users, %d roles, %d types, %d > > bools", > > - p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, > > p->p_bools.nprim); > > if (p->mls_enabled) > > - printk(KERN_CONT ", %d sens, %d cats", p->p_levels.nprim, > > - p->p_cats.nprim); > > - printk(KERN_CONT "\n"); > > + pr_debug("SELinux: %d users, %d roles, %d types, %d bools, > > %d sens, %d cats", > > +p->p_users.nprim, p->p_roles.nprim, > > p->p_types.nprim, > > +p->p_bools.nprim, p->p_levels.nprim, > > p->p_cats.nprim); > > + else > > + pr_debug("SELinux: %d users, %d roles, %d types, %d bools", > > +p->p_users.nprim, p->p_roles.nprim, > > p->p_types.nprim, > > +p->p_bools.nprim); This lost the terminating newline on each pr_debug ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov.
Re: [PATCH 03/13] selinux: Cleanup printk logging in policydb
On Tue, Jun 12, 2018 at 4:09 AM Peter Enderborg wrote: > > Replace printk with pr_* to avoid checkpatch warnings and > replace KERN_CONT with 2 longer prints. > > Signed-off-by: Peter Enderborg > --- > security/selinux/ss/policydb.c | 91 > +- > 1 file changed, 46 insertions(+), 45 deletions(-) Merged, thank you. While removing the separate KERN_CONT message introduces some duplication, I think that's the right thing to do. > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c > index 6e8c8056d7ad..4e82c5fcd1a1 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) > struct hashtab_info info; > > hashtab_stat(h, ); > - printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets used, " > + pr_debug("SELinux: %s: %d entries and %d/%d buckets used, " >"longest chain length %d\n", hash_name, h->nel, >info.slots_used, h->size, info.max_chain_len); > } > @@ -533,15 +533,17 @@ static int policydb_index(struct policydb *p) > { > int i, rc; > > - printk(KERN_DEBUG "SELinux: %d users, %d roles, %d types, %d bools", > - p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, > p->p_bools.nprim); > if (p->mls_enabled) > - printk(KERN_CONT ", %d sens, %d cats", p->p_levels.nprim, > - p->p_cats.nprim); > - printk(KERN_CONT "\n"); > + pr_debug("SELinux: %d users, %d roles, %d types, %d bools, > %d sens, %d cats", > +p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, > +p->p_bools.nprim, p->p_levels.nprim, > p->p_cats.nprim); > + else > + pr_debug("SELinux: %d users, %d roles, %d types, %d bools", > +p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, > +p->p_bools.nprim); > > - printk(KERN_DEBUG "SELinux: %d classes, %d rules\n", > - p->p_classes.nprim, p->te_avtab.nel); > + pr_debug("SELinux: %d classes, %d rules\n", > +p->p_classes.nprim, p->te_avtab.nel); > > #ifdef DEBUG_HASHES > avtab_hash_eval(>te_avtab, "rules"); > @@ -897,7 +899,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab > *s) > > rc = sidtab_init(s); > if (rc) { > - printk(KERN_ERR "SELinux: out of memory on SID table > init\n"); > + pr_err("SELinux: out of memory on SID table init\n"); > goto out; > } > > @@ -905,14 +907,14 @@ int policydb_load_isids(struct policydb *p, struct > sidtab *s) > for (c = head; c; c = c->next) { > rc = -EINVAL; > if (!c->context[0].user) { > - printk(KERN_ERR "SELinux: SID %s was never > defined.\n", > + pr_err("SELinux: SID %s was never defined.\n", > c->u.name); > goto out; > } > > rc = sidtab_insert(s, c->sid[0], >context[0]); > if (rc) { > - printk(KERN_ERR "SELinux: unable to load initial SID > %s.\n", > + pr_err("SELinux: unable to load initial SID %s.\n", > c->u.name); > goto out; > } > @@ -1005,13 +1007,13 @@ static int mls_read_range_helper(struct mls_range *r, > void *fp) > rc = -EINVAL; > items = le32_to_cpu(buf[0]); > if (items > ARRAY_SIZE(buf)) { > - printk(KERN_ERR "SELinux: mls: range overflow\n"); > + pr_err("SELinux: mls: range overflow\n"); > goto out; > } > > rc = next_entry(buf, fp, sizeof(u32) * items); > if (rc) { > - printk(KERN_ERR "SELinux: mls: truncated range\n"); > + pr_err("SELinux: mls: truncated range\n"); > goto out; > } > > @@ -1023,19 +1025,19 @@ static int mls_read_range_helper(struct mls_range *r, > void *fp) > > rc = ebitmap_read(>level[0].cat, fp); > if (rc) { > - printk(KERN_ERR "SELinux: mls: error reading low > categories\n"); > + pr_err("SELinux: mls: error reading low categories\n"); > goto out; > } > if (items > 1) { > rc = ebitmap_read(>level[1].cat, fp); > if (rc) { > - printk(KERN_ERR "SELinux: mls: error reading high > categories\n"); > + pr_err("SELinux: mls: error reading high > categories\n"); > goto bad_high; > } > } else { > rc = ebitmap_cpy(>level[1].cat, >level[0].cat); > if (rc) { > -
[PATCH 03/13] 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 --- security/selinux/ss/policydb.c | 91 +- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 6e8c8056d7ad..4e82c5fcd1a1 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) struct hashtab_info info; hashtab_stat(h, ); - printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets used, " + pr_debug("SELinux: %s: %d entries and %d/%d buckets used, " "longest chain length %d\n", hash_name, h->nel, info.slots_used, h->size, info.max_chain_len); } @@ -533,15 +533,17 @@ static int policydb_index(struct policydb *p) { int i, rc; - printk(KERN_DEBUG "SELinux: %d users, %d roles, %d types, %d bools", - p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, p->p_bools.nprim); if (p->mls_enabled) - printk(KERN_CONT ", %d sens, %d cats", p->p_levels.nprim, - p->p_cats.nprim); - printk(KERN_CONT "\n"); + pr_debug("SELinux: %d users, %d roles, %d types, %d bools, %d sens, %d cats", +p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, +p->p_bools.nprim, p->p_levels.nprim, p->p_cats.nprim); + else + pr_debug("SELinux: %d users, %d roles, %d types, %d bools", +p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, +p->p_bools.nprim); - printk(KERN_DEBUG "SELinux: %d classes, %d rules\n", - p->p_classes.nprim, p->te_avtab.nel); + pr_debug("SELinux: %d classes, %d rules\n", +p->p_classes.nprim, p->te_avtab.nel); #ifdef DEBUG_HASHES avtab_hash_eval(>te_avtab, "rules"); @@ -897,7 +899,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) rc = sidtab_init(s); if (rc) { - printk(KERN_ERR "SELinux: out of memory on SID table init\n"); + pr_err("SELinux: out of memory on SID table init\n"); goto out; } @@ -905,14 +907,14 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) for (c = head; c; c = c->next) { rc = -EINVAL; if (!c->context[0].user) { - printk(KERN_ERR "SELinux: SID %s was never defined.\n", + pr_err("SELinux: SID %s was never defined.\n", c->u.name); goto out; } rc = sidtab_insert(s, c->sid[0], >context[0]); if (rc) { - printk(KERN_ERR "SELinux: unable to load initial SID %s.\n", + pr_err("SELinux: unable to load initial SID %s.\n", c->u.name); goto out; } @@ -1005,13 +1007,13 @@ static int mls_read_range_helper(struct mls_range *r, void *fp) rc = -EINVAL; items = le32_to_cpu(buf[0]); if (items > ARRAY_SIZE(buf)) { - printk(KERN_ERR "SELinux: mls: range overflow\n"); + pr_err("SELinux: mls: range overflow\n"); goto out; } rc = next_entry(buf, fp, sizeof(u32) * items); if (rc) { - printk(KERN_ERR "SELinux: mls: truncated range\n"); + pr_err("SELinux: mls: truncated range\n"); goto out; } @@ -1023,19 +1025,19 @@ static int mls_read_range_helper(struct mls_range *r, void *fp) rc = ebitmap_read(>level[0].cat, fp); if (rc) { - printk(KERN_ERR "SELinux: mls: error reading low categories\n"); + pr_err("SELinux: mls: error reading low categories\n"); goto out; } if (items > 1) { rc = ebitmap_read(>level[1].cat, fp); if (rc) { - printk(KERN_ERR "SELinux: mls: error reading high categories\n"); + pr_err("SELinux: mls: error reading high categories\n"); goto bad_high; } } else { rc = ebitmap_cpy(>level[1].cat, >level[0].cat); if (rc) { - printk(KERN_ERR "SELinux: mls: out of memory\n"); + pr_err("SELinux: mls: out of memory\n"); goto bad_high; } } @@ -1060,7 +1062,7 @@ static int context_read_and_validate(struct context *c, rc = next_entry(buf, fp, sizeof buf); if (rc) { - printk(KERN_ERR "SELinux: context truncated\n"); +