From: peter enderborg <peter.enderborg@sony.com>
To: Joe Perches <joe@perches.com>, Paul Moore <paul@paul-moore.com>,
Stephen Smalley <sds@tycho.nsa.gov>,
Eric Paris <eparis@parisplace.org>,
James Morris <jmorris@namei.org>,
Daniel Jurgens <danielj@mellanox.com>,
Doug Ledford <dledford@redhat.com>, <selinux@tycho.nsa.gov>,
<linux-security-module@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
"Serge E . Hallyn" <serge@hallyn.com>
Subject: Re: [PATCH 01/13] selinux: Cleanup printk logging in conditional
Date: Wed, 13 Jun 2018 08:23:04 +0200 [thread overview]
Message-ID: <ef97b4b2-35da-7642-aa9d-de3e968cfb81@sony.com> (raw)
In-Reply-To: <a85d28e8cbd32acda21424ab6a46089f26969671.camel@perches.com>
On 06/12/2018 04:38 PM, Joe Perches wrote:
> On Tue, 2018-06-12 at 10:09 +0200, Peter Enderborg wrote:
>> Replace printk with pr_* to avoid checkpatch warnings.
> I believe it would be nicer to remove the
> "SELinux: " prefix embbeded in each format
> and use a specific
>
> #define pr_fmt(fmt) "SELinux: " fmt
>
> to automatically prefix these formats.
I cant argument about that, however some of the warnings and debug prints in this set does not have this
so it will then change the actual output. (And I also think that they should have a the prefix, but I don't
know why they don't) So I am not sure if it appropriate for a cleanup patch, it supposed to have no functional change.
>> diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
> []
>> @@ -96,7 +96,7 @@ int evaluate_cond_node(struct policydb *p, struct cond_node *node)
>> if (new_state != node->cur_state) {
>> node->cur_state = new_state;
>> if (new_state == -1)
>> - printk(KERN_ERR "SELinux: expression result was undefined - disabling all rules.\n");
>> + pr_err("SELinux: expression result was undefined - disabling all rules.\n");
>> /* turn the rules on or off */
>> for (cur = node->true_list; cur; cur = cur->next) {
>> if (new_state <= 0)
> So, for instance, this patch could become:
> (etc and so forth for each patch in this series)
>
> ---
> security/selinux/ss/conditional.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
> index c91543a617ac..e96820d92b61 100644
> --- a/security/selinux/ss/conditional.c
> +++ b/security/selinux/ss/conditional.c
> @@ -7,6 +7,8 @@
> * the Free Software Foundation, version 2.
> */
>
> +#define pr_fmt(fmt) "SELinux: " fmt
> +
> #include <linux/kernel.h>
> #include <linux/errno.h>
> #include <linux/string.h>
> @@ -96,7 +98,7 @@ int evaluate_cond_node(struct policydb *p, struct cond_node *node)
> if (new_state != node->cur_state) {
> node->cur_state = new_state;
> if (new_state == -1)
> - printk(KERN_ERR "SELinux: expression result was undefined - disabling all rules.\n");
> + pr_err("expression result was undefined - disabling all rules\n");
> /* turn the rules on or off */
> for (cur = node->true_list; cur; cur = cur->next) {
> if (new_state <= 0)
> @@ -287,7 +289,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum
> */
> if (k->specified & AVTAB_TYPE) {
> if (avtab_search(&p->te_avtab, k)) {
> - printk(KERN_ERR "SELinux: type rule already exists outside of a conditional.\n");
> + pr_err("type rule already exists outside of a conditional\n");
> goto err;
> }
> /*
> @@ -302,7 +304,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum
> node_ptr = avtab_search_node(&p->te_cond_avtab, k);
> if (node_ptr) {
> if (avtab_search_node_next(node_ptr, k->specified)) {
> - printk(KERN_ERR "SELinux: too many conflicting type rules.\n");
> + pr_err("too many conflicting type rules\n");
> goto err;
> }
> found = 0;
> @@ -313,13 +315,13 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum
> }
> }
> if (!found) {
> - printk(KERN_ERR "SELinux: conflicting type rules.\n");
> + pr_err("conflicting type rules\n");
> goto err;
> }
> }
> } else {
> if (avtab_search(&p->te_cond_avtab, k)) {
> - printk(KERN_ERR "SELinux: conflicting type rules when adding type rule for true.\n");
> + pr_err("conflicting type rules when adding type rule for true\n");
> goto err;
> }
> }
> @@ -327,7 +329,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum
>
> node_ptr = avtab_insert_nonunique(&p->te_cond_avtab, k, d);
> if (!node_ptr) {
> - printk(KERN_ERR "SELinux: could not insert rule.\n");
> + pr_err("could not insert rule\n");
> rc = -ENOMEM;
> goto err;
> }
> @@ -387,12 +389,12 @@ static int cond_read_av_list(struct policydb *p, void *fp, struct cond_av_list *
> static int expr_isvalid(struct policydb *p, struct cond_expr *expr)
> {
> if (expr->expr_type <= 0 || expr->expr_type > COND_LAST) {
> - printk(KERN_ERR "SELinux: conditional expressions uses unknown operator.\n");
> + pr_err("conditional expressions uses unknown operator\n");
> return 0;
> }
>
> if (expr->bool > p->p_bools.nprim) {
> - printk(KERN_ERR "SELinux: conditional expressions uses unknown bool.\n");
> + pr_err("conditional expressions uses unknown bool\n");
> return 0;
> }
> return 1;
>
>
next prev parent reply other threads:[~2018-06-13 6:23 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 8:08 [PATCH 00/13 selinux-next] selinux: Cleanup printk logging Peter Enderborg
2018-06-12 8:09 ` [PATCH 01/13] selinux: Cleanup printk logging in conditional Peter Enderborg
2018-06-12 14:38 ` Joe Perches
2018-06-13 6:23 ` peter enderborg [this message]
2018-06-13 17:38 ` J Freyensee
2018-06-19 15:46 ` Paul Moore
2018-06-12 8:09 ` [PATCH 02/13] selinux: Cleanup printk logging in ebitmap Peter Enderborg
2018-06-19 15:49 ` Paul Moore
2018-06-12 8:09 ` [PATCH 03/13] selinux: Cleanup printk logging in policydb Peter Enderborg
2018-06-19 16:41 ` Paul Moore
2018-06-19 16:45 ` Joe Perches
2018-06-19 16:51 ` Paul Moore
2018-06-12 8:09 ` [PATCH 04/13] selinux: Cleanup printk logging in hooks Peter Enderborg
2018-06-19 16:44 ` Paul Moore
2018-06-12 8:09 ` [PATCH 05/13] selinux: Cleanup printk logging in avtab Peter Enderborg
2018-06-19 17:03 ` Paul Moore
2018-06-12 8:09 ` [PATCH 06/13] selinux: Cleanup printk logging in services Peter Enderborg
2018-06-19 17:13 ` Paul Moore
2018-06-12 8:09 ` [PATCH 07/13] selinux: Cleanup printk logging in selinuxfs Peter Enderborg
2018-06-19 17:15 ` Paul Moore
2018-06-12 8:09 ` [PATCH 08/13] selinux: Cleanup printk logging in netlink Peter Enderborg
2018-06-19 17:34 ` Paul Moore
2018-06-12 8:09 ` [PATCH 09/13] selinux: Cleanup printk logging in sidtab Peter Enderborg
2018-06-19 17:39 ` Paul Moore
2018-06-12 8:09 ` [PATCH 10/13] selinux: Cleanup printk logging in netport Peter Enderborg
2018-06-19 17:44 ` Paul Moore
2018-06-12 8:09 ` [PATCH 11/13] selinux: Cleanup printk logging in netif Peter Enderborg
2018-06-19 17:46 ` Paul Moore
2018-06-12 8:09 ` [PATCH 12/13] selinux: Cleanup printk logging in avc Peter Enderborg
2018-06-19 17:48 ` Paul Moore
2018-06-12 8:09 ` [PATCH 13/13] selinux: Cleanup printk logging in netnode Peter Enderborg
2018-06-19 17:50 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef97b4b2-35da-7642-aa9d-de3e968cfb81@sony.com \
--to=peter.enderborg@sony.com \
--cc=danielj@mellanox.com \
--cc=dledford@redhat.com \
--cc=eparis@parisplace.org \
--cc=jmorris@namei.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=serge@hallyn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox