aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Baron <jbaron@redhat.com>2006-01-31 16:56:28 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2006-03-20 14:08:53 -0500
commit7e7f8a036b8e2b2a300df016da5e7128c8a9192e (patch)
treeb3681a073f4ef97a91f53d4b23d0c5aeccbe4993
parent7705a8792b0fc82fd7d4dd923724606bbfd9fb20 (diff)
[PATCH] make vm86 call audit_syscall_exit
hi, The motivation behind the patch below was to address messages in /var/log/messages such as: Jan 31 10:54:15 mets kernel: audit(:0): major=252 name_count=0: freeing multiple contexts (1) Jan 31 10:54:15 mets kernel: audit(:0): major=113 name_count=0: freeing multiple contexts (2) I can reproduce by running 'get-edid' from: http://john.fremlin.de/programs/linux/read-edid/. These messages come about in the log b/c the vm86 calls do not exit via the normal system call exit paths and thus do not call 'audit_syscall_exit'. The next system call will then free the context for itself and for the vm86 context, thus generating the above messages. This patch addresses the issue by simply adding a call to 'audit_syscall_exit' from the vm86 code. Besides fixing the above error messages the patch also now allows vm86 system calls to become auditable. This is useful since strace does not appear to properly record the return values from sys_vm86. I think this patch is also a step in the right direction in terms of cleaning up some core auditing code. If we can correct any other paths that do not properly call the audit exit and entries points, then we can also eliminate the notion of context chaining. I've tested this patch by verifying that the log messages no longer appear, and that the audit records for sys_vm86 appear to be correct. Also, 'read_edid' produces itentical output. thanks, -Jason Signed-off-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/i386/kernel/vm86.c12
-rw-r--r--kernel/auditsc.c5
2 files changed, 10 insertions, 7 deletions
diff --git a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
index f51c894a7da5..aee14fafd13d 100644
--- a/arch/i386/kernel/vm86.c
+++ b/arch/i386/kernel/vm86.c
@@ -43,6 +43,7 @@
43#include <linux/smp_lock.h> 43#include <linux/smp_lock.h>
44#include <linux/highmem.h> 44#include <linux/highmem.h>
45#include <linux/ptrace.h> 45#include <linux/ptrace.h>
46#include <linux/audit.h>
46 47
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48#include <asm/io.h> 49#include <asm/io.h>
@@ -252,6 +253,7 @@ out:
252static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk) 253static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk)
253{ 254{
254 struct tss_struct *tss; 255 struct tss_struct *tss;
256 long eax;
255/* 257/*
256 * make sure the vm86() system call doesn't try to do anything silly 258 * make sure the vm86() system call doesn't try to do anything silly
257 */ 259 */
@@ -305,13 +307,19 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
305 tsk->thread.screen_bitmap = info->screen_bitmap; 307 tsk->thread.screen_bitmap = info->screen_bitmap;
306 if (info->flags & VM86_SCREEN_BITMAP) 308 if (info->flags & VM86_SCREEN_BITMAP)
307 mark_screen_rdonly(tsk->mm); 309 mark_screen_rdonly(tsk->mm);
310 __asm__ __volatile__("xorl %eax,%eax; movl %eax,%fs; movl %eax,%gs\n\t");
311 __asm__ __volatile__("movl %%eax, %0\n" :"=r"(eax));
312
313 /*call audit_syscall_exit since we do not exit via the normal paths */
314 if (unlikely(current->audit_context))
315 audit_syscall_exit(current, AUDITSC_RESULT(eax), eax);
316
308 __asm__ __volatile__( 317 __asm__ __volatile__(
309 "xorl %%eax,%%eax; movl %%eax,%%fs; movl %%eax,%%gs\n\t"
310 "movl %0,%%esp\n\t" 318 "movl %0,%%esp\n\t"
311 "movl %1,%%ebp\n\t" 319 "movl %1,%%ebp\n\t"
312 "jmp resume_userspace" 320 "jmp resume_userspace"
313 : /* no outputs */ 321 : /* no outputs */
314 :"r" (&info->regs), "r" (task_thread_info(tsk)) : "ax"); 322 :"r" (&info->regs), "r" (task_thread_info(tsk)));
315 /* we never return here */ 323 /* we never return here */
316} 324}
317 325
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index d7e7e637b92a..cfaa4a277f08 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -966,11 +966,6 @@ void audit_syscall_entry(struct task_struct *tsk, int arch, int major,
966 if (context->in_syscall) { 966 if (context->in_syscall) {
967 struct audit_context *newctx; 967 struct audit_context *newctx;
968 968
969#if defined(__NR_vm86) && defined(__NR_vm86old)
970 /* vm86 mode should only be entered once */
971 if (major == __NR_vm86 || major == __NR_vm86old)
972 return;
973#endif
974#if AUDIT_DEBUG 969#if AUDIT_DEBUG
975 printk(KERN_ERR 970 printk(KERN_ERR
976 "audit(:%d) pid=%d in syscall=%d;" 971 "audit(:%d) pid=%d in syscall=%d;"