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>
This commit is contained in:
Richard Guy Briggs 2014-01-27 17:38:42 -05:00 коммит произвёл Eric Paris
Родитель b7d3622a39
Коммит f952d10ff4
2 изменённых файлов: 22 добавлений и 21 удалений

Просмотреть файл

@ -19,6 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/kthread.h> #include <linux/kthread.h>
@ -247,7 +249,7 @@ static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule)
; ;
} }
if (unlikely(rule->action == AUDIT_POSSIBLE)) { if (unlikely(rule->action == AUDIT_POSSIBLE)) {
printk(KERN_ERR "AUDIT_POSSIBLE is deprecated\n"); pr_err("AUDIT_POSSIBLE is deprecated\n");
goto exit_err; goto exit_err;
} }
if (rule->action != AUDIT_NEVER && rule->action != AUDIT_ALWAYS) 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,
/* Keep currently invalid fields around in case they /* Keep currently invalid fields around in case they
* become valid after a policy reload. */ * become valid after a policy reload. */
if (err == -EINVAL) { if (err == -EINVAL) {
printk(KERN_WARNING "audit rule for LSM " pr_warn("audit rule for LSM \'%s\' is invalid\n",
"\'%s\' is invalid\n", str); str);
err = 0; err = 0;
} }
if (err) { if (err) {
@ -707,8 +709,8 @@ static inline int audit_dupe_lsm_field(struct audit_field *df,
/* Keep currently invalid fields around in case they /* Keep currently invalid fields around in case they
* become valid after a policy reload. */ * become valid after a policy reload. */
if (ret == -EINVAL) { if (ret == -EINVAL) {
printk(KERN_WARNING "audit rule for LSM \'%s\' is " pr_warn("audit rule for LSM \'%s\' is invalid\n",
"invalid\n", df->lsm_str); df->lsm_str);
ret = 0; ret = 0;
} }

Просмотреть файл

@ -42,6 +42,8 @@
* and <dustin.kirkland@us.ibm.com> for LSPP certification compliance. * and <dustin.kirkland@us.ibm.com> for LSPP certification compliance.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/init.h> #include <linux/init.h>
#include <asm/types.h> #include <asm/types.h>
#include <linux/atomic.h> #include <linux/atomic.h>
@ -850,16 +852,15 @@ static inline void audit_free_names(struct audit_context *context)
if (context->put_count + context->ino_count != context->name_count) { if (context->put_count + context->ino_count != context->name_count) {
int i = 0; int i = 0;
printk(KERN_ERR "%s:%d(:%d): major=%d in_syscall=%d" pr_err("%s:%d(:%d): major=%d in_syscall=%d"
" name_count=%d put_count=%d" " name_count=%d put_count=%d ino_count=%d"
" ino_count=%d [NOT freeing]\n", " [NOT freeing]\n", __FILE__, __LINE__,
__FILE__, __LINE__,
context->serial, context->major, context->in_syscall, context->serial, context->major, context->in_syscall,
context->name_count, context->put_count, context->name_count, context->put_count,
context->ino_count); context->ino_count);
list_for_each_entry(n, &context->names_list, list) { list_for_each_entry(n, &context->names_list, list) {
printk(KERN_ERR "names[%d] = %p = %s\n", i++, pr_err("names[%d] = %p = %s\n", i++, n->name,
n->name, n->name->name ?: "(null)"); n->name->name ?: "(null)");
} }
dump_stack(); dump_stack();
return; return;
@ -1550,7 +1551,7 @@ static inline void handle_one(const struct inode *inode)
if (likely(put_tree_ref(context, chunk))) if (likely(put_tree_ref(context, chunk)))
return; return;
if (unlikely(!grow_tree_refs(context))) { if (unlikely(!grow_tree_refs(context))) {
printk(KERN_WARNING "out of memory, audit has lost a tree reference\n"); pr_warn("out of memory, audit has lost a tree reference\n");
audit_set_auditable(context); audit_set_auditable(context);
audit_put_chunk(chunk); audit_put_chunk(chunk);
unroll_tree_refs(context, p, count); unroll_tree_refs(context, p, count);
@ -1609,8 +1610,7 @@ retry:
goto retry; goto retry;
} }
/* too bad */ /* too bad */
printk(KERN_WARNING pr_warn("out of memory, audit has lost a tree reference\n");
"out of memory, audit has lost a tree reference\n");
unroll_tree_refs(context, p, count); unroll_tree_refs(context, p, count);
audit_set_auditable(context); audit_set_auditable(context);
return; return;
@ -1682,7 +1682,7 @@ void __audit_getname(struct filename *name)
if (!context->in_syscall) { if (!context->in_syscall) {
#if AUDIT_DEBUG == 2 #if AUDIT_DEBUG == 2
printk(KERN_ERR "%s:%d(:%d): ignoring getname(%p)\n", pr_err("%s:%d(:%d): ignoring getname(%p)\n",
__FILE__, __LINE__, context->serial, name); __FILE__, __LINE__, context->serial, name);
dump_stack(); dump_stack();
#endif #endif
@ -1721,15 +1721,15 @@ void audit_putname(struct filename *name)
BUG_ON(!context); BUG_ON(!context);
if (!context->in_syscall) { if (!context->in_syscall) {
#if AUDIT_DEBUG == 2 #if AUDIT_DEBUG == 2
printk(KERN_ERR "%s:%d(:%d): final_putname(%p)\n", pr_err("%s:%d(:%d): final_putname(%p)\n",
__FILE__, __LINE__, context->serial, name); __FILE__, __LINE__, context->serial, name);
if (context->name_count) { if (context->name_count) {
struct audit_names *n; struct audit_names *n;
int i = 0; int i = 0;
list_for_each_entry(n, &context->names_list, list) list_for_each_entry(n, &context->names_list, list)
printk(KERN_ERR "name[%d] = %p = %s\n", i++, pr_err("name[%d] = %p = %s\n", i++, n->name,
n->name, n->name->name ?: "(null)"); n->name->name ?: "(null)");
} }
#endif #endif
final_putname(name); final_putname(name);
@ -1738,9 +1738,8 @@ void audit_putname(struct filename *name)
else { else {
++context->put_count; ++context->put_count;
if (context->put_count > context->name_count) { if (context->put_count > context->name_count) {
printk(KERN_ERR "%s:%d(:%d): major=%d" pr_err("%s:%d(:%d): major=%d in_syscall=%d putname(%p)"
" in_syscall=%d putname(%p) name_count=%d" " name_count=%d put_count=%d\n",
" put_count=%d\n",
__FILE__, __LINE__, __FILE__, __LINE__,
context->serial, context->major, context->serial, context->major,
context->in_syscall, name->name, context->in_syscall, name->name,