Skip to contentSkip to conversation

security: Use a more current logging style

PATCH Superseded Joe Perches 8 participants 25 messages Feb 24, 2014 – Feb 26, 2014 1 message not in the archive

Subsystems (11)
lore
Share & tools
lore
#11 lore raw

PATCH 5/8 security: selinux: Use a more current logging style

In reply to Joe Perches

Convert printk to pr_<level>.
Add pr_fmt.
Coalesce formats, add missing space where appropriate. Standardize on one space after "SELinux: " prefix.

---
 security/selinux/avc.c            |   7 +-
 security/selinux/hooks.c          | 130 ++++++++++++++++----------------------
 security/selinux/netif.c          |  14 ++--
 security/selinux/netlink.c        |   5 +-
 security/selinux/netnode.c        |   6 +-
 security/selinux/netport.c        |   7 +-
 security/selinux/selinuxfs.c      |  19 +++---
 security/selinux/ss/avtab.c       |  39 ++++++------
 security/selinux/ss/conditional.c |  18 +++---
 security/selinux/ss/ebitmap.c     |  21 +++---
 security/selinux/ss/policydb.c    | 109 ++++++++++++++------------------
 security/selinux/ss/services.c    | 101 ++++++++++++-----------------
 security/selinux/ss/sidtab.c      |   8 ++-
 13 files changed, 220 insertions(+), 264 deletions(-)
security/selinux/avc.c +5 -2
index fc3e662..f9bb683 100644
@@ -13,6 +13,9 @@
  *	it under the terms of the GNU General Public License version 2,
  *	as published by the Free Software Foundation.
  */
+
+#define pr_fmt(fmt) "SELinux: " KBUILD_MODNAME ": " fmt
+
 #include <linux/types.h>
 #include <linux/stddef.h>
 #include <linux/kernel.h>
@@ -348,8 +351,8 @@ static int avc_latest_notif_update(int seqno, int is_insert)
 	spin_lock_irqsave(&notif_lock, flag);
 	if (is_insert) {
 		if (seqno < avc_cache.latest_notif) {
-			printk(KERN_WARNING "SELinux: avc:  seqno %d < latest_notif %d\n",
-			       seqno, avc_cache.latest_notif);
+			pr_warn("seqno %d < latest_notif %d\n",
+				seqno, avc_cache.latest_notif);
 			ret = -EAGAIN;
 		}
 	} else {
security/selinux/hooks.c +56 -74

335 lines not on this page · raw message

security/selinux/netif.c +7 -7
index 694e9e4..17001cc 100644
@@ -14,6 +14,9 @@
  * it under the terms of the GNU General Public License version 2,
  * as published by the Free Software Foundation.
  */
+
+#define pr_fmt(fmt) "SELinux: " fmt
+
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/slab.h>
@@ -142,9 +145,8 @@ static int sel_netif_sid_slow(int ifindex, u32 *sid)
 
 	dev = dev_get_by_index(&init_net, ifindex);
 	if (unlikely(dev == NULL)) {
-		printk(KERN_WARNING
-		       "SELinux: failure in sel_netif_sid_slow(),"
-		       " invalid network interface (%d)\n", ifindex);
+		pr_warn("failure in sel_netif_sid_slow(), invalid network interface (%d)\n",
+			ifindex);
 		return -ENOENT;
 	}
 
@@ -173,10 +175,8 @@ out:
 	spin_unlock_bh(&sel_netif_lock);
 	dev_put(dev);
 	if (unlikely(ret)) {
-		printk(KERN_WARNING
-		       "SELinux: failure in sel_netif_sid_slow(),"
-		       " unable to determine network interface label (%d)\n",
-		       ifindex);
+		pr_warn("failure in sel_netif_sid_slow(), unable to determine network interface label (%d)\n",
+			ifindex);
 		kfree(new);
 	}
 	return ret;
security/selinux/netlink.c +4 -1
index 828fb6a..50bc253 100644
@@ -9,6 +9,9 @@
  * it under the terms of the GNU General Public License version 2,
  * as published by the Free Software Foundation.
  */
+
+#define pr_fmt(fmt) "SELinux: " fmt
+
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/slab.h>
@@ -94,7 +97,7 @@ out:
 out_kfree_skb:
 	kfree_skb(skb);
 oom:
-	printk(KERN_ERR "SELinux:  OOM in %s\n", __func__);
+	pr_err("OOM in %s\n", __func__);
 	goto out;
 }
 
security/selinux/netnode.c +3 -3
index 03a72c3..9f8fd79 100644
@@ -28,6 +28,8 @@
  *
  */
 
+#define pr_fmt(fmt) "SELinux: " fmt
+
 #include <linux/types.h>
 #include <linux/rcupdate.h>
 #include <linux/list.h>
@@ -238,9 +240,7 @@ static int sel_netnode_sid_slow(void *addr, u16 family, u32 *sid)
 out:
 	spin_unlock_bh(&sel_netnode_lock);
 	if (unlikely(ret)) {
-		printk(KERN_WARNING
-		       "SELinux: failure in sel_netnode_sid_slow(),"
-		       " unable to determine network node label\n");
+		pr_warn("failure in sel_netnode_sid_slow(), unable to determine network node label\n");
 		kfree(new);
 	}
 	return ret;
security/selinux/netport.c +3 -4
index d353797..20a4ed0 100644
@@ -12,7 +12,6 @@
  *   (see security/selinux/netif.c for more information)
  *
  */
-
 /*
  * (c) Copyright Hewlett-Packard Development Company, L.P., 2008
  *
@@ -27,6 +26,8 @@
  *
  */
 
+#define pr_fmt(fmt) "SELinux: " fmt
+
 #include <linux/types.h>
 #include <linux/rcupdate.h>
 #include <linux/list.h>
@@ -173,9 +174,7 @@ static int sel_netport_sid_slow(u8 protocol, u16 pnum, u32 *sid)
 out:
 	spin_unlock_bh(&sel_netport_lock);
 	if (unlikely(ret)) {
-		printk(KERN_WARNING
-		       "SELinux: failure in sel_netport_sid_slow(),"
-		       " unable to determine network port label\n");
+		pr_warn("failure in sel_netport_sid_slow(), unable to determine network port label\n");
 		kfree(new);
 	}
 	return ret;
security/selinux/selinuxfs.c +10 -9
index 170b4b1..78ced2a 100644
@@ -14,6 +14,8 @@
  *	the Free Software Foundation, version 2.
  */
 
+#define pr_fmt(fmt) "SELinux: " fmt
+
 #include <linux/kernel.h>
 #include <linux/pagemap.h>
 #include <linux/slab.h>
@@ -586,8 +588,8 @@ static ssize_t sel_write_context(struct file *file, char *buf, size_t size)
 
 	length = -ERANGE;
 	if (len > SIMPLE_TRANSACTION_LIMIT) {
-		printk(KERN_ERR "SELinux: %s:  context size (%u) exceeds "
-			"payload max\n", __func__, len);
+		pr_err("%s: context size (%u) exceeds payload max\n",
+		       __func__, len);
 		goto out;
 	}
 
@@ -836,8 +838,8 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
 
 	length = -ERANGE;
 	if (len > SIMPLE_TRANSACTION_LIMIT) {
-		printk(KERN_ERR "SELinux: %s:  context size (%u) exceeds "
-			"payload max\n", __func__, len);
+		pr_err("%s: context size (%u) exceeds payload max\n",
+		       __func__, len);
 		goto out;
 	}
 
@@ -1012,8 +1014,8 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size)
 
 	length = -ERANGE;
 	if (len > SIMPLE_TRANSACTION_LIMIT) {
-		printk(KERN_ERR "SELinux: %s:  context size (%u) exceeds "
-			"payload max\n", __func__, len);
+		pr_err("%s: context size (%u) exceeds payload max\n",
+		       __func__, len);
 		goto out;
 	}
 
@@ -1873,8 +1875,7 @@ static int sel_fill_super(struct super_block *sb, void *data, int silent)
 	}
 	return 0;
 err:
-	printk(KERN_ERR "SELinux: %s:  failed while creating inodes\n",
-		__func__);
+	pr_err("%s: failed while creating inodes\n", __func__);
 	return ret;
 }
 
@@ -1912,7 +1913,7 @@ static int __init init_sel_fs(void)
 
 	selinux_null.mnt = selinuxfs_mount = kern_mount(&sel_fs_type);
 	if (IS_ERR(selinuxfs_mount)) {
-		printk(KERN_ERR "selinuxfs:  could not mount!\n");
+		pr_err("selinuxfs: could not mount!\n");
 		err = PTR_ERR(selinuxfs_mount);
 		selinuxfs_mount = NULL;
 	}
security/selinux/ss/avtab.c +21 -18
index a3dd9fa..b805fe2 100644
@@ -17,6 +17,8 @@
  *	Tuned number of hash slots for avtab to reduce memory usage
  */
 
+#define pr_fmt(fmt) "SELinux: avtab: " fmt
+
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
@@ -343,18 +345,18 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
 	if (vers < POLICYDB_VERSION_AVTAB) {
 		rc = next_entry(buf32, fp, sizeof(u32));
 		if (rc) {
-			printk(KERN_ERR "SELinux: avtab: truncated entry\n");
+			pr_err("truncated entry\n");
 			return rc;
 		}
 		items2 = le32_to_cpu(buf32[0]);
 		if (items2 > ARRAY_SIZE(buf32)) {
-			printk(KERN_ERR "SELinux: avtab: entry overflow\n");
+			pr_err("entry overflow\n");
 			return -EINVAL;
 
 		}
 		rc = next_entry(buf32, fp, sizeof(u32)*items2);
 		if (rc) {
-			printk(KERN_ERR "SELinux: avtab: truncated entry\n");
+			pr_err("truncated entry\n");
 			return rc;
 		}
 		items = 0;
@@ -362,19 +364,19 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
 		val = le32_to_cpu(buf32[items++]);
 		key.source_type = (u16)val;
 		if (key.source_type != val) {
-			printk(KERN_ERR "SELinux: avtab: truncated source type\n");
+			pr_err("truncated source type\n");
 			return -EINVAL;
 		}
 		val = le32_to_cpu(buf32[items++]);
 		key.target_type = (u16)val;
 		if (key.target_type != val) {
-			printk(KERN_ERR "SELinux: avtab: truncated target type\n");
+			pr_err("truncated target type\n");
 			return -EINVAL;
 		}
 		val = le32_to_cpu(buf32[items++]);
 		key.target_class = (u16)val;
 		if (key.target_class != val) {
-			printk(KERN_ERR "SELinux: avtab: truncated target class\n");
+			pr_err("truncated target class\n");
 			return -EINVAL;
 		}
 
@@ -382,12 +384,12 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
 		enabled = (val & AVTAB_ENABLED_OLD) ? AVTAB_ENABLED : 0;
 
 		if (!(val & (AVTAB_AV | AVTAB_TYPE))) {
-			printk(KERN_ERR "SELinux: avtab: null entry\n");
+			pr_err("null entry\n");
 			return -EINVAL;
 		}
 		if ((val & AVTAB_AV) &&
 		    (val & AVTAB_TYPE)) {
-			printk(KERN_ERR "SELinux: avtab: entry has both access vectors and types\n");
+			pr_err("entry has both access vectors and types\n");
 			return -EINVAL;
 		}
 
@@ -402,7 +404,8 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
 		}
 
 		if (items != items2) {
-			printk(KERN_ERR "SELinux: avtab: entry only had %d items, expected %d\n", items2, items);
+			pr_err("entry only had %d items, expected %d\n",
+			       items2, items);
 			return -EINVAL;
 		}
 		return 0;
@@ -410,7 +413,7 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
 
 	rc = next_entry(buf16, fp, sizeof(u16)*4);
 	if (rc) {
-		printk(KERN_ERR "SELinux: avtab: truncated entry\n");
+		pr_err("truncated entry\n");
 		return rc;
 	}
 
@@ -423,7 +426,7 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
 	if (!policydb_type_isvalid(pol, key.source_type) ||
 	    !policydb_type_isvalid(pol, key.target_type) ||
 	    !policydb_class_isvalid(pol, key.target_class)) {
-		printk(KERN_ERR "SELinux: avtab: invalid type or class\n");
+		pr_err("invalid type or class\n");
 		return -EINVAL;
 	}
 
@@ -433,19 +436,19 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
 			set++;
 	}
 	if (!set || set > 1) {
-		printk(KERN_ERR "SELinux:  avtab:  more than one specifier\n");
+		pr_err("more than one specifier\n");
 		return -EINVAL;
 	}
 
 	rc = next_entry(buf32, fp, sizeof(u32));
 	if (rc) {
-		printk(KERN_ERR "SELinux: avtab: truncated entry\n");
+		pr_err("truncated entry\n");
 		return rc;
 	}
 	datum.data = le32_to_cpu(*buf32);
 	if ((key.specified & AVTAB_TYPE) &&
 	    !policydb_type_isvalid(pol, datum.data)) {
-		printk(KERN_ERR "SELinux: avtab: invalid type\n");
+		pr_err("invalid type\n");
 		return -EINVAL;
 	}
 	return insertf(a, &key, &datum, p);
@@ -466,12 +469,12 @@ int avtab_read(struct avtab *a, void *fp, struct policydb *pol)
 
 	rc = next_entry(buf, fp, sizeof(u32));
 	if (rc < 0) {
-		printk(KERN_ERR "SELinux: avtab: truncated table\n");
+		pr_err("truncated table\n");
 		goto bad;
 	}
 	nel = le32_to_cpu(buf[0]);
 	if (!nel) {
-		printk(KERN_ERR "SELinux: avtab: table is empty\n");
+		pr_err("table is empty\n");
 		rc = -EINVAL;
 		goto bad;
 	}
