Commit a1b5bcff authored by Yi Wang's avatar Yi Wang Committed by Greg Kroah-Hartman

audit: fix potential null dereference 'context->'

commit b305f7ed upstream.

The variable 'context->' may be null pointer when
kmalloc return null, so it's better to check it before using
to avoid null dereference.
Another one more thing this patch does is using kstrdup instead
of (kmalloc + strcpy), and signal a lost record via audit_log_lost.

Cc: # 4.11
Signed-off-by: default avatarYi Wang <>
Reviewed-by: default avatarJiang Biao <>
Reviewed-by: default avatarRichard Guy Briggs <>
Signed-off-by: default avatarPaul Moore <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent e5a16c6a
......@@ -1274,8 +1274,12 @@ static void show_special(struct audit_context *context, int *call_panic)
audit_log_format(ab, "name=");
audit_log_untrustedstring(ab, context->;
if (context-> {
audit_log_untrustedstring(ab, context->;
} else
audit_log_format(ab, "(null)");
......@@ -2387,8 +2391,9 @@ void __audit_log_kern_module(char *name)
struct audit_context *context = current->audit_context;
context-> = kmalloc(strlen(name) + 1, GFP_KERNEL);
strcpy(context->, name);
context-> = kstrdup(name, GFP_KERNEL);
if (!context->
audit_log_lost("out of memory in __audit_log_kern_module");
context->type = AUDIT_KERN_MODULE;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment