提交 f5561964 编写于 作者: D David Woodhouse

AUDIT: Avoid scheduling in idle thread

When we flush a pending syscall audit record due to audit_free(), we
might be doing that in the context of the idle thread. So use GFP_ATOMIC
Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
上级 582edda5
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/time.h> #include <linux/time.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/compiler.h>
#include <asm/unistd.h> #include <asm/unistd.h>
/* 0 = no checking /* 0 = no checking
...@@ -778,13 +779,13 @@ static void audit_log_task_info(struct audit_buffer *ab) ...@@ -778,13 +779,13 @@ static void audit_log_task_info(struct audit_buffer *ab)
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
} }
static void audit_log_exit(struct audit_context *context) static void audit_log_exit(struct audit_context *context, unsigned int gfp_mask)
{ {
int i; int i;
struct audit_buffer *ab; struct audit_buffer *ab;
struct audit_aux_data *aux; struct audit_aux_data *aux;
ab = audit_log_start(context, GFP_KERNEL, AUDIT_SYSCALL); ab = audit_log_start(context, gfp_mask, AUDIT_SYSCALL);
if (!ab) if (!ab)
return; /* audit_panic has been called */ return; /* audit_panic has been called */
audit_log_format(ab, "arch=%x syscall=%d", audit_log_format(ab, "arch=%x syscall=%d",
...@@ -900,9 +901,11 @@ void audit_free(struct task_struct *tsk) ...@@ -900,9 +901,11 @@ void audit_free(struct task_struct *tsk)
return; return;
/* Check for system calls that do not go through the exit /* Check for system calls that do not go through the exit
* function (e.g., exit_group), then free context block. */ * function (e.g., exit_group), then free context block.
* We use GFP_ATOMIC here because we might be doing this
* in the context of the idle thread */
if (context->in_syscall && context->auditable) if (context->in_syscall && context->auditable)
audit_log_exit(context); audit_log_exit(context, GFP_ATOMIC);
audit_free_context(context); audit_free_context(context);
} }
...@@ -1007,7 +1010,7 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code) ...@@ -1007,7 +1010,7 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code)
return; return;
if (context->in_syscall && context->auditable) if (context->in_syscall && context->auditable)
audit_log_exit(context); audit_log_exit(context, GFP_KERNEL);
context->in_syscall = 0; context->in_syscall = 0;
context->auditable = 0; context->auditable = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册