From patchwork Tue Jun 12 14:38:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 10460485 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B963601A0 for ; Tue, 12 Jun 2018 14:38:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39D84287A0 for ; Tue, 12 Jun 2018 14:38:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D902287B2; Tue, 12 Jun 2018 14:38:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58A84287A0 for ; Tue, 12 Jun 2018 14:38:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933076AbeFLOiH (ORCPT ); Tue, 12 Jun 2018 10:38:07 -0400 Received: from smtprelay0253.hostedemail.com ([216.40.44.253]:49021 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932905AbeFLOiG (ORCPT ); Tue, 12 Jun 2018 10:38:06 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id 6DA501358B; Tue, 12 Jun 2018 14:38:05 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: magic94_2907044760740 X-Filterd-Recvd-Size: 5348 Received: from XPS-9350.home (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Tue, 12 Jun 2018 14:38:01 +0000 (UTC) Message-ID: Subject: Re: [PATCH 01/13] selinux: Cleanup printk logging in conditional From: Joe Perches To: Peter Enderborg , Paul Moore , Stephen Smalley , Eric Paris , James Morris , Daniel Jurgens , Doug Ledford , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, "Serge E . Hallyn" Date: Tue, 12 Jun 2018 07:38:00 -0700 In-Reply-To: <20180612080912.7827-2-peter.enderborg@sony.com> References: <20180612080912.7827-1-peter.enderborg@sony.com> <20180612080912.7827-2-peter.enderborg@sony.com> X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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. > 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) Acked-by: Jay Freyensee --- security/selinux/ss/conditional.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 #include #include @@ -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;