Skip to contentSkip to conversation

UML - skas0 stubs now check system call return values

PATCH In review Jeff Dike 1 participant 1 message Sep 1, 2005 User-mode Linux (UML)

lore
Share & tools
lore

Jeff Dike

author
#0 lore raw

PATCH 9/12 UML - skas0 stubs now check system call return values

From: Bodo Stroesser <[email protected]>

Change syscall-stub's data to include a "expected retval". Stub now checks syscalls retval and aborts execution of syscall list, if retval != expected retval. run_syscall_stub prints the data of the failed syscall, using the data pointer and retval written by the stub to the beginning of the stack.
one_syscall_stub is removed, to simplify code, because only some instructions are saved by one_syscall_stub, no host-syscall.
Using the stub with additional data (modify_ldt via stub) is prepared also.

arch/um/include/tlb.h +3 -3
Index: test/arch/um/include/tlb.h
===================================================================
@@ -38,9 +38,9 @@
 extern void force_flush_all(void);
 extern void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
                              unsigned long end_addr, int force,
-			     void *(*do_ops)(union mm_context *,
-					     struct host_vm_op *, int, int,
-					     void *));
+			     int (*do_ops)(union mm_context *, 
+					   struct host_vm_op *, int, int,
+					   void **));
 extern int flush_tlb_kernel_range_common(unsigned long start,
 					 unsigned long end);
 
arch/um/kernel/skas/include/skas.h +14 -19
Index: test/arch/um/kernel/skas/include/skas.h
===================================================================
@@ -24,14 +24,14 @@
 extern void remove_sigstack(void);
 extern void new_thread_handler(int sig);
 extern void handle_syscall(union uml_pt_regs *regs);
-extern void *map(struct mm_id * mm_idp, unsigned long virt,
-		 unsigned long len, int r, int w, int x, int phys_fd,
-		 unsigned long long offset, int done, void *data);
-extern void *unmap(struct mm_id * mm_idp, void *addr,
-		   unsigned long len, int done, void *data);
-extern void *protect(struct mm_id * mm_idp, unsigned long addr,
-		     unsigned long len, int r, int w, int x, int done,
-		     void *data);
+extern int map(struct mm_id * mm_idp, unsigned long virt,
+	       unsigned long len, int r, int w, int x, int phys_fd, 
+	       unsigned long long offset, int done, void **data);
+extern int unmap(struct mm_id * mm_idp, void *addr, unsigned long len,
+		 int done, void **data);
+extern int protect(struct mm_id * mm_idp, unsigned long addr,
+		   unsigned long len, int r, int w, int x, int done, 
+		   void **data);
 extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
 extern int new_mm(int from, unsigned long stack);
 extern int start_userspace(unsigned long stub_stack);
@@ -39,16 +39,11 @@
 extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
 extern long execute_syscall_skas(void *r);
 extern unsigned long current_stub_stack(void);
+extern long run_syscall_stub(struct mm_id * mm_idp,
+                             int syscall, unsigned long *args, long expected,
+                             void **addr, int done);
+extern long syscall_stub_data(struct mm_id * mm_idp,
+                              unsigned long *data, int data_count,
+                              void **addr, void **stub_addr);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
arch/um/kernel/skas/mem_user.c +141 -99

342 lines not on this page · raw message

arch/um/kernel/skas/tlb.c +16 -15
Index: test/arch/um/kernel/skas/tlb.c
===================================================================
@@ -18,30 +18,31 @@
 #include "os.h"
 #include "tlb.h"
 
-static void *do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
-		    int finished, void *flush)
+static int do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
+		  int finished, void **flush)
 {
 	struct host_vm_op *op;
-	int i;
+        int i, ret = 0;
 
-	for(i = 0; i <= last; i++){
+        for(i = 0; i <= last && !ret; i++){
 		op = &ops[i];
 		switch(op->type){
 		case MMAP:
-			flush = map(&mmu->skas.id, op->u.mmap.addr,
-				    op->u.mmap.len, op->u.mmap.r, op->u.mmap.w,
-				    op->u.mmap.x, op->u.mmap.fd,
-				    op->u.mmap.offset, finished, flush);
+			ret = map(&mmu->skas.id, op->u.mmap.addr, 
+				  op->u.mmap.len, op->u.mmap.r, op->u.mmap.w,
+				  op->u.mmap.x, op->u.mmap.fd,
+				  op->u.mmap.offset, finished, flush);
 			break;
 		case MUNMAP:
-			flush = unmap(&mmu->skas.id, (void *) op->u.munmap.addr,
-				      op->u.munmap.len, finished, flush);
+			ret = unmap(&mmu->skas.id, 
+				    (void *) op->u.munmap.addr,
+				    op->u.munmap.len, finished, flush);
 			break;
 		case MPROTECT:
-			flush = protect(&mmu->skas.id, op->u.mprotect.addr,
-					op->u.mprotect.len, op->u.mprotect.r,
-					op->u.mprotect.w, op->u.mprotect.x,
-					finished, flush);
+			ret = protect(&mmu->skas.id, op->u.mprotect.addr,
+				      op->u.mprotect.len, op->u.mprotect.r, 
+				      op->u.mprotect.w, op->u.mprotect.x, 
+				      finished, flush);
 			break;
 		default:
 			printk("Unknown op type %d in do_ops\n", op->type);
@@ -49,7 +50,7 @@
 		}
 	}
 
-	return flush;
+	return ret;
 }
 
 extern int proc_mm;
arch/um/kernel/tlb.c +88 -77

265 lines not on this page · raw message

arch/um/kernel/tt/tlb.c +16 -11
Index: test/arch/um/kernel/tt/tlb.c
===================================================================
@@ -17,26 +17,31 @@
 #include "os.h"
 #include "tlb.h"
 
-static void *do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
-		    int finished, void *flush)
+static int do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
+		    int finished, void **flush)
 {
 	struct host_vm_op *op;
-	int i;
+        int i, ret=0;
 
-	for(i = 0; i <= last; i++){
+        for(i = 0; i <= last && !ret; i++){
 		op = &ops[i];
 		switch(op->type){
 		case MMAP:
-                        os_map_memory((void *) op->u.mmap.addr, op->u.mmap.fd,
-				      op->u.mmap.offset, op->u.mmap.len,
-				      op->u.mmap.r, op->u.mmap.w,
-				      op->u.mmap.x);
+                        ret = os_map_memory((void *) op->u.mmap.addr,
+                                            op->u.mmap.fd, op->u.mmap.offset,
+                                            op->u.mmap.len, op->u.mmap.r,
+                                            op->u.mmap.w, op->u.mmap.x);
 			break;
 		case MUNMAP:
-			os_unmap_memory((void *) op->u.munmap.addr,
-					op->u.munmap.len);
+                        ret = os_unmap_memory((void *) op->u.munmap.addr, 
+                                              op->u.munmap.len);
 			break;
 		case MPROTECT:
+                        ret = protect_memory(op->u.mprotect.addr,
+                                             op->u.munmap.len, 
+                                             op->u.mprotect.r,
+                                             op->u.mprotect.w, 
+                                             op->u.mprotect.x, 1);
 			protect_memory(op->u.mprotect.addr, op->u.munmap.len,
 				       op->u.mprotect.r, op->u.mprotect.w,
 				       op->u.mprotect.x, 1);
@@ -47,7 +52,7 @@
 		}
 	}
 
-	return NULL;
+	return ret;
 }
 
 static void fix_range(struct mm_struct *mm, unsigned long start_addr, 
arch/um/sys-i386/stub.S +34 -8

58 lines not on this page · raw message

arch/um/sys-x86_64/stub.S +40 -10

61 lines not on this page · raw message

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel