uaccess.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/sched.h"
  6. #include "asm/uaccess.h"
  7. int copy_from_user_tt(void *to, const void __user *from, int n)
  8. {
  9. if(!access_ok_tt(VERIFY_READ, from, n))
  10. return(n);
  11. return(__do_copy_from_user(to, from, n, &current->thread.fault_addr,
  12. &current->thread.fault_catcher));
  13. }
  14. int copy_to_user_tt(void __user *to, const void *from, int n)
  15. {
  16. if(!access_ok_tt(VERIFY_WRITE, to, n))
  17. return(n);
  18. return(__do_copy_to_user(to, from, n, &current->thread.fault_addr,
  19. &current->thread.fault_catcher));
  20. }
  21. int strncpy_from_user_tt(char *dst, const char __user *src, int count)
  22. {
  23. int n;
  24. if(!access_ok_tt(VERIFY_READ, src, 1))
  25. return(-EFAULT);
  26. n = __do_strncpy_from_user(dst, src, count,
  27. &current->thread.fault_addr,
  28. &current->thread.fault_catcher);
  29. if(n < 0) return(-EFAULT);
  30. return(n);
  31. }
  32. int __clear_user_tt(void __user *mem, int len)
  33. {
  34. return(__do_clear_user(mem, len,
  35. &current->thread.fault_addr,
  36. &current->thread.fault_catcher));
  37. }
  38. int clear_user_tt(void __user *mem, int len)
  39. {
  40. if(!access_ok_tt(VERIFY_WRITE, mem, len))
  41. return(len);
  42. return(__do_clear_user(mem, len, &current->thread.fault_addr,
  43. &current->thread.fault_catcher));
  44. }
  45. int strnlen_user_tt(const void __user *str, int len)
  46. {
  47. return(__do_strnlen_user(str, len,
  48. &current->thread.fault_addr,
  49. &current->thread.fault_catcher));
  50. }
  51. /*
  52. * Overrides for Emacs so that we follow Linus's tabbing style.
  53. * Emacs will notice this stuff at the end of the file and automatically
  54. * adjust the settings for this buffer only. This must remain at the end
  55. * of the file.
  56. * ---------------------------------------------------------------------------
  57. * Local variables:
  58. * c-file-style: "linux"
  59. * End:
  60. */