From: Eric Paris Subject: [PATCH 2/4] audit: do not audit actions during init module Date: Mon, 10 May 2010 14:23:07 -0400 Message-ID: <20100510182307.27102.12249.stgit@paris.rdu.redhat.com> References: <20100510182301.27102.29768.stgit@paris.rdu.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20100510182301.27102.29768.stgit@paris.rdu.redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: linux-audit@redhat.com Cc: viro@zeniv.linux.org.uk List-Id: linux-audit@redhat.com Module loading code can do anything it damn well pleases. At the moment we have examples where module loading code is creating lots of objects in debugfs and this is overflowing the number of inodes the audit system can keep track of. We can't really trust ANYTHING that happens during module loading so we might as well just not even try. Signed-off-by: Eric Paris --- kernel/module.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 8ae93db..380615d 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -55,6 +55,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -2521,6 +2522,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod, { struct module *mod; int ret = 0; + struct audit_context *audit_context; /* Must have permission */ if (!capable(CAP_SYS_MODULE) || modules_disabled) @@ -2530,10 +2532,18 @@ SYSCALL_DEFINE3(init_module, void __user *, umod, if (mutex_lock_interruptible(&module_mutex) != 0) return -EINTR; + /* + * Module loading can do anything it wants and if it is violent audit + * won't matter. So just don't even bother + */ + audit_context = current->audit_context; + current->audit_context = NULL; + /* Do all the hard work */ mod = load_module(umod, len, uargs); if (IS_ERR(mod)) { mutex_unlock(&module_mutex); + current->audit_context = audit_context; return PTR_ERR(mod); } @@ -2559,6 +2569,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod, free_module(mod); mutex_unlock(&module_mutex); wake_up(&module_wq); + current->audit_context = audit_context; return ret; } if (ret > 0) { @@ -2593,6 +2604,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod, mod->init_size = 0; mod->init_text_size = 0; mutex_unlock(&module_mutex); + current->audit_context = audit_context; return 0; }