Skip to content

Commit f952d10

Browse files
rgbriggseparis
authored andcommitted
audit: Use more current logging style again
Add pr_fmt to prefix "audit: " to output Convert printk(KERN_<LEVEL> to pr_<level> Coalesce formats Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
1 parent b7d3622 commit f952d10

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

‎kernel/auditfilter.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2020
*/
2121

22+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23+
2224
#include <linux/kernel.h>
2325
#include <linux/audit.h>
2426
#include <linux/kthread.h>
@@ -247,7 +249,7 @@ static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule)
247249
;
248250
}
249251
if (unlikely(rule->action == AUDIT_POSSIBLE)) {
250-
printk(KERN_ERR "AUDIT_POSSIBLE is deprecated\n");
252+
pr_err("AUDIT_POSSIBLE is deprecated\n");
251253
goto exit_err;
252254
}
253255
if (rule->action != AUDIT_NEVER && rule->action != AUDIT_ALWAYS)
@@ -477,8 +479,8 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
477479
/* Keep currently invalid fields around in case they
478480
* become valid after a policy reload. */
479481
if (err == -EINVAL) {
480-
printk(KERN_WARNING "audit rule for LSM "
481-
"\'%s\' is invalid\n", str);
482+
pr_warn("audit rule for LSM \'%s\' is invalid\n",
483+
str);
482484
err = 0;
483485
}
484486
if (err) {
@@ -707,8 +709,8 @@ static inline int audit_dupe_lsm_field(struct audit_field *df,
707709
/* Keep currently invalid fields around in case they
708710
* become valid after a policy reload. */
709711
if (ret == -EINVAL) {
710-
printk(KERN_WARNING "audit rule for LSM \'%s\' is "
711-
"invalid\n", df->lsm_str);
712+
pr_warn("audit rule for LSM \'%s\' is invalid\n",
713+
df->lsm_str);
712714
ret = 0;
713715
}
714716

‎kernel/auditsc.c‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
* and <dustin.kirkland@us.ibm.com> for LSPP certification compliance.
4343
*/
4444

45+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
46+
4547
#include <linux/init.h>
4648
#include <asm/types.h>
4749
#include <linux/atomic.h>
@@ -850,16 +852,15 @@ static inline void audit_free_names(struct audit_context *context)
850852
if (context->put_count + context->ino_count != context->name_count) {
851853
int i = 0;
852854

853-
printk(KERN_ERR "%s:%d(:%d): major=%d in_syscall=%d"
854-
" name_count=%d put_count=%d"
855-
" ino_count=%d [NOT freeing]\n",
856-
__FILE__, __LINE__,
855+
pr_err("%s:%d(:%d): major=%d in_syscall=%d"
856+
" name_count=%d put_count=%d ino_count=%d"
857+
" [NOT freeing]\n", __FILE__, __LINE__,
857858
context->serial, context->major, context->in_syscall,
858859
context->name_count, context->put_count,
859860
context->ino_count);
860861
list_for_each_entry(n, &context->names_list, list) {
861-
printk(KERN_ERR "names[%d] = %p = %s\n", i++,
862-
n->name, n->name->name ?: "(null)");
862+
pr_err("names[%d] = %p = %s\n", i++, n->name,
863+
n->name->name ?: "(null)");
863864
}
864865
dump_stack();
865866
return;
@@ -1550,7 +1551,7 @@ static inline void handle_one(const struct inode *inode)
15501551
if (likely(put_tree_ref(context, chunk)))
15511552
return;
15521553
if (unlikely(!grow_tree_refs(context))) {
1553-
printk(KERN_WARNING "out of memory, audit has lost a tree reference\n");
1554+
pr_warn("out of memory, audit has lost a tree reference\n");
15541555
audit_set_auditable(context);
15551556
audit_put_chunk(chunk);
15561557
unroll_tree_refs(context, p, count);
@@ -1609,8 +1610,7 @@ static void handle_path(const struct dentry *dentry)
16091610
goto retry;
16101611
}
16111612
/* too bad */
1612-
printk(KERN_WARNING
1613-
"out of memory, audit has lost a tree reference\n");
1613+
pr_warn("out of memory, audit has lost a tree reference\n");
16141614
unroll_tree_refs(context, p, count);
16151615
audit_set_auditable(context);
16161616
return;
@@ -1682,7 +1682,7 @@ void __audit_getname(struct filename *name)
16821682

16831683
if (!context->in_syscall) {
16841684
#if AUDIT_DEBUG == 2
1685-
printk(KERN_ERR "%s:%d(:%d): ignoring getname(%p)\n",
1685+
pr_err("%s:%d(:%d): ignoring getname(%p)\n",
16861686
__FILE__, __LINE__, context->serial, name);
16871687
dump_stack();
16881688
#endif
@@ -1721,15 +1721,15 @@ void audit_putname(struct filename *name)
17211721
BUG_ON(!context);
17221722
if (!context->in_syscall) {
17231723
#if AUDIT_DEBUG == 2
1724-
printk(KERN_ERR "%s:%d(:%d): final_putname(%p)\n",
1724+
pr_err("%s:%d(:%d): final_putname(%p)\n",
17251725
__FILE__, __LINE__, context->serial, name);
17261726
if (context->name_count) {
17271727
struct audit_names *n;
17281728
int i = 0;
17291729

17301730
list_for_each_entry(n, &context->names_list, list)
1731-
printk(KERN_ERR "name[%d] = %p = %s\n", i++,
1732-
n->name, n->name->name ?: "(null)");
1731+
pr_err("name[%d] = %p = %s\n", i++, n->name,
1732+
n->name->name ?: "(null)");
17331733
}
17341734
#endif
17351735
final_putname(name);
@@ -1738,9 +1738,8 @@ void audit_putname(struct filename *name)
17381738
else {
17391739
++context->put_count;
17401740
if (context->put_count > context->name_count) {
1741-
printk(KERN_ERR "%s:%d(:%d): major=%d"
1742-
" in_syscall=%d putname(%p) name_count=%d"
1743-
" put_count=%d\n",
1741+
pr_err("%s:%d(:%d): major=%d in_syscall=%d putname(%p)"
1742+
" name_count=%d put_count=%d\n",
17441743
__FILE__, __LINE__,
17451744
context->serial, context->major,
17461745
context->in_syscall, name->name,

0 commit comments

Comments
 (0)