@@ -484,9 +487,9 @@ int avtab_read(struct avtab *a, void *fp, struct policydb *pol)
 		rc = avtab_read_item(a, fp, pol, avtab_insertf, NULL);
 		if (rc) {
 			if (rc == -ENOMEM)
-				printk(KERN_ERR "SELinux: avtab: out of memory\n");
+				pr_err("out of memory\n");
 			else if (rc == -EEXIST)
-				printk(KERN_ERR "SELinux: avtab: duplicate entry\n");
+				pr_err("duplicate entry\n");
 
 			goto bad;
 		}
security/selinux/ss/conditional.c +10 -8
index 377d148..9bb2dde 100644
@@ -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>
@@ -95,7 +97,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)
@@ -283,7 +285,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;
 		}
 		/*
@@ -298,7 +300,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;
@@ -309,13 +311,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;
 			}
 		}
@@ -323,7 +325,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;
 	}
@@ -384,12 +386,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;
security/selinux/ss/ebitmap.c +9 -12
index 820313a..0ea9bbc 100644
@@ -15,6 +15,8 @@
  *      Applied standard bit operations to improve bitmap scanning.
  */
 
+#define pr_fmt(fmt) "SELinux: ebitmap: " fmt
+
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
@@ -382,8 +384,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 	count = le32_to_cpu(buf[2]);
 
 	if (mapunit != BITS_PER_U64) {
-		printk(KERN_ERR "SELinux: ebitmap: map size %u does not "
-		       "match my size %Zd (high bit was %d)\n",
+		pr_err("map size %u does not match my size %Zd (high bit was %d)\n",
 		       mapunit, BITS_PER_U64, e->highbit);
 		goto bad;
 	}
@@ -400,20 +401,18 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 	for (i = 0; i < count; i++) {
 		rc = next_entry(&startbit, fp, sizeof(u32));
 		if (rc < 0) {
-			printk(KERN_ERR "SELinux: ebitmap: truncated map\n");
+			pr_err("truncated map\n");
 			goto bad;
 		}
 		startbit = le32_to_cpu(startbit);
 
 		if (startbit & (mapunit - 1)) {
-			printk(KERN_ERR "SELinux: ebitmap start bit (%d) is "
-			       "not a multiple of the map unit size (%u)\n",
+			pr_err("start bit (%d) is not a multiple of the map unit size (%u)\n",
 			       startbit, mapunit);
 			goto bad;
 		}
 		if (startbit > e->highbit - mapunit) {
-			printk(KERN_ERR "SELinux: ebitmap start bit (%d) is "
-			       "beyond the end of the bitmap (%u)\n",
+			pr_err("start bit (%d) is beyond the end of the bitmap (%u)\n",
 			       startbit, (e->highbit - mapunit));
 			goto bad;
 		}
@@ -422,8 +421,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 			struct ebitmap_node *tmp;
 			tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
 			if (!tmp) {
-				printk(KERN_ERR
-				       "SELinux: ebitmap: out of memory\n");
+				pr_err("out of memory\n");
 				rc = -ENOMEM;
 				goto bad;
 			}
@@ -435,15 +433,14 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 				e->node = tmp;
 			n = tmp;
 		} else if (startbit <= n->startbit) {
-			printk(KERN_ERR "SELinux: ebitmap: start bit %d"
-			       " comes after start bit %d\n",
+			pr_err("start bit %d comes after start bit %d\n",
 			       startbit, n->startbit);
 			goto bad;
 		}
 
 		rc = next_entry(&map, fp, sizeof(u64));
 		if (rc < 0) {
-			printk(KERN_ERR "SELinux: ebitmap: truncated map\n");
+			pr_err("truncated map\n");
 			goto bad;
 		}
 		map = le64_to_cpu(map);
security/selinux/ss/policydb.c +48 -61

332 lines not on this page · raw message

security/selinux/ss/services.c +39 -62

295 lines not on this page · raw message

security/selinux/ss/sidtab.c +5 -3
index 5840a35..aef422a 100644
@@ -3,6 +3,9 @@
  *
  * Author : Stephen Smalley, <[email protected]>
  */
+
+#define pr_fmt(fmt) "SELinux: " fmt
+
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
@@ -220,9 +223,8 @@ int sidtab_context_to_sid(struct sidtab *s,
 		}
 		sid = s->next_sid++;
 		if (context->len)
-			printk(KERN_INFO
-		       "SELinux:  Context %s is not valid (left unmapped).\n",
-			       context->str);
+			pr_info("Context %s is not valid (left unmapped)\n",
+				context->str);
 		ret = sidtab_insert(s, sid, context);
 		if (ret)
 			s->next_sid--;
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#0 lore raw

cover security: Use a more current logging style

Mostly trivial cleanups of security modules

Joe Perches (8):
security: Use a more current logging style
security: apparmor: Use a more current logging style
security: integrity: Use a more current logging style
security: keys: Use a more current logging style
security: selinux: Use a more current logging style
security: smack: Use a more current logging style
security: tomoyo: Use a more current logging style
security: yama: Use a more current logging style

 security/apparmor/apparmorfs.c           |   2 +
 security/apparmor/crypto.c               |   2 +
 security/apparmor/include/apparmor.h     |   2 +-
 security/apparmor/lib.c                  |   4 +-
 security/apparmor/lsm.c                  |   2 +
 security/apparmor/match.c                |   5 +-
 security/apparmor/policy.c               |   2 +
 security/apparmor/procattr.c             |   2 +
 security/capability.c                    |  16 ++--
 security/commoncap.c                     |  15 ++--
 security/integrity/evm/evm_crypto.c      |   4 +-
 security/integrity/evm/evm_main.c        |   6 +-
 security/integrity/evm/evm_secfs.c       |   6 +-
 security/integrity/ima/ima_crypto.c      |   4 +-
 security/integrity/ima/ima_init.c        |   5 +-
 security/integrity/ima/ima_queue.c       |   8 +-
 security/integrity/ima/ima_template.c    |   5 +-
 security/keys/encrypted-keys/encrypted.c |  70 ++++++++---------
 security/keys/encrypted-keys/encrypted.h |   2 +-
 security/keys/key.c                      |   2 +
 security/keys/trusted.c                  |  42 +++++-----
 security/keys/trusted.h                  |  20 ++---
 security/security.c                      |   4 +-
 security/selinux/avc.c                   |   7 +-
 security/selinux/hooks.c                 | 130 +++++++++++++------------------
 security/selinux/netif.c                 |  14 ++--
 security/selinux/netlink.c               |   5 +-
 security/selinux/netnode.c               |   6 +-
 security/selinux/netport.c               |   7 +-
 security/selinux/selinuxfs.c             |  19 ++---
 security/selinux/ss/avtab.c              |  39 +++++-----
 security/selinux/ss/conditional.c        |  18 +++--
 security/selinux/ss/ebitmap.c            |  21 +++--
 security/selinux/ss/policydb.c           | 109 ++++++++++++--------------
 security/selinux/ss/services.c           | 101 ++++++++++--------------
 security/selinux/ss/sidtab.c             |   8 +-
 security/smack/smack_lsm.c               |   7 +-
 security/smack/smackfs.c                 |  25 +++---
 security/tomoyo/common.c                 |  23 +++---
 security/tomoyo/domain.c                 |   8 +-
 security/tomoyo/load_policy.c            |   9 ++-
 security/tomoyo/memory.c                 |   7 +-
 security/tomoyo/tomoyo.c                 |   4 +-
 security/tomoyo/util.c                   |   7 +-
 security/yama/yama_lsm.c                 |  18 ++---
 45 files changed, 404 insertions(+), 418 deletions(-)
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#1 lore raw

PATCH 1/8 security: Use a more current logging style

Convert printks to pr_<level>.
Add pr_fmt to prefix output with "security: " or "capability: " Coalesce formats.
Use a generic string for pr_debug to reduce object size.

---
 security/capability.c | 16 +++++++++-------
 security/commoncap.c  | 15 ++++++++-------
 security/security.c   |  4 +++-
 3 files changed, 20 insertions(+), 15 deletions(-)
security/capability.c +9 -7
index 8b4f24a..086af9b 100644
@@ -10,6 +10,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/security.h>
 
 static int cap_syslog(int type)
@@ -914,13 +916,13 @@ static void cap_audit_rule_free(void *lsmrule)
 #endif /* CONFIG_AUDIT */
 
 #define set_to_cap_if_null(ops, function)				\
-	do {								\
-		if (!ops->function) {					\
-			ops->function = cap_##function;			\
-			pr_debug("Had to override the " #function	\
-				 " security operation with the default.\n");\
-			}						\
-	} while (0)
+do {									\
+	if (!ops->function) {						\
+		ops->function = cap_##function;				\
+		pr_debug("Had to override the %s security operation with the default\n", \
+			 #function);					\
+	}								\
+} while (0)
 
 void __init security_fixup_ops(struct security_operations *ops)
 {
security/commoncap.c +8 -7
index b9d613e..b5c3bc4 100644
@@ -7,6 +7,8 @@
  *
  */
 
+#define pr_fmt(fmt) "capability: " fmt
+
 #include <linux/capability.h>
 #include <linux/audit.h>
 #include <linux/module.h>
@@ -46,9 +48,8 @@ static void warn_setuid_and_fcaps_mixed(const char *fname)
 {
 	static int warned;
 	if (!warned) {
-		printk(KERN_INFO "warning: `%s' has both setuid-root and"
-			" effective capabilities. Therefore not raising all"
-			" capabilities.\n", fname);
+		pr_info("warning: `%s' has both setuid-root and effective capabilities, therefore not raising all capabilities\n",
+			fname);
 		warned = 1;
 	}
 }
@@ -448,8 +449,8 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_c
 	rc = get_vfs_caps_from_disk(dentry, &vcaps);
 	if (rc < 0) {
 		if (rc == -EINVAL)
-			printk(KERN_NOTICE "%s: get_vfs_caps_from_disk returned %d for %s\n",
-				__func__, rc, bprm->filename);
+			pr_notice("%s: get_vfs_caps_from_disk returned %d for %s\n",
+				  __func__, rc, bprm->filename);
 		else if (rc == -ENODATA)
 			rc = 0;
 		goto out;
@@ -457,8 +458,8 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_c
 
 	rc = bprm_caps_from_vfs_caps(&vcaps, bprm, effective, has_cap);
 	if (rc == -EINVAL)
-		printk(KERN_NOTICE "%s: cap_from_disk returned %d for %s\n",
-		       __func__, rc, bprm->filename);
+		pr_notice("%s: cap_from_disk returned %d for %s\n",
+			  __func__, rc, bprm->filename);
 
 out:
 	dput(dentry);
security/security.c +3 -1
index 15b6928..53d1885 100644
@@ -11,6 +11,8 @@
  *	(at your option) any later version.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/capability.h>
 #include <linux/dcache.h>
 #include <linux/module.h>
@@ -64,7 +66,7 @@ static void __init do_security_initcalls(void)
  */
 int __init security_init(void)
 {
-	printk(KERN_INFO "Security Framework initialized\n");
+	pr_info("Security Framework initialized\n");
 
 	security_fixup_ops(&default_security_ops);
 	security_ops = &default_security_ops;
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#5 lore raw

PATCH 2/8 security: apparmor: Use a more current logging style

In reply to Joe Perches

Convert printks to pr_<level>.
Add pr_fmt.
Coalesce formats.
Remove embedded prefixes from logging.

---
 security/apparmor/apparmorfs.c       | 2 ++
 security/apparmor/crypto.c           | 2 ++
 security/apparmor/include/apparmor.h | 2 +-
 security/apparmor/lib.c              | 4 +++-
 security/apparmor/lsm.c              | 2 ++
 security/apparmor/match.c            | 5 +++--
 security/apparmor/policy.c           | 2 ++
 security/apparmor/procattr.c         | 2 ++
 8 files changed, 17 insertions(+), 4 deletions(-)
security/apparmor/apparmorfs.c +2 -0
index 7db9954..d4b65cc 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/ctype.h>
 #include <linux/security.h>
 #include <linux/vmalloc.h>
security/apparmor/crypto.c +2 -0
index 532471d..9506544 100644
@@ -15,6 +15,8 @@
  * it should be.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <crypto/hash.h>
 
 #include "include/apparmor.h"
security/apparmor/include/apparmor.h +1 -1
index 8fb1488..3065025 100644
@@ -56,7 +56,7 @@ extern unsigned int aa_g_path_max;
 #define AA_ERROR(fmt, args...)						\
 	do {								\
 		if (printk_ratelimit())					\
-			printk(KERN_ERR "AppArmor: " fmt, ##args);	\
+			pr_err(fmt, ##args);				\
 	} while (0)
 
 /* Flag indicating whether initialization completed */
security/apparmor/lib.c +3 -1
index 6968992..432b1b6 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -73,7 +75,7 @@ void aa_info_message(const char *str)
 		aad.info = str;
 		aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL);
 	}
-	printk(KERN_INFO "AppArmor: %s\n", str);
+	pr_info("%s\n", str);
 }
 
 /**
security/apparmor/lsm.c +2 -0
index 9981000..49f0180 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/security.h>
 #include <linux/moduleparam.h>
 #include <linux/mm.h>
security/apparmor/match.c +3 -2
index 727eb42..688482a 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -140,8 +142,7 @@ static int verify_dfa(struct aa_dfa *dfa, int flags)
 			if (DEFAULT_TABLE(dfa)[i] >= state_count)
 				goto out;
 			if (base_idx(BASE_TABLE(dfa)[i]) + 255 >= trans_count) {
-				printk(KERN_ERR "AppArmor DFA next/check upper "
-				       "bounds error\n");
+				pr_err("DFA next/check upper bounds error\n");
 				goto out;
 			}
 		}
security/apparmor/policy.c +2 -0
index 705c287..4e20c1f 100644
@@ -73,6 +73,8 @@
  * FIXME: move profile lists to using rcu_lists
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
security/apparmor/procattr.c +2 -0
index b125acc..c105fc5 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include "include/apparmor.h"
 #include "include/context.h"
 #include "include/policy.h"
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#8 lore raw

PATCH 3/8 security: integrity: Use a more current logging style

In reply to Joe Perches

Convert printks to pr_<level>.
Add pr_fmt.
Remove embedded prefixes.

---
 security/integrity/evm/evm_crypto.c   | 4 +++-
 security/integrity/evm/evm_main.c     | 6 ++++--
 security/integrity/evm/evm_secfs.c    | 6 ++++--
 security/integrity/ima/ima_crypto.c   | 4 +++-
 security/integrity/ima/ima_init.c     | 5 ++++-
 security/integrity/ima/ima_queue.c    | 8 +++++---
 security/integrity/ima/ima_template.c | 5 ++++-
 7 files changed, 27 insertions(+), 11 deletions(-)
security/integrity/evm/evm_crypto.c +3 -1
index 3bab89e..9bd329f 100644
@@ -13,6 +13,8 @@
  *	 Using root's kernel master key (kmk), calculate the HMAC
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/crypto.h>
 #include <linux/xattr.h>
@@ -221,7 +223,7 @@ int evm_init_hmac(struct inode *inode, const struct xattr *lsm_xattr,
 
 	desc = init_desc(EVM_XATTR_HMAC);
 	if (IS_ERR(desc)) {
-		printk(KERN_INFO "init_desc failed\n");
+		pr_info("init_desc failed\n");
 		return PTR_ERR(desc);
 	}
 
security/integrity/evm/evm_main.c +4 -2
index 336b3dd..996092f 100644
@@ -14,6 +14,8 @@
  *	evm_inode_removexattr, and evm_verifyxattr
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/crypto.h>
 #include <linux/audit.h>
@@ -432,7 +434,7 @@ static int __init init_evm(void)
 
 	error = evm_init_secfs();
 	if (error < 0) {
-		printk(KERN_INFO "EVM: Error registering secfs\n");
+		pr_info("Error registering secfs\n");
 		goto err;
 	}
 
@@ -449,7 +451,7 @@ static int __init evm_display_config(void)
 	char **xattrname;
 
 	for (xattrname = evm_config_xattrnames; *xattrname != NULL; xattrname++)
-		printk(KERN_INFO "EVM: %s\n", *xattrname);
+		pr_info("%s\n", *xattrname);
 	return 0;
 }
 
security/integrity/evm/evm_secfs.c +4 -2
index 30f670a..cf12a04 100644
@@ -13,6 +13,8 @@
  *	- Get the key and enable EVM
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/uaccess.h>
 #include <linux/module.h>
 #include "evm.h"
@@ -79,9 +81,9 @@ static ssize_t evm_write_key(struct file *file, const char __user *buf,
 	error = evm_init_key();
 	if (!error) {
 		evm_initialized = 1;
-		pr_info("EVM: initialized\n");
+		pr_info("initialized\n");
 	} else
-		pr_err("EVM: initialization failed\n");
+		pr_err("initialization failed\n");
 	return count;
 }
 
security/integrity/ima/ima_crypto.c +3 -1
index fdf60de..972df659 100644
@@ -13,6 +13,8 @@
  * 	Calculates md5/sha1 file hash, template hash, boot-aggreate hash
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/file.h>
 #include <linux/crypto.h>
@@ -205,7 +207,7 @@ static void __init ima_pcrread(int idx, u8 *pcr)
 		return;
 
 	if (tpm_pcr_read(TPM_ANY_NUM, idx, pcr) != 0)
-		pr_err("IMA: Error Communicating to TPM chip\n");
+		pr_err("Error Communicating to TPM chip\n");
 }
 
 /*
security/integrity/ima/ima_init.c +4 -1
index 3712276..b3bc313 100644
@@ -14,6 +14,9 @@
  * File: ima_init.c
  *             initialization and cleanup functions
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/scatterlist.h>
 #include <linux/slab.h>
@@ -93,7 +96,7 @@ int __init ima_init(void)
 		ima_used_chip = 1;
 
 	if (!ima_used_chip)
-		pr_info("IMA: No TPM chip found, activating TPM-bypass!\n");
+		pr_info("No TPM chip found, activating TPM-bypass!\n");
 
 	rc = ima_init_crypto();
 	if (rc)
security/integrity/ima/ima_queue.c +5 -3
index d85e997..91128b4 100644
@@ -18,6 +18,9 @@
  *       The measurement list is append-only. No entry is
  *       ever removed or changed during the boot-cycle.
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/rculist.h>
 #include <linux/slab.h>
@@ -72,7 +75,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
 
 	qe = kmalloc(sizeof(*qe), GFP_KERNEL);
 	if (qe == NULL) {
-		pr_err("IMA: OUT OF MEMORY ERROR creating queue entry.\n");
+		pr_err("OUT OF MEMORY ERROR creating queue entry\n");
 		return -ENOMEM;
 	}
 	qe->entry = entry;
@@ -95,8 +98,7 @@ static int ima_pcr_extend(const u8 *hash)
 
 	result = tpm_pcr_extend(TPM_ANY_NUM, CONFIG_IMA_MEASURE_PCR_IDX, hash);
 	if (result != 0)
-		pr_err("IMA: Error Communicating to TPM chip, result: %d\n",
-		       result);
+		pr_err("Error Communicating to TPM chip, result: %d\n", result);
 	return result;
 }
 
security/integrity/ima/ima_template.c +4 -1
index 635695f..9a4a0d1 100644
@@ -12,6 +12,9 @@
  * File: ima_template.c
  *      Helpers to manage template descriptors.
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <crypto/hash_info.h>
 
 #include "ima.h"
@@ -58,7 +61,7 @@ static int __init ima_template_setup(char *str)
 	 */
 	if (template_len == 3 && strcmp(str, IMA_TEMPLATE_IMA_NAME) == 0 &&
 	    ima_hash_algo != HASH_ALGO_SHA1 && ima_hash_algo != HASH_ALGO_MD5) {
-		pr_err("IMA: template does not support hash alg\n");
+		pr_err("template does not support hash alg\n");
 		return 1;
 	}
 
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#10 lore raw

PATCH 4/8 security: keys: Use a more current logging style

In reply to Joe Perches

Add pr_fmt and remove embedded prefixes.
Add missing newline '\n' terminations.
Coalesce formats.

---
 security/keys/encrypted-keys/encrypted.c | 70 +++++++++++++++-----------------
 security/keys/encrypted-keys/encrypted.h |  2 +-
 security/keys/key.c                      |  2 +
 security/keys/trusted.c                  | 42 +++++++++----------
 security/keys/trusted.h                  | 20 ++++-----
 5 files changed, 66 insertions(+), 70 deletions(-)
security/keys/encrypted-keys/encrypted.c +32 -38
index 5fe443d..82d2dd7 100644
@@ -14,6 +14,8 @@
  * See Documentation/security/keys-trusted-encrypted.txt
  */
 
+#define pr_fmt(fmt) "encrypted_key: " fmt
+
 #include <linux/uaccess.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -89,8 +91,7 @@ static int aes_get_sizes(void)
 
 	tfm = crypto_alloc_blkcipher(blkcipher_alg, 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(tfm)) {
-		pr_err("encrypted_key: failed to alloc_cipher (%ld)\n",
-		       PTR_ERR(tfm));
+		pr_err("failed to alloc_cipher (%ld)\n", PTR_ERR(tfm));
 		return PTR_ERR(tfm);
 	}
 	ivsize = crypto_blkcipher_ivsize(tfm);
@@ -111,15 +112,14 @@ static int valid_ecryptfs_desc(const char *ecryptfs_desc)
 	int i;
 
 	if (strlen(ecryptfs_desc) != KEY_ECRYPTFS_DESC_LEN) {
-		pr_err("encrypted_key: key description must be %d hexadecimal "
-		       "characters long\n", KEY_ECRYPTFS_DESC_LEN);
+		pr_err("key description must be %d hexadecimal characters long\n",
+		       KEY_ECRYPTFS_DESC_LEN);
 		return -EINVAL;
 	}
 
 	for (i = 0; i < KEY_ECRYPTFS_DESC_LEN; i++) {
 		if (!isxdigit(ecryptfs_desc[i])) {
-			pr_err("encrypted_key: key description must contain "
-			       "only hexadecimal characters\n");
+			pr_err("key description must contain only hexadecimal characters\n");
 			return -EINVAL;
 		}
 	}
@@ -186,7 +186,7 @@ static int datablob_parse(char *datablob, const char **format,
 
 	keyword = strsep(&datablob, " \t");
 	if (!keyword) {
-		pr_info("encrypted_key: insufficient parameters specified\n");
+		pr_info("insufficient parameters specified\n");
 		return ret;
 	}
 	key_cmd = match_token(keyword, key_tokens, args);
@@ -194,7 +194,7 @@ static int datablob_parse(char *datablob, const char **format,
 	/* Get optional format: default | ecryptfs */
 	p = strsep(&datablob, " \t");
 	if (!p) {
-		pr_err("encrypted_key: insufficient parameters specified\n");
+		pr_err("insufficient parameters specified\n");
 		return ret;
 	}
 
@@ -211,20 +211,20 @@ static int datablob_parse(char *datablob, const char **format,
 	}
 
 	if (!*master_desc) {
-		pr_info("encrypted_key: master key parameter is missing\n");
+		pr_info("master key parameter is missing\n");
 		goto out;
 	}
 
 	if (valid_master_desc(*master_desc, NULL) < 0) {
-		pr_info("encrypted_key: master key parameter \'%s\' "
-			"is invalid\n", *master_desc);
+		pr_info("master key parameter \'%s\' is invalid\n",
+			*master_desc);
 		goto out;
 	}
 
 	if (decrypted_datalen) {
 		*decrypted_datalen = strsep(&datablob, " \t");
 		if (!*decrypted_datalen) {
-			pr_info("encrypted_key: keylen parameter is missing\n");
+			pr_info("keylen parameter is missing\n");
 			goto out;
 		}
 	}
@@ -232,37 +232,35 @@ static int datablob_parse(char *datablob, const char **format,
 	switch (key_cmd) {
 	case Opt_new:
 		if (!decrypted_datalen) {
-			pr_info("encrypted_key: keyword \'%s\' not allowed "
-				"when called from .update method\n", keyword);
+			pr_info("keyword \'%s\' not allowed when called from .update method\n",
+				keyword);
 			break;
 		}
 		ret = 0;
 		break;
 	case Opt_load:
 		if (!decrypted_datalen) {
-			pr_info("encrypted_key: keyword \'%s\' not allowed "
-				"when called from .update method\n", keyword);
+			pr_info("keyword \'%s\' not allowed when called from .update method\n",
+				keyword);
 			break;
 		}
 		*hex_encoded_iv = strsep(&datablob, " \t");
 		if (!*hex_encoded_iv) {
-			pr_info("encrypted_key: hex blob is missing\n");
+			pr_info("hex blob is missing\n");
 			break;
 		}
 		ret = 0;
 		break;
 	case Opt_update:
 		if (decrypted_datalen) {
-			pr_info("encrypted_key: keyword \'%s\' not allowed "
-				"when called from .instantiate method\n",
+			pr_info("keyword \'%s\' not allowed when called from .instantiate method\n",
 				keyword);
 			break;
 		}
 		ret = 0;
 		break;
 	case Opt_err:
-		pr_info("encrypted_key: keyword \'%s\' not recognized\n",
-			keyword);
+		pr_info("keyword \'%s\' not recognized\n", keyword);
 		break;
 	}
 out:
@@ -343,7 +341,7 @@ static int calc_hmac(u8 *digest, const u8 *key, unsigned int keylen,
 
 	sdesc = alloc_sdesc(hmacalg);
 	if (IS_ERR(sdesc)) {
-		pr_info("encrypted_key: can't alloc %s\n", hmac_alg);
+		pr_info("can't alloc %s\n", hmac_alg);
 		return PTR_ERR(sdesc);
 	}
 
@@ -361,7 +359,7 @@ static int calc_hash(u8 *digest, const u8 *buf, unsigned int buflen)
 
 	sdesc = alloc_sdesc(hashalg);
 	if (IS_ERR(sdesc)) {
-		pr_info("encrypted_key: can't alloc %s\n", hash_alg);
+		pr_info("can't alloc %s\n", hash_alg);
 		return PTR_ERR(sdesc);
 	}
 
@@ -386,7 +384,7 @@ static int get_derived_key(u8 *derived_key, enum derived_key_type key_type,
 
 	derived_buf = kzalloc(derived_buf_len, GFP_KERNEL);
 	if (!derived_buf) {
-		pr_err("encrypted_key: out of memory\n");
+		pr_err("out of memory\n");
 		return -ENOMEM;
 	}
 	if (key_type)
@@ -409,7 +407,7 @@ static int init_blkcipher_desc(struct blkcipher_desc *desc, const u8 *key,
 
 	desc->tfm = crypto_alloc_blkcipher(blkcipher_alg, 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(desc->tfm)) {
-		pr_err("encrypted_key: failed to load %s transform (%ld)\n",
+		pr_err("failed to load %s transform (%ld)\n",
 		       blkcipher_alg, PTR_ERR(desc->tfm));
 		return PTR_ERR(desc->tfm);
 	}
@@ -417,7 +415,7 @@ static int init_blkcipher_desc(struct blkcipher_desc *desc, const u8 *key,
 
 	ret = crypto_blkcipher_setkey(desc->tfm, key, key_len);
 	if (ret < 0) {
-		pr_err("encrypted_key: failed to setkey (%d)\n", ret);
+		pr_err("failed to setkey (%d)\n", ret);
 		crypto_free_blkcipher(desc->tfm);
 		return ret;
 	}
@@ -447,11 +445,10 @@ static struct key *request_master_key(struct encrypted_key_payload *epayload,
 		int ret = PTR_ERR(mkey);
 
 		if (ret == -ENOTSUPP)
-			pr_info("encrypted_key: key %s not supported",
+			pr_info("key %s not supported\n",
 				epayload->master_desc);
 		else
-			pr_info("encrypted_key: key %s not found",
-				epayload->master_desc);
+			pr_info("key %s not found\n", epayload->master_desc);
 		goto out;
 	}
 
@@ -494,7 +491,7 @@ static int derived_key_encrypt(struct encrypted_key_payload *epayload,
 	ret = crypto_blkcipher_encrypt(&desc, sg_out, sg_in, encrypted_datalen);
 	crypto_free_blkcipher(desc.tfm);
 	if (ret < 0)
-		pr_err("encrypted_key: failed to encrypt (%d)\n", ret);
+		pr_err("failed to encrypt (%d)\n", ret);
 	else
 		dump_encrypted_data(epayload, encrypted_datalen);
 out:
@@ -618,8 +615,7 @@ static struct encrypted_key_payload *encrypted_key_alloc(struct key *key,
 	payload_datalen = decrypted_datalen;
 	if (format && !strcmp(format, key_format_ecryptfs)) {
 		if (dlen != ECRYPTFS_MAX_KEY_BYTES) {
-			pr_err("encrypted_key: keylen for the ecryptfs format "
-			       "must be equal to %d bytes\n",
+			pr_err("keylen for the ecryptfs format must be equal to %d bytes\n",
 			       ECRYPTFS_MAX_KEY_BYTES);
 			return ERR_PTR(-EINVAL);
 		}
@@ -687,7 +683,7 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload,
 
 	ret = datablob_hmac_verify(epayload, format, master_key, master_keylen);
 	if (ret < 0) {
-		pr_err("encrypted_key: bad hmac (%d)\n", ret);
+		pr_err("bad hmac (%d)\n", ret);
 		goto out;
 	}
 
@@ -697,7 +693,7 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload,
 
 	ret = derived_key_decrypt(epayload, derived_key, sizeof derived_key);
 	if (ret < 0)
-		pr_err("encrypted_key: failed to decrypt key (%d)\n", ret);
+		pr_err("failed to decrypt key (%d)\n", ret);
 out:
 	up_read(&mkey->sem);
 	key_put(mkey);
@@ -991,15 +987,13 @@ static int __init encrypted_shash_alloc(void)
 
 	hmacalg = crypto_alloc_shash(hmac_alg, 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(hmacalg)) {
-		pr_info("encrypted_key: could not allocate crypto %s\n",
-			hmac_alg);
+		pr_info("could not allocate crypto %s\n", hmac_alg);
 		return PTR_ERR(hmacalg);
 	}
 
 	hashalg = crypto_alloc_shash(hash_alg, 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(hashalg)) {
-		pr_info("encrypted_key: could not allocate crypto %s\n",
-			hash_alg);
+		pr_info("could not allocate crypto %s\n", hash_alg);
 		ret = PTR_ERR(hashalg);
 		goto hashalg_fail;
 	}
security/keys/encrypted-keys/encrypted.h +1 -1
index 8136a2d..1244aaa 100644
@@ -40,7 +40,7 @@ static inline void dump_hmac(const char *str, const u8 *digest,
 			     unsigned int hmac_size)
 {
 	if (str)
-		pr_info("encrypted_key: %s", str);
+		pr_info("%s", str);
 	print_hex_dump(KERN_ERR, "hmac: ", DUMP_PREFIX_NONE, 32, 1, digest,
 		       hmac_size, 0);
 }
security/keys/key.c +2 -0
index 6e21c11..16e26c7 100644
@@ -9,6 +9,8 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/poison.h>
security/keys/trusted.c +21 -21

156 lines not on this page · raw message

security/keys/trusted.h +10 -10
index 3249fbd..babe4fb 100644
@@ -51,33 +51,33 @@ struct trusted_key_options {
 #if TPM_DEBUG
 static inline void dump_options(struct trusted_key_options *o)
 {
-	pr_info("trusted_key: sealing key type %d\n", o->keytype);
-	pr_info("trusted_key: sealing key handle %0X\n", o->keyhandle);
-	pr_info("trusted_key: pcrlock %d\n", o->pcrlock);
-	pr_info("trusted_key: pcrinfo %d\n", o->pcrinfo_len);
+	pr_info("sealing key type %d\n", o->keytype);
+	pr_info("sealing key handle %0X\n", o->keyhandle);
+	pr_info("pcrlock %d\n", o->pcrlock);
+	pr_info("pcrinfo %d\n", o->pcrinfo_len);
 	print_hex_dump(KERN_INFO, "pcrinfo ", DUMP_PREFIX_NONE,
 		       16, 1, o->pcrinfo, o->pcrinfo_len, 0);
 }
 
 static inline void dump_payload(struct trusted_key_payload *p)
 {
-	pr_info("trusted_key: key_len %d\n", p->key_len);
+	pr_info("key_len %d\n", p->key_len);
 	print_hex_dump(KERN_INFO, "key ", DUMP_PREFIX_NONE,
 		       16, 1, p->key, p->key_len, 0);
-	pr_info("trusted_key: bloblen %d\n", p->blob_len);
+	pr_info("bloblen %d\n", p->blob_len);
 	print_hex_dump(KERN_INFO, "blob ", DUMP_PREFIX_NONE,
 		       16, 1, p->blob, p->blob_len, 0);
-	pr_info("trusted_key: migratable %d\n", p->migratable);
+	pr_info("migratable %d\n", p->migratable);
 }
 
 static inline void dump_sess(struct osapsess *s)
 {
 	print_hex_dump(KERN_INFO, "trusted-key: handle ", DUMP_PREFIX_NONE,
 		       16, 1, &s->handle, 4, 0);
-	pr_info("trusted-key: secret:\n");
+	pr_info("secret:\n");
 	print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE,
 		       16, 1, &s->secret, SHA1_DIGEST_SIZE, 0);
-	pr_info("trusted-key: enonce:\n");
+	pr_info("enonce:\n");
 	print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE,
 		       16, 1, &s->enonce, SHA1_DIGEST_SIZE, 0);
 }
@@ -86,7 +86,7 @@ static inline void dump_tpm_buf(unsigned char *buf)
 {
 	int len;
 
-	pr_info("\ntrusted-key: tpm buffer\n");
+	pr_info("tpm buffer\n");
 	len = LOAD32(buf, TPM_SIZE_OFFSET);
 	print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1, buf, len, 0);
 }
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#14 lore raw

PATCH 6/8 security: smack: Use a more current logging style

In reply to Joe Perches

Convert printks to pr_<level>
Add pr_fmt.

---
 security/smack/smack_lsm.c |  7 ++++---
 security/smack/smackfs.c   | 25 +++++++++++--------------
 2 files changed, 15 insertions(+), 17 deletions(-)
security/smack/smack_lsm.c +4 -3
index 14f52be..a273aad 100644
@@ -18,6 +18,8 @@
  *      as published by the Free Software Foundation.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/xattr.h>
 #include <linux/pagemap.h>
 #include <linux/mount.h>
@@ -2106,8 +2108,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 		if (sock->sk->sk_family == PF_INET) {
 			rc = smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET);
 			if (rc != 0)
-				printk(KERN_WARNING
-					"Smack: \"%s\" netlbl error %d.\n",
+				pr_warn("\"%s\" netlbl error %d\n",
 					__func__, -rc);
 		}
 	} else
@@ -3916,7 +3917,7 @@ static __init int smack_init(void)
 	if (tsp == NULL)
 		return -ENOMEM;
 
-	printk(KERN_INFO "Smack:  Initializing.\n");
+	pr_info("Initializing\n");
 
 	/*
 	 * Set the security state for the initial task.
security/smack/smackfs.c +11 -14
index 3198cfe..2e25220 100644
@@ -16,6 +16,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/security.h>
@@ -698,8 +700,7 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_map_del(NULL, PF_INET, NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d remove rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d remove rc = %d\n", __func__, __LINE__, rc);
 
 	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
 	if (doip == NULL)
@@ -713,15 +714,13 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_cipsov4_add(doip, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d cipso add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d cipso add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
 	rc = netlbl_cfg_cipsov4_map_add(doip->doi, NULL, NULL, NULL, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d map add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d map add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
@@ -741,8 +740,8 @@ static void smk_unlbl_ambient(char *oldambient)
 	if (oldambient != NULL) {
 		rc = netlbl_cfg_map_del(oldambient, PF_INET, NULL, NULL, &nai);
 		if (rc != 0)
-			printk(KERN_WARNING "%s:%d remove rc = %d\n",
-			       __func__, __LINE__, rc);
+			pr_warn("%s:%d remove rc = %d\n",
+				__func__, __LINE__, rc);
 	}
 	if (smack_net_ambient == NULL)
 		smack_net_ambient = &smack_known_floor;
@@ -750,8 +749,7 @@ static void smk_unlbl_ambient(char *oldambient)
 	rc = netlbl_cfg_unlbl_map_add(smack_net_ambient->smk_known, PF_INET,
 				      NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d add rc = %d\n", __func__, __LINE__, rc);
 }
 
 /*
@@ -2302,8 +2300,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
 
 	rc = simple_fill_super(sb, SMACK_MAGIC, smack_files);
 	if (rc != 0) {
-		printk(KERN_ERR "%s failed %d while creating inodes\n",
-			__func__, rc);
+		pr_err("%s failed %d while creating inodes\n", __func__, rc);
 		return rc;
 	}
 
@@ -2369,13 +2366,13 @@ static int __init init_smk_fs(void)
 
 	err = smk_init_sysfs();
 	if (err)
-		printk(KERN_ERR "smackfs: sysfs mountpoint problem.\n");
+		pr_err("smackfs: sysfs mountpoint problem\n");
 
 	err = register_filesystem(&smk_fs_type);
 	if (!err) {
 		smackfs_mount = kern_mount(&smk_fs_type);
 		if (IS_ERR(smackfs_mount)) {
-			printk(KERN_ERR "smackfs:  could not mount!\n");
+			pr_err("smackfs: could not mount!\n");
 			err = PTR_ERR(smackfs_mount);
 			smackfs_mount = NULL;
 		}
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#25 lore raw

PATCH 8/8 security: yama: Use a more current logging style

In reply to Joe Perches

Convert printks to pr_<level>.
Add pr_fmt to prefix with "yama: "
Convert printk_ratelimited to pr_<level>_ratelimited.

---
 security/yama/yama_lsm.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
security/yama/yama_lsm.c +9 -9
index 13c88fbc..9de0f2b 100644
@@ -12,6 +12,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/security.h>
 #include <linux/sysctl.h>
 #include <linux/ptrace.h>
@@ -319,9 +321,8 @@ int yama_ptrace_access_check(struct task_struct *child,
 	}
 
 	if (rc) {
-		printk_ratelimited(KERN_NOTICE
-			"ptrace of pid %d was attempted by: %s (pid %d)\n",
-			child->pid, current->comm, current->pid);
+		pr_notice_ratelimited("ptrace of pid %d was attempted by: %s (pid %d)\n",
+				      child->pid, current->comm, current->pid);
 	}
 
 	return rc;
@@ -356,9 +357,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
 	}
 
 	if (rc) {
-		printk_ratelimited(KERN_NOTICE
-			"ptraceme of pid %d was attempted by: %s (pid %d)\n",
-			current->pid, parent->comm, parent->pid);
+		pr_notice_ratelimited("ptraceme of pid %d was attempted by: %s (pid %d)\n",
+				      current->pid, parent->comm, parent->pid);
 	}
 
 	return rc;
@@ -425,16 +425,16 @@ static __init int yama_init(void)
 		return 0;
 #endif
 
-	printk(KERN_INFO "Yama: becoming mindful.\n");
+	pr_info("becoming mindful\n");
 
 #ifndef CONFIG_SECURITY_YAMA_STACKED
 	if (register_security(&yama_ops))
-		panic("Yama: kernel registration failed.\n");
+		panic("Yama: kernel registration failed\n");
 #endif
 
 #ifdef CONFIG_SYSCTL
 	if (!register_sysctl_paths(yama_sysctl_path, yama_sysctl_table))
-		panic("Yama: sysctl registration failed.\n");
+		panic("Yama: sysctl registration failed\n");
 #endif
 
 	return 0;
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#23 lore raw

PATCH 7/8 security: tomoyo: Use a more current logging style

In reply to Joe Perches

Convert printks to pr_<level>
Add pr_fmt to prefix output with "tomoyo: "
Coalesce formats.

---
 security/tomoyo/common.c      | 23 ++++++++++-------------
 security/tomoyo/domain.c      |  8 ++++----
 security/tomoyo/load_policy.c |  9 +++++----
 security/tomoyo/memory.c      |  7 ++++---
 security/tomoyo/tomoyo.c      |  4 +++-
 security/tomoyo/util.c        |  7 ++++---
 6 files changed, 30 insertions(+), 28 deletions(-)
security/tomoyo/common.c +10 -13
index 283862a..f18d73c 100644
@@ -4,6 +4,8 @@
  * Copyright (C) 2005-2011  NTT DATA CORPORATION
  */
 
+#define pr_fmt(fmt) "tomoyo: " fmt
+
 #include <linux/uaccess.h>
 #include <linux/slab.h>
 #include <linux/security.h>
@@ -945,8 +947,8 @@ static bool tomoyo_manager(void)
 		static pid_t last_pid;
 		const pid_t pid = current->pid;
 		if (last_pid != pid) {
-			printk(KERN_WARNING "%s ( %s ) is not permitted to "
-			       "update policies.\n", domainname->name, exe);
+			pr_warn("%s ( %s ) is not permitted to update policies\n",
+				domainname->name, exe);
 			last_pid = pid;
 		}
 	}
@@ -2702,29 +2704,24 @@ void tomoyo_check_profile(void)
 	struct tomoyo_domain_info *domain;
 	const int idx = tomoyo_read_lock();
 	tomoyo_policy_loaded = true;
-	printk(KERN_INFO "TOMOYO: 2.5.0\n");
+	pr_info("TOMOYO: 2.5.0\n");
 	list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
 		const u8 profile = domain->profile;
 		const struct tomoyo_policy_namespace *ns = domain->ns;
 		if (ns->profile_version != 20110903)
-			printk(KERN_ERR
-			       "Profile version %u is not supported.\n",
+			pr_err("Profile version %u is not supported\n",
 			       ns->profile_version);
 		else if (!ns->profile_ptr[profile])
-			printk(KERN_ERR
-			       "Profile %u (used by '%s') is not defined.\n",
+			pr_err("Profile %u (used by '%s') is not defined\n",
 			       profile, domain->domainname->name);
 		else
 			continue;
-		printk(KERN_ERR
-		       "Userland tools for TOMOYO 2.5 must be installed and "
-		       "policy must be initialized.\n");
-		printk(KERN_ERR "Please see http://tomoyo.sourceforge.jp/2.5/ "
-		       "for more information.\n");
+		pr_err("Userland tools for TOMOYO 2.5 must be installed and policy must be initialized\n");
+		pr_err("Please see http://tomoyo.sourceforge.jp/2.5/ for more information\n");
 		panic("STOP!");
 	}
 	tomoyo_read_unlock(idx);
-	printk(KERN_INFO "Mandatory Access Control activated.\n");
+	pr_info("Mandatory Access Control activated\n");
 }
 
 /**
security/tomoyo/domain.c +4 -4
index 3865145..a150642 100644
@@ -4,6 +4,8 @@
  * Copyright (C) 2005-2011  NTT DATA CORPORATION
  */
 
+#define pr_fmt(fmt) "tomoyo: " fmt
+
 #include "common.h"
 #include <linux/binfmts.h>
 #include <linux/slab.h>
@@ -819,8 +821,7 @@ force_jump_domain:
 	if (domain)
 		retval = 0;
 	else if (reject_on_transition_failure) {
-		printk(KERN_WARNING "ERROR: Domain '%s' not ready.\n",
-		       ee->tmp);
+		pr_warn("ERROR: Domain '%s' not ready\n", ee->tmp);
 		retval = -ENOMEM;
 	} else if (ee->r.mode == TOMOYO_CONFIG_ENFORCING)
 		retval = -ENOMEM;
@@ -831,8 +832,7 @@ force_jump_domain:
 			ee->r.granted = false;
 			tomoyo_write_log(&ee->r, "%s", tomoyo_dif
 					 [TOMOYO_DIF_TRANSITION_FAILED]);
-			printk(KERN_WARNING
-			       "ERROR: Domain '%s' not defined.\n", ee->tmp);
+			pr_warn("ERROR: Domain '%s' not defined\n", ee->tmp);
 		}
 	}
  out:
security/tomoyo/load_policy.c +5 -4
index 078fac0..f5f5a06 100644
@@ -4,6 +4,8 @@
  * Copyright (C) 2005-2011  NTT DATA CORPORATION
  */
 
+#define pr_fmt(fmt) "tomoyo: " fmt
+
 #include "common.h"
 
 #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
@@ -39,8 +41,8 @@ static bool tomoyo_policy_loader_exists(void)
 	if (!tomoyo_loader)
 		tomoyo_loader = CONFIG_SECURITY_TOMOYO_POLICY_LOADER;
 	if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) {
-		printk(KERN_INFO "Not activating Mandatory Access Control "
-		       "as %s does not exist.\n", tomoyo_loader);
+		pr_info("Not activating Mandatory Access Control as %s does not exist\n",
+			tomoyo_loader);
 		return false;
 	}
 	path_put(&path);
@@ -95,8 +97,7 @@ void tomoyo_load_policy(const char *filename)
 	if (!tomoyo_policy_loader_exists())
 		return;
 	done = true;
-	printk(KERN_INFO "Calling %s to load policy. Please wait.\n",
-	       tomoyo_loader);
+	pr_info("Calling %s to load policy. Please wait.\n", tomoyo_loader);
 	argv[0] = (char *) tomoyo_loader;
 	argv[1] = NULL;
 	envp[0] = "HOME=/";
security/tomoyo/memory.c +4 -3
index 0e99571..b9bc828 100644
@@ -4,6 +4,8 @@
  * Copyright (C) 2005-2011  NTT DATA CORPORATION
  */
 
+#define pr_fmt(fmt) "tomoyo: " fmt
+
 #include <linux/hash.h>
 #include <linux/slab.h>
 #include "common.h"
@@ -19,12 +21,11 @@ void tomoyo_warn_oom(const char *function)
 	static pid_t tomoyo_last_pid;
 	const pid_t pid = current->pid;
 	if (tomoyo_last_pid != pid) {
-		printk(KERN_WARNING "ERROR: Out of memory at %s.\n",
-		       function);
+		pr_warn("ERROR: Out of memory at %s\n", function);
 		tomoyo_last_pid = pid;
 	}
 	if (!tomoyo_policy_loaded)
-		panic("MAC Initialization failed.\n");
+		panic("MAC Initialization failed\n");
 }
 
 /* Memoy currently used by policy/audit log/query. */
security/tomoyo/tomoyo.c +3 -1
index f0b756e..d363805 100644
@@ -4,6 +4,8 @@
  * Copyright (C) 2005-2011  NTT DATA CORPORATION
  */
 
+#define pr_fmt(fmt) "tomoyo: " fmt
+
 #include <linux/security.h>
 #include "common.h"
 
@@ -552,7 +554,7 @@ static int __init tomoyo_init(void)
 	/* register ourselves with the security framework */
 	if (register_security(&tomoyo_security_ops))
 		panic("Failure registering TOMOYO Linux");
-	printk(KERN_INFO "TOMOYO Linux initialized\n");
+	pr_info("TOMOYO Linux initialized\n");
 	cred->security = &tomoyo_kernel_domain;
 	tomoyo_mm_init();
 	return 0;
security/tomoyo/util.c +4 -3
index 2952ba5..4d4131c 100644
@@ -4,6 +4,8 @@
  * Copyright (C) 2005-2011  NTT DATA CORPORATION
  */
 
+#define pr_fmt(fmt) "tomoyo: " fmt
+
 #include <linux/slab.h>
 #include "common.h"
 
@@ -1077,9 +1079,8 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
 		domain->flags[TOMOYO_DIF_QUOTA_WARNED] = true;
 		/* r->granted = false; */
 		tomoyo_write_log(r, "%s", tomoyo_dif[TOMOYO_DIF_QUOTA_WARNED]);
-		printk(KERN_WARNING "WARNING: "
-		       "Domain '%s' has too many ACLs to hold. "
-		       "Stopped learning mode.\n", domain->domainname->name);
+		pr_warn("WARNING: Domain '%s' has too many ACLs to hold - stopped learning mode\n",
+			domain->domainname->name);
 	}
 	return false;
 }
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
maintainer
#15 lore raw

Re: [PATCH 6/8] security: smack: Use a more current logging style

In reply to Joe Perches
Quoted 14 lines · Joe Perches

Convert printks to pr_<level>
Add pr_fmt.

---
 security/smack/smack_lsm.c |  7 ++++---
 security/smack/smackfs.c   | 25 +++++++++++--------------
 2 files changed, 15 insertions(+), 17 deletions(-)
security/smack/smack_lsm.c +0 -0
index 14f52be..a273aad 100644

security/smack/smack_lsm.c line 22

Quoted 5 lines
security/smack/smack_lsm.c +2 -0
@@ -18,6 +18,8 @@
  *      as published by the Free Software Foundation.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+

What is pr_fmt() for?

Quoted 110 lines
security/smack/smack_lsm.c +2 -3
 #include <linux/xattr.h>
 #include <linux/pagemap.h>
 #include <linux/mount.h>
@@ -2106,8 +2108,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 		if (sock->sk->sk_family == PF_INET) {
 			rc = smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET);
 			if (rc != 0)
-				printk(KERN_WARNING
-					"Smack: \"%s\" netlbl error %d.\n",
+				pr_warn("\"%s\" netlbl error %d\n",
 					__func__, -rc);
 		}
 	} else
@@ -3916,7 +3917,7 @@ static __init int smack_init(void)
 	if (tsp == NULL)
 		return -ENOMEM;
 
-	printk(KERN_INFO "Smack:  Initializing.\n");
+	pr_info("Initializing\n");
 
 	/*
 	 * Set the security state for the initial task.
security/smack/smackfs.c +11 -14
index 3198cfe..2e25220 100644
@@ -16,6 +16,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/security.h>
@@ -698,8 +700,7 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_map_del(NULL, PF_INET, NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d remove rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d remove rc = %d\n", __func__, __LINE__, rc);
 
 	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
 	if (doip == NULL)
@@ -713,15 +714,13 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_cipsov4_add(doip, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d cipso add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d cipso add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
 	rc = netlbl_cfg_cipsov4_map_add(doip->doi, NULL, NULL, NULL, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d map add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d map add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
@@ -741,8 +740,8 @@ static void smk_unlbl_ambient(char *oldambient)
 	if (oldambient != NULL) {
 		rc = netlbl_cfg_map_del(oldambient, PF_INET, NULL, NULL, &nai);
 		if (rc != 0)
-			printk(KERN_WARNING "%s:%d remove rc = %d\n",
-			       __func__, __LINE__, rc);
+			pr_warn("%s:%d remove rc = %d\n",
+				__func__, __LINE__, rc);
 	}
 	if (smack_net_ambient == NULL)
 		smack_net_ambient = &smack_known_floor;
@@ -750,8 +749,7 @@ static void smk_unlbl_ambient(char *oldambient)
 	rc = netlbl_cfg_unlbl_map_add(smack_net_ambient->smk_known, PF_INET,
 				      NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d add rc = %d\n", __func__, __LINE__, rc);
 }
 
 /*
@@ -2302,8 +2300,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
 
 	rc = simple_fill_super(sb, SMACK_MAGIC, smack_files);
 	if (rc != 0) {
-		printk(KERN_ERR "%s failed %d while creating inodes\n",
-			__func__, rc);
+		pr_err("%s failed %d while creating inodes\n", __func__, rc);
 		return rc;
 	}
 
@@ -2369,13 +2366,13 @@ static int __init init_smk_fs(void)
 
 	err = smk_init_sysfs();
 	if (err)
-		printk(KERN_ERR "smackfs: sysfs mountpoint problem.\n");
+		pr_err("smackfs: sysfs mountpoint problem\n");
 
 	err = register_filesystem(&smk_fs_type);
 	if (!err) {
 		smackfs_mount = kern_mount(&smk_fs_type);
 		if (IS_ERR(smackfs_mount)) {
-			printk(KERN_ERR "smackfs:  could not mount!\n");
+			pr_err("smackfs: could not mount!\n");
 			err = PTR_ERR(smackfs_mount);
 			smackfs_mount = NULL;
 		}
#16 lore raw

Re: [PATCH 6/8] security: smack: Use a more current logging style

Quoted 5 lines · Casey Schaufler

security/smack/smack_lsm.c

Quoted 4 lines · Joe Perches

Convert printks to pr_<level>
Add pr_fmt.

security/smack/smack_lsm.c +0 -0

[]

Quoted 4 lines

security/smack/smack_lsm.c

Quoted 2 lines
security/smack/smack_lsm.c +2 -0
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+

What is pr_fmt() for?

Prefixing "smack: " to the pr_<level> uses.

Quoted 8 lines

security/smack/smack_lsm.c static int smack_inode_setsecurity(struct inode *inode, const char *name, · line 2112

Quoted 8 lines
security/smack/smack_lsm.c +1 -2
@@ -2106,8 +2108,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 		if (sock->sk->sk_family == PF_INET) {
 			rc = smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET);
 			if (rc != 0)
-				printk(KERN_WARNING
-					"Smack: \"%s\" netlbl error %d.\n",
+				pr_warn("\"%s\" netlbl error %d\n",
 					__func__, -rc);

This will be now be emitted as

<4>smack: "smack_inode_setsecurity" netlbl error -<d>

instead of

<4>Smack: "smack_inode_setsecurity" netlbl error -<d>

Though it'd be a lot more common to use:

					pr_warn("%s: netlbl error: %d\n",
						__func__, -rc);

so the output would be:

<4>smack: smack_inode_setsecurity: netlbl error: -<d>

maintainer
#17 lore raw

Re: [PATCH 6/8] security: smack: Use a more current logging style

Quoted 10 lines · Joe Perches
Quoted 4 lines · Casey Schaufler

security/smack/smack_lsm.c

Quoted 3 lines · Joe Perches

Convert printks to pr_<level>
Add pr_fmt.

security/smack/smack_lsm.c +0 -0

[]

Quoted 3 lines

security/smack/smack_lsm.c

Quoted 2 lines
security/smack/smack_lsm.c +2 -0
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+

What is pr_fmt() for?

Prefixing "smack: " to the pr_<level> uses.

OK. I didn't see where it was used. I understand now. I'll go back and ACK the changes.

Quoted 28 lines
Quoted 9 lines

security/smack/smack_lsm.c static int smack_inode_setsecurity(struct inode *inode, const char *name, · line 2112

Quoted 9 lines
security/smack/smack_lsm.c +1 -2
@@ -2106,8 +2108,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 		if (sock->sk->sk_family == PF_INET) {
 			rc = smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET);
 			if (rc != 0)
-				printk(KERN_WARNING
-					"Smack: \"%s\" netlbl error %d.\n",
+				pr_warn("\"%s\" netlbl error %d\n",
 					__func__, -rc);

This will be now be emitted as

<4>smack: "smack_inode_setsecurity" netlbl error -<d>

instead of

<4>Smack: "smack_inode_setsecurity" netlbl error -<d>

Though it'd be a lot more common to use:

					pr_warn("%s: netlbl error: %d\n",
						__func__, -rc);

so the output would be:

<4>smack: smack_inode_setsecurity: netlbl error: -<d>

maintainer Acked-by on v1 6/8
#18 lore raw

Re: [PATCH 6/8] security: smack: Use a more current logging style

In reply to Joe Perches
Quoted 4 lines · Joe Perches

Convert printks to pr_<level>
Add pr_fmt.

I will take this into the smack-next tree.

Quoted 125 lines
---
 security/smack/smack_lsm.c |  7 ++++---
 security/smack/smackfs.c   | 25 +++++++++++--------------
 2 files changed, 15 insertions(+), 17 deletions(-)
security/smack/smack_lsm.c +4 -3
index 14f52be..a273aad 100644
@@ -18,6 +18,8 @@
  *      as published by the Free Software Foundation.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/xattr.h>
 #include <linux/pagemap.h>
 #include <linux/mount.h>
@@ -2106,8 +2108,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 		if (sock->sk->sk_family == PF_INET) {
 			rc = smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET);
 			if (rc != 0)
-				printk(KERN_WARNING
-					"Smack: \"%s\" netlbl error %d.\n",
+				pr_warn("\"%s\" netlbl error %d\n",
 					__func__, -rc);
 		}
 	} else
@@ -3916,7 +3917,7 @@ static __init int smack_init(void)
 	if (tsp == NULL)
 		return -ENOMEM;
 
-	printk(KERN_INFO "Smack:  Initializing.\n");
+	pr_info("Initializing\n");
 
 	/*
 	 * Set the security state for the initial task.
security/smack/smackfs.c +11 -14
index 3198cfe..2e25220 100644
@@ -16,6 +16,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/security.h>
@@ -698,8 +700,7 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_map_del(NULL, PF_INET, NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d remove rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d remove rc = %d\n", __func__, __LINE__, rc);
 
 	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
 	if (doip == NULL)
@@ -713,15 +714,13 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_cipsov4_add(doip, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d cipso add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d cipso add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
 	rc = netlbl_cfg_cipsov4_map_add(doip->doi, NULL, NULL, NULL, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d map add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d map add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
@@ -741,8 +740,8 @@ static void smk_unlbl_ambient(char *oldambient)
 	if (oldambient != NULL) {
 		rc = netlbl_cfg_map_del(oldambient, PF_INET, NULL, NULL, &nai);
 		if (rc != 0)
-			printk(KERN_WARNING "%s:%d remove rc = %d\n",
-			       __func__, __LINE__, rc);
+			pr_warn("%s:%d remove rc = %d\n",
+				__func__, __LINE__, rc);
 	}
 	if (smack_net_ambient == NULL)
 		smack_net_ambient = &smack_known_floor;
@@ -750,8 +749,7 @@ static void smk_unlbl_ambient(char *oldambient)
 	rc = netlbl_cfg_unlbl_map_add(smack_net_ambient->smk_known, PF_INET,
 				      NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d add rc = %d\n", __func__, __LINE__, rc);
 }
 
 /*
@@ -2302,8 +2300,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
 
 	rc = simple_fill_super(sb, SMACK_MAGIC, smack_files);
 	if (rc != 0) {
-		printk(KERN_ERR "%s failed %d while creating inodes\n",
-			__func__, rc);
+		pr_err("%s failed %d while creating inodes\n", __func__, rc);
 		return rc;
 	}
 
@@ -2369,13 +2366,13 @@ static int __init init_smk_fs(void)
 
 	err = smk_init_sysfs();
 	if (err)
-		printk(KERN_ERR "smackfs: sysfs mountpoint problem.\n");
+		pr_err("smackfs: sysfs mountpoint problem\n");
 
 	err = register_filesystem(&smk_fs_type);
 	if (!err) {
 		smackfs_mount = kern_mount(&smk_fs_type);
 		if (IS_ERR(smackfs_mount)) {
-			printk(KERN_ERR "smackfs:  could not mount!\n");
+			pr_err("smackfs: could not mount!\n");
 			err = PTR_ERR(smackfs_mount);
 			smackfs_mount = NULL;
 		}
maintainer
#19 lore raw

Re: [PATCH 6/8] security: smack: Use a more current logging style

Quoted 8 lines · Casey Schaufler
Quoted 4 lines · Joe Perches

Convert printks to pr_<level>
Add pr_fmt.

I will take this into the smack-next tree.

Unless James would rather take the whole set, that is.

Quoted 131 lines
Quoted 116 lines
---
 security/smack/smack_lsm.c |  7 ++++---
 security/smack/smackfs.c   | 25 +++++++++++--------------
 2 files changed, 15 insertions(+), 17 deletions(-)
security/smack/smack_lsm.c +4 -3
index 14f52be..a273aad 100644
@@ -18,6 +18,8 @@
  *      as published by the Free Software Foundation.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/xattr.h>
 #include <linux/pagemap.h>
 #include <linux/mount.h>
@@ -2106,8 +2108,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 		if (sock->sk->sk_family == PF_INET) {
 			rc = smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET);
 			if (rc != 0)
-				printk(KERN_WARNING
-					"Smack: \"%s\" netlbl error %d.\n",
+				pr_warn("\"%s\" netlbl error %d\n",
 					__func__, -rc);
 		}
 	} else
@@ -3916,7 +3917,7 @@ static __init int smack_init(void)
 	if (tsp == NULL)
 		return -ENOMEM;
 
-	printk(KERN_INFO "Smack:  Initializing.\n");
+	pr_info("Initializing\n");
 
 	/*
 	 * Set the security state for the initial task.
security/smack/smackfs.c +10 -13
index 3198cfe..2e25220 100644
@@ -16,6 +16,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/security.h>
@@ -698,8 +700,7 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_map_del(NULL, PF_INET, NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d remove rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d remove rc = %d\n", __func__, __LINE__, rc);
 
 	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
 	if (doip == NULL)
@@ -713,15 +714,13 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_cipsov4_add(doip, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d cipso add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d cipso add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
 	rc = netlbl_cfg_cipsov4_map_add(doip->doi, NULL, NULL, NULL, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d map add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d map add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
@@ -741,8 +740,8 @@ static void smk_unlbl_ambient(char *oldambient)
 	if (oldambient != NULL) {
 		rc = netlbl_cfg_map_del(oldambient, PF_INET, NULL, NULL, &nai);
 		if (rc != 0)
-			printk(KERN_WARNING "%s:%d remove rc = %d\n",
-			       __func__, __LINE__, rc);
+			pr_warn("%s:%d remove rc = %d\n",
+				__func__, __LINE__, rc);
 	}
 	if (smack_net_ambient == NULL)
 		smack_net_ambient = &smack_known_floor;
@@ -750,8 +749,7 @@ static void smk_unlbl_ambient(char *oldambient)
 	rc = netlbl_cfg_unlbl_map_add(smack_net_ambient->smk_known, PF_INET,
 				      NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d add rc = %d\n", __func__, __LINE__, rc);
 }
 
 /*
@@ -2302,8 +2300,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
 
 	rc = simple_fill_super(sb, SMACK_MAGIC, smack_files);
 	if (rc != 0) {
-		printk(KERN_ERR "%s failed %d while creating inodes\n",
-			__func__, rc);
+		pr_err("%s failed %d while creating inodes\n", __func__, rc);
 		return rc;
 	}
 
@@ -2369,13 +2366,13 @@ static int __init init_smk_fs(void)
 
 	err = smk_init_sysfs();
 	if (err)
-		printk(KERN_ERR "smackfs: sysfs mountpoint problem.\n");
+		pr_err("smackfs: sysfs mountpoint problem\n");

security/smack/smackfs.c static int __init init_smk_fs(void) · line 2378

Quoted 10 lines
security/smack/smackfs.c +1 -1
 
 	err = register_filesystem(&smk_fs_type);
 	if (!err) {
 		smackfs_mount = kern_mount(&smk_fs_type);
 		if (IS_ERR(smackfs_mount)) {
-			printk(KERN_ERR "smackfs:  could not mount!\n");
+			pr_err("smackfs: could not mount!\n");
 			err = PTR_ERR(smackfs_mount);
 			smackfs_mount = NULL;
 		}

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH 3/8] security: integrity: Use a more current logging style

In reply to Joe Perches
Quoted 5 lines · Joe Perches

Convert printks to pr_<level>.
Add pr_fmt.
Remove embedded prefixes.

Thanks Joe, both this and the keys patch look good.

Quoted 189 lines
---
 security/integrity/evm/evm_crypto.c   | 4 +++-
 security/integrity/evm/evm_main.c     | 6 ++++--
 security/integrity/evm/evm_secfs.c    | 6 ++++--
 security/integrity/ima/ima_crypto.c   | 4 +++-
 security/integrity/ima/ima_init.c     | 5 ++++-
 security/integrity/ima/ima_queue.c    | 8 +++++---
 security/integrity/ima/ima_template.c | 5 ++++-
 7 files changed, 27 insertions(+), 11 deletions(-)
security/integrity/evm/evm_crypto.c +3 -1
index 3bab89e..9bd329f 100644
@@ -13,6 +13,8 @@
  *	 Using root's kernel master key (kmk), calculate the HMAC
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/crypto.h>
 #include <linux/xattr.h>
@@ -221,7 +223,7 @@ int evm_init_hmac(struct inode *inode, const struct xattr *lsm_xattr,
 
 	desc = init_desc(EVM_XATTR_HMAC);
 	if (IS_ERR(desc)) {
-		printk(KERN_INFO "init_desc failed\n");
+		pr_info("init_desc failed\n");
 		return PTR_ERR(desc);
 	}
 
security/integrity/evm/evm_main.c +4 -2
index 336b3dd..996092f 100644
@@ -14,6 +14,8 @@
  *	evm_inode_removexattr, and evm_verifyxattr
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/crypto.h>
 #include <linux/audit.h>
@@ -432,7 +434,7 @@ static int __init init_evm(void)
 
 	error = evm_init_secfs();
 	if (error < 0) {
-		printk(KERN_INFO "EVM: Error registering secfs\n");
+		pr_info("Error registering secfs\n");
 		goto err;
 	}
 
@@ -449,7 +451,7 @@ static int __init evm_display_config(void)
 	char **xattrname;
 
 	for (xattrname = evm_config_xattrnames; *xattrname != NULL; xattrname++)
-		printk(KERN_INFO "EVM: %s\n", *xattrname);
+		pr_info("%s\n", *xattrname);
 	return 0;
 }
 
security/integrity/evm/evm_secfs.c +4 -2
index 30f670a..cf12a04 100644
@@ -13,6 +13,8 @@
  *	- Get the key and enable EVM
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/uaccess.h>
 #include <linux/module.h>
 #include "evm.h"
@@ -79,9 +81,9 @@ static ssize_t evm_write_key(struct file *file, const char __user *buf,
 	error = evm_init_key();
 	if (!error) {
 		evm_initialized = 1;
-		pr_info("EVM: initialized\n");
+		pr_info("initialized\n");
 	} else
-		pr_err("EVM: initialization failed\n");
+		pr_err("initialization failed\n");
 	return count;
 }
 
security/integrity/ima/ima_crypto.c +3 -1
index fdf60de..972df659 100644
@@ -13,6 +13,8 @@
  * 	Calculates md5/sha1 file hash, template hash, boot-aggreate hash
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/file.h>
 #include <linux/crypto.h>
@@ -205,7 +207,7 @@ static void __init ima_pcrread(int idx, u8 *pcr)
 		return;
 
 	if (tpm_pcr_read(TPM_ANY_NUM, idx, pcr) != 0)
-		pr_err("IMA: Error Communicating to TPM chip\n");
+		pr_err("Error Communicating to TPM chip\n");
 }
 
 /*
security/integrity/ima/ima_init.c +4 -1
index 3712276..b3bc313 100644
@@ -14,6 +14,9 @@
  * File: ima_init.c
  *             initialization and cleanup functions
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/scatterlist.h>
 #include <linux/slab.h>
@@ -93,7 +96,7 @@ int __init ima_init(void)
 		ima_used_chip = 1;
 
 	if (!ima_used_chip)
-		pr_info("IMA: No TPM chip found, activating TPM-bypass!\n");
+		pr_info("No TPM chip found, activating TPM-bypass!\n");
 
 	rc = ima_init_crypto();
 	if (rc)
security/integrity/ima/ima_queue.c +5 -3
index d85e997..91128b4 100644
@@ -18,6 +18,9 @@
  *       The measurement list is append-only. No entry is
  *       ever removed or changed during the boot-cycle.
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/rculist.h>
 #include <linux/slab.h>
@@ -72,7 +75,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
 
 	qe = kmalloc(sizeof(*qe), GFP_KERNEL);
 	if (qe == NULL) {
-		pr_err("IMA: OUT OF MEMORY ERROR creating queue entry.\n");
+		pr_err("OUT OF MEMORY ERROR creating queue entry\n");
 		return -ENOMEM;
 	}
 	qe->entry = entry;
@@ -95,8 +98,7 @@ static int ima_pcr_extend(const u8 *hash)
 
 	result = tpm_pcr_extend(TPM_ANY_NUM, CONFIG_IMA_MEASURE_PCR_IDX, hash);
 	if (result != 0)
-		pr_err("IMA: Error Communicating to TPM chip, result: %d\n",
-		       result);
+		pr_err("Error Communicating to TPM chip, result: %d\n", result);
 	return result;
 }
 
security/integrity/ima/ima_template.c +4 -1
index 635695f..9a4a0d1 100644
@@ -12,6 +12,9 @@
  * File: ima_template.c
  *      Helpers to manage template descriptors.
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <crypto/hash_info.h>
 
 #include "ima.h"
@@ -58,7 +61,7 @@ static int __init ima_template_setup(char *str)
 	 */
 	if (template_len == 3 && strcmp(str, IMA_TEMPLATE_IMA_NAME) == 0 &&
 	    ima_hash_algo != HASH_ALGO_SHA1 && ima_hash_algo != HASH_ALGO_MD5) {
-		pr_err("IMA: template does not support hash alg\n");
+		pr_err("template does not support hash alg\n");
 		return 1;
 	}
 
maintainer
#20 lore raw

Re: [PATCH 6/8] security: smack: Use a more current logging style

In reply to Casey Schaufler
Quoted 11 lines · Casey Schaufler
Quoted 8 lines · Casey Schaufler
Quoted 4 lines · Joe Perches

Convert printks to pr_<level>
Add pr_fmt.

I will take this into the smack-next tree.

Unless James would rather take the whole set, that is.

Yep, I'll take the whole set.

Quoted 138 lines
Quoted 118 lines
Quoted 118 lines

---
 security/smack/smack_lsm.c |  7 ++++---
 security/smack/smackfs.c   | 25 +++++++++++--------------
 2 files changed, 15 insertions(+), 17 deletions(-)
security/smack/smack_lsm.c +4 -3
index 14f52be..a273aad 100644
@@ -18,6 +18,8 @@
  *      as published by the Free Software Foundation.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/xattr.h>
 #include <linux/pagemap.h>
 #include <linux/mount.h>
@@ -2106,8 +2108,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 		if (sock->sk->sk_family == PF_INET) {
 			rc = smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET);
 			if (rc != 0)
-				printk(KERN_WARNING
-					"Smack: \"%s\" netlbl error %d.\n",
+				pr_warn("\"%s\" netlbl error %d\n",
 					__func__, -rc);
 		}
 	} else
@@ -3916,7 +3917,7 @@ static __init int smack_init(void)
 	if (tsp == NULL)
 		return -ENOMEM;
 
-	printk(KERN_INFO "Smack:  Initializing.\n");
+	pr_info("Initializing\n");
 
 	/*
 	 * Set the security state for the initial task.
security/smack/smackfs.c +10 -13
index 3198cfe..2e25220 100644
@@ -16,6 +16,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/security.h>
@@ -698,8 +700,7 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_map_del(NULL, PF_INET, NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d remove rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d remove rc = %d\n", __func__, __LINE__, rc);
 
 	doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
 	if (doip == NULL)
@@ -713,15 +714,13 @@ static void smk_cipso_doi(void)
 
 	rc = netlbl_cfg_cipsov4_add(doip, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d cipso add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d cipso add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
 	rc = netlbl_cfg_cipsov4_map_add(doip->doi, NULL, NULL, NULL, &nai);
 	if (rc != 0) {
-		printk(KERN_WARNING "%s:%d map add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d map add rc = %d\n", __func__, __LINE__, rc);
 		kfree(doip);
 		return;
 	}
@@ -741,8 +740,8 @@ static void smk_unlbl_ambient(char *oldambient)
 	if (oldambient != NULL) {
 		rc = netlbl_cfg_map_del(oldambient, PF_INET, NULL, NULL, &nai);
 		if (rc != 0)
-			printk(KERN_WARNING "%s:%d remove rc = %d\n",
-			       __func__, __LINE__, rc);
+			pr_warn("%s:%d remove rc = %d\n",
+				__func__, __LINE__, rc);
 	}
 	if (smack_net_ambient == NULL)
 		smack_net_ambient = &smack_known_floor;
@@ -750,8 +749,7 @@ static void smk_unlbl_ambient(char *oldambient)
 	rc = netlbl_cfg_unlbl_map_add(smack_net_ambient->smk_known, PF_INET,
 				      NULL, NULL, &nai);
 	if (rc != 0)
-		printk(KERN_WARNING "%s:%d add rc = %d\n",
-		       __func__, __LINE__, rc);
+		pr_warn("%s:%d add rc = %d\n", __func__, __LINE__, rc);
 }
 
 /*
@@ -2302,8 +2300,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
 
 	rc = simple_fill_super(sb, SMACK_MAGIC, smack_files);
 	if (rc != 0) {
-		printk(KERN_ERR "%s failed %d while creating inodes\n",
-			__func__, rc);
+		pr_err("%s failed %d while creating inodes\n", __func__, rc);
 		return rc;
 	}
 
@@ -2369,13 +2366,13 @@ static int __init init_smk_fs(void)
 
 	err = smk_init_sysfs();
 	if (err)
-		printk(KERN_ERR "smackfs: sysfs mountpoint problem.\n");
+		pr_err("smackfs: sysfs mountpoint problem\n");
 
Quoted 14 lines

security/smack/smackfs.c static int __init init_smk_fs(void) · line 2378

Quoted 9 lines
security/smack/smackfs.c +1 -1
 	err = register_filesystem(&smk_fs_type);
 	if (!err) {
 		smackfs_mount = kern_mount(&smk_fs_type);
 		if (IS_ERR(smackfs_mount)) {
-			printk(KERN_ERR "smackfs:  could not mount!\n");
+			pr_err("smackfs: could not mount!\n");
 			err = PTR_ERR(smackfs_mount);
 			smackfs_mount = NULL;
 		}

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
James Morris
<[email protected]>
Acked-by on v1 1/8
#2 lore raw
In reply to Joe Perches
Quoted 7 lines · Joe Perches

Convert printks to pr_<level>.
Add pr_fmt to prefix output with "security: " or "capability: " Coalesce formats.
Use a generic string for pr_debug to reduce object size.

---

Though should warn_setuid_and_fcaps_mixed be using pr_info_once()?

Quoted 111 lines
 security/capability.c | 16 +++++++++-------
 security/commoncap.c  | 15 ++++++++-------
 security/security.c   |  4 +++-
 3 files changed, 20 insertions(+), 15 deletions(-)
security/capability.c +9 -7
index 8b4f24a..086af9b 100644
@@ -10,6 +10,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/security.h>
 
 static int cap_syslog(int type)
@@ -914,13 +916,13 @@ static void cap_audit_rule_free(void *lsmrule)
 #endif /* CONFIG_AUDIT */
 
 #define set_to_cap_if_null(ops, function)				\
-	do {								\
-		if (!ops->function) {					\
-			ops->function = cap_##function;			\
-			pr_debug("Had to override the " #function	\
-				 " security operation with the default.\n");\
-			}						\
-	} while (0)
+do {									\
+	if (!ops->function) {						\
+		ops->function = cap_##function;				\
+		pr_debug("Had to override the %s security operation with the default\n", \
+			 #function);					\
+	}								\
+} while (0)
 
 void __init security_fixup_ops(struct security_operations *ops)
 {
security/commoncap.c +8 -7
index b9d613e..b5c3bc4 100644
@@ -7,6 +7,8 @@
  *
  */
 
+#define pr_fmt(fmt) "capability: " fmt
+
 #include <linux/capability.h>
 #include <linux/audit.h>
 #include <linux/module.h>
@@ -46,9 +48,8 @@ static void warn_setuid_and_fcaps_mixed(const char *fname)
 {
 	static int warned;
 	if (!warned) {
-		printk(KERN_INFO "warning: `%s' has both setuid-root and"
-			" effective capabilities. Therefore not raising all"
-			" capabilities.\n", fname);
+		pr_info("warning: `%s' has both setuid-root and effective capabilities, therefore not raising all capabilities\n",
+			fname);
 		warned = 1;
 	}
 }
@@ -448,8 +449,8 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_c
 	rc = get_vfs_caps_from_disk(dentry, &vcaps);
 	if (rc < 0) {
 		if (rc == -EINVAL)
-			printk(KERN_NOTICE "%s: get_vfs_caps_from_disk returned %d for %s\n",
-				__func__, rc, bprm->filename);
+			pr_notice("%s: get_vfs_caps_from_disk returned %d for %s\n",
+				  __func__, rc, bprm->filename);
 		else if (rc == -ENODATA)
 			rc = 0;
 		goto out;
@@ -457,8 +458,8 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_c
 
 	rc = bprm_caps_from_vfs_caps(&vcaps, bprm, effective, has_cap);
 	if (rc == -EINVAL)
-		printk(KERN_NOTICE "%s: cap_from_disk returned %d for %s\n",
-		       __func__, rc, bprm->filename);
+		pr_notice("%s: cap_from_disk returned %d for %s\n",
+			  __func__, rc, bprm->filename);
 
 out:
 	dput(dentry);
security/security.c +3 -1
index 15b6928..53d1885 100644
@@ -11,6 +11,8 @@
  *	(at your option) any later version.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/capability.h>
 #include <linux/dcache.h>
 #include <linux/module.h>
@@ -64,7 +66,7 @@ static void __init do_security_initcalls(void)
  */
 int __init security_init(void)
 {
-	printk(KERN_INFO "Security Framework initialized\n");
+	pr_info("Security Framework initialized\n");
 
 	security_fixup_ops(&default_security_ops);
 	security_ops = &default_security_ops;
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#3 lore raw
Quoted 2 lines · Serge Hallyn
Quoted 1 line · Joe Perches

Convert printks to pr_<level>.

[]

Quoted 4 lines

Though should warn_setuid_and_fcaps_mixed be using pr_info_once()?

Yup, thanks. I'll send a follow-on with your reported-by if/after this is applied and I'll send a V2 now so James could apply that instead if that's what he prefers.

Quoted 1 line

security/commoncap.c

Quoted 1 line
security/commoncap.c +0 -0

[]

Quoted 9 lines

security/commoncap.c static void warn_setuid_and_fcaps_mixed(const char *fname) · line 52

Quoted 9 lines
security/commoncap.c +2 -3
@@ -46,9 +48,8 @@ static void warn_setuid_and_fcaps_mixed(const char *fname)
 {
 	static int warned;
 	if (!warned) {
-		printk(KERN_INFO "warning: `%s' has both setuid-root and"
-			" effective capabilities. Therefore not raising all"
-			" capabilities.\n", fname);
+		pr_info("warning: `%s' has both setuid-root and effective capabilities, therefore not raising all capabilities\n",
+			fname);
	pr_info_once(etc...
Quoted 3 lines
Quoted 3 lines
security/commoncap.c +0 -0
 		warned = 1;
 	}
 }
#4 lore raw

PATCH v2 1/8 security: Use a more current logging style

In reply to Serge Hallyn

Convert printks to pr_<level>.
Convert printk with single time guard to pr_info_once. Add pr_fmt to prefix output with "security: " or "capability: " Coalesce formats.
Use a generic string for pr_debug to reduce object size.

---
 security/capability.c | 16 +++++++++-------
 security/commoncap.c  | 19 ++++++++-----------
 security/security.c   |  4 +++-
 3 files changed, 20 insertions(+), 19 deletions(-)
security/capability.c +9 -7
index 8b4f24a..086af9b 100644
@@ -10,6 +10,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/security.h>
 
 static int cap_syslog(int type)
@@ -914,13 +916,13 @@ static void cap_audit_rule_free(void *lsmrule)
 #endif /* CONFIG_AUDIT */
 
 #define set_to_cap_if_null(ops, function)				\
-	do {								\
-		if (!ops->function) {					\
-			ops->function = cap_##function;			\
-			pr_debug("Had to override the " #function	\
-				 " security operation with the default.\n");\
-			}						\
-	} while (0)
+do {									\
+	if (!ops->function) {						\
+		ops->function = cap_##function;				\
+		pr_debug("Had to override the %s security operation with the default\n", \
+			 #function);					\
+	}								\
+} while (0)
 
 void __init security_fixup_ops(struct security_operations *ops)
 {
security/commoncap.c +8 -11
index b9d613e..09da086 100644
@@ -7,6 +7,8 @@
  *
  */
 
+#define pr_fmt(fmt) "capability: " fmt
+
 #include <linux/capability.h>
 #include <linux/audit.h>
 #include <linux/module.h>
@@ -44,13 +46,8 @@
  */
 static void warn_setuid_and_fcaps_mixed(const char *fname)
 {
-	static int warned;
-	if (!warned) {
-		printk(KERN_INFO "warning: `%s' has both setuid-root and"
-			" effective capabilities. Therefore not raising all"
-			" capabilities.\n", fname);
-		warned = 1;
-	}
+	pr_info_once("warning: `%s' has both setuid-root and effective capabilities, therefore not raising all capabilities\n",
+		     fname);
 }
 
 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
@@ -448,8 +445,8 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_c
 	rc = get_vfs_caps_from_disk(dentry, &vcaps);
 	if (rc < 0) {
 		if (rc == -EINVAL)
-			printk(KERN_NOTICE "%s: get_vfs_caps_from_disk returned %d for %s\n",
-				__func__, rc, bprm->filename);
+			pr_notice("%s: get_vfs_caps_from_disk returned %d for %s\n",
+				  __func__, rc, bprm->filename);
 		else if (rc == -ENODATA)
 			rc = 0;
 		goto out;
@@ -457,8 +454,8 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_c
 
 	rc = bprm_caps_from_vfs_caps(&vcaps, bprm, effective, has_cap);
 	if (rc == -EINVAL)
-		printk(KERN_NOTICE "%s: cap_from_disk returned %d for %s\n",
-		       __func__, rc, bprm->filename);
+		pr_notice("%s: cap_from_disk returned %d for %s\n",
+			  __func__, rc, bprm->filename);
 
 out:
 	dput(dentry);
security/security.c +3 -1
index 15b6928..53d1885 100644
@@ -11,6 +11,8 @@
  *	(at your option) any later version.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/capability.h>
 #include <linux/dcache.h>
 #include <linux/module.h>
@@ -64,7 +66,7 @@ static void __init do_security_initcalls(void)
  */
 int __init security_init(void)
 {
-	printk(KERN_INFO "Security Framework initialized\n");
+	pr_info("Security Framework initialized\n");
 
 	security_fixup_ops(&default_security_ops);
 	security_ops = &default_security_ops;
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
maintainer
#12 lore raw

Re: [PATCH 5/8] security: selinux: Use a more current logging style

In reply to Joe Perches
Quoted 6 lines · Joe Perches

Convert printk to pr_<level>.
Add pr_fmt.
Coalesce formats, add missing space where appropriate. Standardize on one space after "SELinux: " prefix.

A few minor comments inline ...

security/selinux/avc.c line 18

Quoted 11 lines
security/selinux/avc.c +3 -0
index fc3e662..f9bb683 100644
@@ -13,6 +13,9 @@
  *	it under the terms of the GNU General Public License version 2,
  *	as published by the Free Software Foundation.
  */
+
+#define pr_fmt(fmt) "SELinux: " KBUILD_MODNAME ": " fmt
+

Wouldn't this result in "SELinux: selinux: ..."? If not great, if so, let's just specify "avc" the old fashioned way.

Quoted 9 lines
security/selinux/hooks.c +0 -0
index d07413d..49a4a3d 100644
 
 	/* Set the security state for the initial task. */
 	cred_init_security();
@@ -5976,9 +5958,9 @@ static __init int selinux_init(void)
 		panic("SELinux: Unable to register with kernel.\n");

security/selinux/hooks.c static __init int selinux_init(void) · line 5966

Quoted 10 lines
security/selinux/hooks.c +2 -2
 
 	if (selinux_enforcing)
-		printk(KERN_DEBUG "SELinux:  Starting in enforcing mode\n");
+		printk(KERN_DEBUG "SELinux: Starting in enforcing mode\n");
 	else
-		printk(KERN_DEBUG "SELinux:  Starting in permissive mode\n");
+		printk(KERN_DEBUG "SELinux: Starting in permissive mode\n");
 
 	return 0;
 }

What about using 'pr_fmt("...")' in the printks above? Seems like it would help with consistency.

security/selinux/hooks.c static void delayed_superblock_init(struct · line 5981

Quoted 13 lines
security/selinux/hooks.c +2 -2
@@ -5990,10 +5972,10 @@ static void delayed_superblock_init(struct
 super_block *sb, void *unused)
 
 void selinux_complete_init(void)
 {
-	printk(KERN_DEBUG "SELinux:  Completing initialization.\n");
+	printk(KERN_DEBUG "SELinux: Completing initialization\n");
 
 	/* Set up any superblocks initialized prior to the policy load. */
-	printk(KERN_DEBUG "SELinux:  Setting up existing superblocks.\n");
+	printk(KERN_DEBUG "SELinux: Setting up existing superblocks\n");
 	iterate_supers(delayed_superblock_init, NULL);
 }

Same.

Quoted 10 lines
security/selinux/hooks.c +1 -1
@@ -6055,7 +6037,7 @@ static int __init selinux_nf_ip_init(void)
 	if (!selinux_enabled)
 		goto out;
 
-	printk(KERN_DEBUG "SELinux:  Registering netfilter hooks\n");
+	printk(KERN_DEBUG "SELinux: Registering netfilter hooks\n");
 
 	err = nf_register_hooks(selinux_ipv4_ops, ARRAY_SIZE(selinux_ipv4_ops));
 	if (err)

security/selinux/hooks.c __initcall(selinux_nf_ip_init); · line 6061

Quoted 5 lines
security/selinux/hooks.c +1 -1
@@ -6076,7 +6058,7 @@ __initcall(selinux_nf_ip_init);
 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
 static void selinux_nf_ip_exit(void)
 {
-	printk(KERN_DEBUG "SELinux:  Unregistering netfilter hooks\n");
+	printk(KERN_DEBUG "SELinux: Unregistering netfilter hooks\n");

Same.

security/selinux/netport.c line 17

Quoted 12 lines
security/selinux/netport.c +0 -1
index d353797..20a4ed0 100644
@@ -12,7 +12,6 @@
  *   (see security/selinux/netif.c for more information)
  *
  */
-
 /*
  * (c) Copyright Hewlett-Packard Development Company, L.P., 2008
  *

Whitespace noise.

Quoted 18 lines
security/selinux/ss/policydb.c +2 -1
index c0f4988..ff9e193 100644
@@ -25,6 +25,8 @@
  *	the Free Software Foundation, version 2.
  */
 
+#define pr_fmt(fmt) "SELinux: " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
@@ -515,14 +517,14 @@ static int policydb_index(struct policydb *p)
 {
 	int i, rc;
 
-	printk(KERN_DEBUG "SELinux:  %d users, %d roles, %d types, %d bools",

security/selinux/ss/policydb.c static int policydb_index(struct policydb *p) · line 528

Quoted 10 lines
security/selinux/ss/policydb.c +2 -1
+	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(", %d sens, %d cats", p->p_levels.nprim,
 		       p->p_cats.nprim);
 	printk("\n");
 
-	printk(KERN_DEBUG "SELinux:  %d classes, %d rules\n",
+	printk(KERN_DEBUG "SELinux: %d classes, %d rules\n",
 	       p->p_classes.nprim, p->te_avtab.nel);

More potential 'pr_fmt(x)' uses ...

Signature · 2 lines
paul moore
www.paul-moore.com
#13 lore raw

Re: [PATCH 5/8] security: selinux: Use a more current logging style

Quoted 11 lines · Paul Moore
Quoted 6 lines · Joe Perches

Convert printk to pr_<level>.
Add pr_fmt.
Coalesce formats, add missing space where appropriate. Standardize on one space after "SELinux: " prefix.

A few minor comments inline ...

security/selinux/avc.c

Quoted 1 line
security/selinux/avc.c +0 -0

[]

Quoted 10 lines

security/selinux/avc.c line 18

Quoted 7 lines
security/selinux/avc.c +3 -0
@@ -13,6 +13,9 @@
  *	it under the terms of the GNU General Public License version 2,
  *	as published by the Free Software Foundation.
  */
+
+#define pr_fmt(fmt) "SELinux: " KBUILD_MODNAME ": " fmt
+

Wouldn't this result in "SELinux: selinux: ..."? If not great, if so, let's just specify "avc" the old fashioned way.

Yup, you're right. Thanks. I stuffed that one up.

$ strings security/selinux/avc.o | grep "^[0-6]"
4SELinux: selinux: seqno %d < latest_notif %d

I'll send a v2.

Quoted 1 line

security/selinux/hooks.c

Quoted 1 line
security/selinux/hooks.c +0 -0

[]

Quoted 9 lines

security/selinux/hooks.c static __init int selinux_init(void) · line 5963

Quoted 9 lines
security/selinux/hooks.c +2 -2
@@ -5976,9 +5958,9 @@ static __init int selinux_init(void)
 		panic("SELinux: Unable to register with kernel.\n");
 
 	if (selinux_enforcing)
-		printk(KERN_DEBUG "SELinux:  Starting in enforcing mode\n");
+		printk(KERN_DEBUG "SELinux: Starting in enforcing mode\n");
 	else
-		printk(KERN_DEBUG "SELinux:  Starting in permissive mode\n");
+		printk(KERN_DEBUG "SELinux: Starting in permissive mode\n");

These printks should/will be converted to pr_debug in a separate patch. I didn't want to mix these conversions with the other pr_<level> ones.

maintainer Acked-by on v1 2/8
#6 lore raw

Re: [PATCH 2/8] security: apparmor: Use a more current logging style

In reply to Joe Perches
Quoted 5 lines · Joe Perches

Convert printks to pr_<level>.
Add pr_fmt.
Coalesce formats.
Remove embedded prefixes from logging.

you missed one place,

security/apparmor/include/apparmor.h +1 -1
@@ -50,7 +50,7 @@ extern unsigned int aa_g_path_max;
 #define AA_DEBUG(fmt, args...)                                         \
        do {                                                            \
                if (aa_g_debug && printk_ratelimit())                   \
-                       printk(KERN_DEBUG "AppArmor: " fmt, ##args);    \
+                       pr_debug(fmt, ##args);                          \
        } while (0)
 
 #define AA_ERROR(fmt, args...)                                         \

other than that looks good.

Quoted 1 line
Quoted 135 lines
---
 security/apparmor/apparmorfs.c       | 2 ++
 security/apparmor/crypto.c           | 2 ++
 security/apparmor/include/apparmor.h | 2 +-
 security/apparmor/lib.c              | 4 +++-
 security/apparmor/lsm.c              | 2 ++
 security/apparmor/match.c            | 5 +++--
 security/apparmor/policy.c           | 2 ++
 security/apparmor/procattr.c         | 2 ++
 8 files changed, 17 insertions(+), 4 deletions(-)
security/apparmor/apparmorfs.c +2 -0
index 7db9954..d4b65cc 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/ctype.h>
 #include <linux/security.h>
 #include <linux/vmalloc.h>
security/apparmor/crypto.c +2 -0
index 532471d..9506544 100644
@@ -15,6 +15,8 @@
  * it should be.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <crypto/hash.h>
 
 #include "include/apparmor.h"
security/apparmor/include/apparmor.h +1 -1
index 8fb1488..3065025 100644
@@ -56,7 +56,7 @@ extern unsigned int aa_g_path_max;
 #define AA_ERROR(fmt, args...)						\
 	do {								\
 		if (printk_ratelimit())					\
-			printk(KERN_ERR "AppArmor: " fmt, ##args);	\
+			pr_err(fmt, ##args);				\
 	} while (0)
 
 /* Flag indicating whether initialization completed */
security/apparmor/lib.c +3 -1
index 6968992..432b1b6 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -73,7 +75,7 @@ void aa_info_message(const char *str)
 		aad.info = str;
 		aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL);
 	}
-	printk(KERN_INFO "AppArmor: %s\n", str);
+	pr_info("%s\n", str);
 }
 
 /**
security/apparmor/lsm.c +2 -0
index 9981000..49f0180 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/security.h>
 #include <linux/moduleparam.h>
 #include <linux/mm.h>
security/apparmor/match.c +3 -2
index 727eb42..688482a 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -140,8 +142,7 @@ static int verify_dfa(struct aa_dfa *dfa, int flags)
 			if (DEFAULT_TABLE(dfa)[i] >= state_count)
 				goto out;
 			if (base_idx(BASE_TABLE(dfa)[i]) + 255 >= trans_count) {
-				printk(KERN_ERR "AppArmor DFA next/check upper "
-				       "bounds error\n");
+				pr_err("DFA next/check upper bounds error\n");
 				goto out;
 			}
 		}
security/apparmor/policy.c +2 -0
index 705c287..4e20c1f 100644
@@ -73,6 +73,8 @@
  * FIXME: move profile lists to using rcu_lists
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
security/apparmor/procattr.c +2 -0
index b125acc..c105fc5 100644
@@ -12,6 +12,8 @@
  * License.
  */
 
+#define pr_fmt(fmt) "AppArmor: " fmt
+
 #include "include/apparmor.h"
 #include "include/context.h"
 #include "include/policy.h"
#7 lore raw

Re: [PATCH 2/8] security: apparmor: Use a more current logging style

Quoted 8 lines · John Johansen
Quoted 5 lines · Joe Perches

Convert printks to pr_<level>.
Add pr_fmt.
Coalesce formats.
Remove embedded prefixes from logging.

you missed one place,

No, not really.

pr_debug differs from printk(KERN_DEBUG in that pr_debug is only enabled with a #define DEBUG or CONFIG_DYNAMIC_DEBUG setting.

I did not want to convert any of the printks with KERN_DEBUG in this pass as that would change the message logging by requiring dynamic debugging be included in the CONFIG.

A subsequent pass converting these uses will be done if or after these initial patches are applied.

thanks, Joe

Quoted 16 lines
security/apparmor/include/apparmor.h +1 -1
@@ -50,7 +50,7 @@ extern unsigned int aa_g_path_max;
 #define AA_DEBUG(fmt, args...)                                         \
        do {                                                            \
                if (aa_g_debug && printk_ratelimit())                   \
-                       printk(KERN_DEBUG "AppArmor: " fmt, ##args);    \
+                       pr_debug(fmt, ##args);                          \
        } while (0)
 
 #define AA_ERROR(fmt, args...)                                         \

other than that looks good.

Quoted 1 line