~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/um/sys-i386/ldt.c

Version: ~ [ linux-5.1-rc1 ] ~ [ linux-5.0.3 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.30 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.107 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.164 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.176 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.136 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.63 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
  3  * Licensed under the GPL
  4  */
  5 
  6 #include "linux/config.h"
  7 #include "linux/slab.h"
  8 #include "asm/uaccess.h"
  9 #include "asm/ptrace.h"
 10 #include "choose-mode.h"
 11 #include "kern.h"
 12 
 13 #ifdef CONFIG_MODE_TT
 14 extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
 15 
 16 int sys_modify_ldt_tt(int func, void *ptr, unsigned long bytecount)
 17 {
 18         if(verify_area(VERIFY_READ, ptr, bytecount)) return(-EFAULT);
 19         return(modify_ldt(func, ptr, bytecount));
 20 }
 21 #endif
 22 
 23 #ifdef CONFIG_MODE_SKAS
 24 extern int userspace_pid;
 25 
 26 int sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount)
 27 {
 28         struct ptrace_ldt ldt;
 29         void *buf;
 30         int res, n;
 31 
 32         buf = kmalloc(bytecount, GFP_KERNEL);
 33         if(buf == NULL)
 34                 return(-ENOMEM);
 35 
 36         res = 0;
 37 
 38         switch(func){
 39         case 1:
 40         case 0x11:
 41                 res = copy_from_user(buf, ptr, bytecount);
 42                 break;
 43         }
 44 
 45         if(res != 0){
 46                 res = -EFAULT;
 47                 goto out;
 48         }
 49 
 50         ldt = ((struct ptrace_ldt) { .func      = func,
 51                                      .ptr       = buf,
 52                                      .bytecount = bytecount });
 53         res = ptrace(PTRACE_LDT, userspace_pid, 0, (unsigned long) &ldt);
 54         if(res < 0)
 55                 goto out;
 56 
 57         switch(func){
 58         case 0:
 59         case 2:
 60                 n = res;
 61                 res = copy_to_user(ptr, buf, n);
 62                 if(res != 0)
 63                         res = -EFAULT;
 64                 else 
 65                         res = n;
 66                 break;
 67         }
 68 
 69  out:
 70         kfree(buf);
 71         return(res);
 72 }
 73 #endif
 74 
 75 int sys_modify_ldt(int func, void *ptr, unsigned long bytecount)
 76 {
 77         return(CHOOSE_MODE_PROC(sys_modify_ldt_tt, sys_modify_ldt_skas, func, 
 78                                 ptr, bytecount));
 79 }
 80 
 81 
 82 
 83 /*
 84  * Overrides for Emacs so that we follow Linus's tabbing style.
 85  * Emacs will notice this stuff at the end of the file and automatically
 86  * adjust the settings for this buffer only.  This must remain at the end
 87  * of the file.
 88  * ---------------------------------------------------------------------------
 89  * Local variables:
 90  * c-file-style: "linux"
 91  * End:
 92  */
 93 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp