Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp265076imm; Tue, 12 Jun 2018 23:23:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLv+idAHlJBPSGpX4l4y1bc3oHzmnCG53BaCUx1mk2Qukr2Rc2aE/n2qMpKR6dOuAKb/S8V X-Received: by 2002:a65:6210:: with SMTP id d16-v6mr2901423pgv.272.1528871027567; Tue, 12 Jun 2018 23:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528871027; cv=none; d=google.com; s=arc-20160816; b=UzqGZWZmY+19QvPMOqDTwz5tcWvxIHFYQYyvFdhhKxLoS21sV/E7nz25N6tEAfrswe iLpRFsFiVWGrXtuqhCtlYOpX3NU+STmNtuW8SnwC0Ujyq7KET260gmRtH4KC5sYb65Pp 8AnOJb2H6wzAuytJAbP60vkU9Nxn8INpjgaVzn+QSxK+EUgrqtv3yYwJAP1yPzlo1y8O +2sBZQSa892lz5GOWs0Y8o20t6/ymp8vAQ9NRlisAHxRiRyScJRDyhYbEFdJR7YCYfyi iRKB08h4AS1BtDBgyT4yYOjLLwhHpl0UsaOgEOE4NuA1Mg4ykP0m8skW3hZc+KppitLJ dhqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=kIOwd87mksYNLeUM1MJitKJ9fGFzYwDt2R3nMV03c+I=; b=izSUYOr9wV4EhGpEM/dDc4LNlDrKlt5UwHKeua9FC2cOcA6rEmVP5JRO+sKdxR+VHB CYw1PyQkqfJzWsQt5aRinyXz7dBNw4zzobTrygZK8QCL4vwljdqEPVhzOK7QyPShute6 q1kTkiXvgK1m0qILADGf5Sm4Nn+74Mj5p1YUBUdfp5rD9nZ87ORlbu5ZXIhcx1W71QDO owSg6oGhnbbwrqfhkqun62/NWGBjPqroMb1hOoYE8aMoISdmYJMrEbC33iJYfiqHASrU 988hfQEvmg6EvVN6w+3XIbviXJ6LoMO4Cr7lhexXWvxx/g/tNmny2gn9uUqaVqCvCg2i 91CQ== 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 x70-v6si1963309pfj.347.2018.06.12.23.23.32; Tue, 12 Jun 2018 23:23:47 -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 S1754475AbeFMGXI (ORCPT + 99 others); Wed, 13 Jun 2018 02:23:08 -0400 Received: from seldsegrel01.sonyericsson.com ([37.139.156.29]:1436 "EHLO SELDSEGREL01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754377AbeFMGXH (ORCPT ); Wed, 13 Jun 2018 02:23:07 -0400 Subject: Re: [PATCH 01/13] selinux: Cleanup printk logging in conditional To: Joe Perches , Paul Moore , Stephen Smalley , Eric Paris , James Morris , Daniel Jurgens , Doug Ledford , , , , "Serge E . Hallyn" References: <20180612080912.7827-1-peter.enderborg@sony.com> <20180612080912.7827-2-peter.enderborg@sony.com> From: peter enderborg Message-ID: Date: Wed, 13 Jun 2018 08:23:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > #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; > >