sandbox.h 1.5 KB

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