ssp-internal.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Distributed under the terms of the GNU Lesser General Public License
  3. * $Header: $
  4. */
  5. #ifndef _SSP_INTERNAL_H
  6. #define _SSP_INTERNAL_H 1
  7. #ifdef __SSP__
  8. #error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector"
  9. #endif
  10. #ifdef __PROPOLICE_BLOCK_SEGV__
  11. # define SSP_SIGTYPE SIGSEGV
  12. #else
  13. # define SSP_SIGTYPE SIGABRT
  14. #endif
  15. #include <sys/types.h>
  16. #include <sys/time.h>
  17. #include <signal.h>
  18. #include <linux/unistd.h>
  19. #ifdef __SSP_USE_ERANDOM__
  20. # include <sys/sysctl.h>
  21. #if 1
  22. # define SYSCTL __sysctl
  23. #else
  24. #define __NR__kernel_sysctl __NR_sysctl
  25. static __always_inline _syscall6(int,__kernel_sysctl,int *,name,int,nlen,void *,oldval,size_t *,oldlenp,void *,newval,size_t,newlen);
  26. #define SYSCTL(name,nlen,oldval,oldlenp,newval,newlen) __kernel_sysctl(name,nlen,oldval,oldlenp,newval,newlen)
  27. #endif
  28. #endif
  29. #ifndef __SSP_QUICK_CANARY__
  30. #define __NR___kernel_open __NR_open
  31. static __always_inline _syscall2(int,__kernel_open,const char *,path,int,flags);
  32. #define OPEN(path, flags) __kernel_open(path, flags)
  33. /* void * = __ptr_t */
  34. #define __NR___kernel_read __NR_read
  35. static __always_inline _syscall3(ssize_t,__kernel_read,int,fd,void *,buf,size_t,count);
  36. #define READ(fd, buf, count) __kernel_read(fd, buf, count)
  37. #define __NR___kernel_close __NR_close
  38. static __always_inline _syscall1(int,__kernel_close,int,fd);
  39. #define CLOSE(fd) __kernel_close(fd)
  40. #endif
  41. /* const void * = const __ptr_t */
  42. #define __NR___kernel_write __NR_write
  43. static __always_inline _syscall3(ssize_t,__kernel_write,int,fd,const void *,buf,size_t,count);
  44. #define WRITE(fd, buf, count) __kernel_write(fd, buf, count)
  45. /* not using __NR_ */
  46. #define __NR___kernel_gettimeofday __NR_gettimeofday
  47. static __always_inline _syscall2(int,__kernel_gettimeofday,struct timeval *,tv,struct timezone *,tz);
  48. #define GETTIMEOFDAY(tv, tz) __kernel_gettimeofday(tv, tz)
  49. #define __NR___kernel_getpid __NR_getpid
  50. static __always_inline _syscall0(pid_t,__kernel_getpid);
  51. #define GETPID() __kernel_getpid()
  52. //#ifdef __NR_rt_sigaction
  53. //#define __NR___kernel_sigaction __NR_rt_sigaction
  54. //static __always_inline _syscall4(...);
  55. //#else
  56. #define __NR___kernel_sigaction __NR_sigaction
  57. static __always_inline _syscall3(int,__kernel_sigaction,int,signum,const struct sigaction *,act,struct sigaction *,oldact);
  58. //#endif
  59. #define SIGACTION(signum, act, oldact) __kernel_sigaction(signum, act, oldact)
  60. //#ifdef __NR_rt_sigprocmask
  61. //#define __NR___kernel_sigprocmask __NR_rt_sigprocmask
  62. //static __always_inline _syscall4(...);
  63. //#else
  64. #define __NR___kernel_sigprocmask __NR_sigprocmask
  65. static __always_inline _syscall3(int,__kernel_sigprocmask,int,how,const sigset_t *,set,sigset_t *,oldset);
  66. //#endif
  67. #define SIGPROCMASK(how, set, oldset) __kernel_sigprocmask(how, set, oldset)
  68. #define __NR___kernel_kill __NR_kill
  69. static __always_inline _syscall2(int,__kernel_kill,__kernel_pid_t,pid,int,sig);
  70. #define KILL(pid, sig) __kernel_kill(pid, sig)
  71. #define __NR___kernel_exit __NR_exit
  72. static __always_inline _syscall1(void,__kernel_exit,int,status);
  73. #define EXIT(status) __kernel_exit(status)
  74. #endif /* _SSP_INTERNAL_H */