tame.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* $OpenBSD: tame.h,v 1.3 2015/07/28 15:22:25 deraadt Exp $ */
  2. /*
  3. * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
  4. * Copyright (c) 2015 Theo de Raadt <deraadt@openbsd.org>
  5. *
  6. * Permission to use, copy, modify, and distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _SYS_TAME_H_
  19. #define _SYS_TAME_H_
  20. #include <sys/cdefs.h>
  21. #define _TM_SELF 0x00000001 /* operate on own pid */
  22. #define _TM_RW 0x00000002 /* basic io operations */
  23. #define _TM_MALLOC 0x00000004 /* enough for malloc */
  24. #define _TM_DNSPATH 0x00000008 /* access to DNS pathnames */
  25. #define _TM_RPATH 0x00000010 /* allow open for read */
  26. #define _TM_WPATH 0x00000020 /* allow open for write */
  27. #define _TM_TMPPATH 0x00000040 /* for mk*temp() */
  28. #define _TM_INET 0x00000080 /* AF_INET/AF_INET6 sockets */
  29. #define _TM_UNIX 0x00000100 /* AF_UNIX sockets */
  30. #define _TM_CMSG 0x00000200 /* AF_UNIX CMSG fd passing */
  31. #define _TM_IOCTL 0x00000400 /* scary */
  32. #define _TM_GETPW 0x00000800 /* enough to enable YP */
  33. #define _TM_PROC 0x00001000 /* fork, waitpid, etc */
  34. #define _TM_CPATH 0x00002000 /* allow create, mkdir, or inode mods */
  35. #define _TM_ABORT 0x08000000 /* SIGABRT instead of SIGKILL */
  36. /* Following flags are set by kernel, as it learns things.
  37. * Not user settable. Should be moved to a seperate variable */
  38. #define _TM_USERSET 0x0fffffff
  39. #define _TM_YP_ACTIVE 0x10000000 /* YP use detected and allowed */
  40. #define _TM_DNS_ACTIVE 0x20000000 /* DNS use detected and allowed */
  41. #define TAME_MALLOC (_TM_SELF | _TM_MALLOC)
  42. #define TAME_RW (_TM_SELF | _TM_RW)
  43. #define TAME_STDIO (_TM_SELF | _TM_MALLOC | _TM_RW)
  44. #define TAME_RPATH (_TM_SELF | _TM_RW | _TM_RPATH)
  45. #define TAME_WPATH (_TM_SELF | _TM_RW | _TM_WPATH)
  46. #define TAME_TMPPATH (_TM_SELF | _TM_RW | _TM_TMPPATH)
  47. #define TAME_INET (_TM_SELF | _TM_RW | _TM_INET)
  48. #define TAME_UNIX (_TM_SELF | _TM_RW | _TM_UNIX)
  49. #define TAME_CMSG (TAME_UNIX | _TM_CMSG)
  50. #define TAME_DNS (TAME_MALLOC | _TM_DNSPATH)
  51. #define TAME_IOCTL (_TM_IOCTL)
  52. #define TAME_GETPW (TAME_STDIO | _TM_GETPW)
  53. #define TAME_PROC (_TM_PROC)
  54. #define TAME_CPATH (_TM_CPATH)
  55. #define TAME_ABORT (_TM_ABORT)
  56. #ifdef _KERNEL
  57. int tame_check(struct proc *, int);
  58. int tame_fail(struct proc *, int, int);
  59. int tame_namei(struct proc *, char *);
  60. void tame_aftersyscall(struct proc *, int, int);
  61. int tame_cmsg_send(struct proc *p, void *v, int controllen);
  62. int tame_cmsg_recv(struct proc *p, void *v, int controllen);
  63. int tame_sysctl_check(struct proc *p, int namelen, int *name, void *new);
  64. int tame_adjtime_check(struct proc *p, const void *v);
  65. int tame_recvfrom_check(struct proc *p, void *from);
  66. int tame_sendto_check(struct proc *p, const void *to);
  67. int tame_bind_check(struct proc *p, const void *v);
  68. int tame_connect_check(struct proc *p);
  69. int tame_socket_check(struct proc *p, int domain);
  70. int tame_setsockopt_check(struct proc *p, int level, int optname);
  71. int tame_dns_check(struct proc *p, in_port_t port);
  72. int tame_ioctl_check(struct proc *p, long com, void *);
  73. #else /* _KERNEL */
  74. int tame(int);
  75. #endif /* _KERNEL */
  76. #endif /* _SYS_TAME_H_ */