Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5423088imm; Tue, 12 Jun 2018 07:39:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIdUf/9zcVpjs7Ij0RtfLygpod1gTeAmNugPV3s9SdKQ0Cxn/2wqP5k5NJviObzAwvF5rRG X-Received: by 2002:a17:902:8509:: with SMTP id bj9-v6mr732259plb.210.1528814357971; Tue, 12 Jun 2018 07:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528814357; cv=none; d=google.com; s=arc-20160816; b=aSOJbCl/+Q/fjcIa7Pe3a/iCzcnozZAAz6xh0tdwHGIXTPfxAvD4lWzfneqxqwvKDK unabhjHvj4i4jw8z3zrA1c+dIrCsoB7p+cJq4HXZyfuWePj+bsp4K9UJbg9f2sI/3Nu/ mZTNhr2r7Wm0HEPUJG7HBoDwXu7bXWl0llCPkow4UebRDi7IiLl3Hb3spQM9ja8XUwDm IjT2ifDJ0wEXtbCPjcywrR2cZIZUdDaHef6Alb9gbw4M8ZhbgHz8OU3q+uV5c0FiO7Ez zzXDGhADXhnRpb5qPpepnKfzp3Gjjxa5h66xNIrl7QrgXtarSyzS8OSCo3qJA+f/m3no +1HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:to:from:subject:message-id :arc-authentication-results; bh=qVk9jREDKm0N7VqLmr6Y4BVJ+1DjOrhkIjDnSXTifyM=; b=O5uPNvHY5+swj882BRlAOhsRsrEQxaVLIywjHKCD8dFw2c+lbHM7pRd80/lP0wsvBR 4+byDIWEfEl5TXIBDi0ozbUbzoDeNXUZEuKrI9xw1wumHeCUerEiwzVkcJF8KM1Iyn2y IoWDSpQAxHQytziCT8oogtN4r30CkVMx/ytJTm0lqseroMnBUSnoHW5L2ydaEkM/Z3be ftqo/MGqcHgFwEp4Ajv90zUD/idhyRh2+SCyJXpC8kFpyPvwlx6RCqTXTBJQQHvLXDYr lMSeoe8HUQsTiydkUszIHlbv/EXXTy6EZXZTgM4HDu40LncdXG4p8Ep27HuX0Qn3Idu7 8duw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o124-v6si243326pga.90.2018.06.12.07.39.03; Tue, 12 Jun 2018 07:39:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934137AbeFLOiH (ORCPT + 99 others); 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-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::,RULES_HIT:41:355:379:541:599:960:966:968:973:988:989:1042:1260:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1535:1544:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2691:2828:2894:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3872:4321:4385:5007:6119:6737:7875:10004:10848:11026:11232:11658:11914:12043:12048:12296:12438:12555:12740:12760:12895:13439:14659:14721:21080:21451:21611:21627:30054:30091,0,RBL:47.151.150.235:@perches.com:.lbl8.mailshell.net-62.14.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:29,LUA_SUMMARY:none 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> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) --- 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 #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;