sandbox.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2013, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file sandbox.h
  8. * \brief Header file for sandbox.c.
  9. **/
  10. #ifndef SANDBOX_H_
  11. #define SANDBOX_H_
  12. #ifndef SYS_SECCOMP
  13. /**
  14. * Used by SIGSYS signal handler to check if the signal was issued due to a
  15. * seccomp2 filter violation.
  16. */
  17. #define SYS_SECCOMP 1
  18. #endif
  19. #include "torint.h"
  20. /**
  21. * Linux definitions
  22. */
  23. #ifdef __linux__
  24. #define __USE_GNU
  25. #include <sys/ucontext.h>
  26. #define MAX_PARAM_LEN 32
  27. typedef struct {
  28. int syscall;
  29. intptr_t param; // TODO: make this intptr_t to support multiple types
  30. char prot;
  31. } ParFilter;
  32. /**
  33. * Linux 32 bit definitions
  34. */
  35. #if defined(__i386__)
  36. #define REG_SYSCALL REG_EAX
  37. /**
  38. * Linux 64 bit definitions
  39. */
  40. #elif defined(__x86_64__)
  41. #define REG_SYSCALL REG_RAX
  42. #endif
  43. #endif // __linux__
  44. void sandbox_set_debugging_fd(int fd);
  45. int tor_global_sandbox(void);
  46. char* get_prot_param(char *param);
  47. #endif /* SANDBOX_H_ */