sandbox.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 64
  27. #define PARAM_PTR 0
  28. #define PARAM_NUM 1
  29. typedef struct {
  30. int syscall;
  31. char ptype;
  32. char pindex;
  33. intptr_t param;
  34. char prot;
  35. } sandbox_static_cfg_t;
  36. struct pfd_elem {
  37. int syscall;
  38. char ptype;
  39. char pindex;
  40. intptr_t param;
  41. char prot;
  42. struct pfd_elem *next;
  43. };
  44. typedef struct pfd_elem sandbox_cfg_t;
  45. /**
  46. * Linux 32 bit definitions
  47. */
  48. #if defined(__i386__)
  49. #define REG_SYSCALL REG_EAX
  50. /**
  51. * Linux 64 bit definitions
  52. */
  53. #elif defined(__x86_64__)
  54. #define REG_SYSCALL REG_RAX
  55. #endif
  56. #endif // __linux__
  57. void sandbox_set_debugging_fd(int fd);
  58. int tor_global_sandbox(void);
  59. char* get_prot_param(char *param);
  60. sandbox_cfg_t * sandbox_cfg_new();
  61. int sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file);
  62. int sandbox_init(sandbox_cfg_t* cfg);
  63. #endif /* SANDBOX_H_ */