siginfo.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI_ASM_GENERIC_SIGINFO_H
  3. #define _UAPI_ASM_GENERIC_SIGINFO_H
  4. #include <linux/compiler.h>
  5. #include <linux/types.h>
  6. typedef union sigval {
  7. int sival_int;
  8. void __user *sival_ptr;
  9. } sigval_t;
  10. #define SI_MAX_SIZE 128
  11. /*
  12. * The default "si_band" type is "long", as specified by POSIX.
  13. * However, some architectures want to override this to "int"
  14. * for historical compatibility reasons, so we allow that.
  15. */
  16. #ifndef __ARCH_SI_BAND_T
  17. #define __ARCH_SI_BAND_T long
  18. #endif
  19. #ifndef __ARCH_SI_CLOCK_T
  20. #define __ARCH_SI_CLOCK_T __kernel_clock_t
  21. #endif
  22. #ifndef __ARCH_SI_ATTRIBUTES
  23. #define __ARCH_SI_ATTRIBUTES
  24. #endif
  25. /*
  26. * Be careful when extending this union. On 32bit siginfo_t is 32bit
  27. * aligned. Which means that a 64bit field or any other field that
  28. * would increase the alignment of siginfo_t will break the ABI.
  29. */
  30. union __sifields {
  31. /* kill() */
  32. struct {
  33. __kernel_pid_t _pid; /* sender's pid */
  34. __kernel_uid32_t _uid; /* sender's uid */
  35. } _kill;
  36. /* POSIX.1b timers */
  37. struct {
  38. __kernel_timer_t _tid; /* timer id */
  39. int _overrun; /* overrun count */
  40. sigval_t _sigval; /* same as below */
  41. int _sys_private; /* Not used by the kernel. Historic leftover. Always 0. */
  42. } _timer;
  43. /* POSIX.1b signals */
  44. struct {
  45. __kernel_pid_t _pid; /* sender's pid */
  46. __kernel_uid32_t _uid; /* sender's uid */
  47. sigval_t _sigval;
  48. } _rt;
  49. /* SIGCHLD */
  50. struct {
  51. __kernel_pid_t _pid; /* which child */
  52. __kernel_uid32_t _uid; /* sender's uid */
  53. int _status; /* exit code */
  54. __ARCH_SI_CLOCK_T _utime;
  55. __ARCH_SI_CLOCK_T _stime;
  56. } _sigchld;
  57. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
  58. struct {
  59. void __user *_addr; /* faulting insn/memory ref. */
  60. #define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \
  61. sizeof(short) : __alignof__(void *))
  62. union {
  63. /* used on alpha and sparc */
  64. int _trapno; /* TRAP # which caused the signal */
  65. /*
  66. * used when si_code=BUS_MCEERR_AR or
  67. * used when si_code=BUS_MCEERR_AO
  68. */
  69. short _addr_lsb; /* LSB of the reported address */
  70. /* used when si_code=SEGV_BNDERR */
  71. struct {
  72. char _dummy_bnd[__ADDR_BND_PKEY_PAD];
  73. void __user *_lower;
  74. void __user *_upper;
  75. } _addr_bnd;
  76. /* used when si_code=SEGV_PKUERR */
  77. struct {
  78. char _dummy_pkey[__ADDR_BND_PKEY_PAD];
  79. __u32 _pkey;
  80. } _addr_pkey;
  81. /* used when si_code=TRAP_PERF */
  82. struct {
  83. unsigned long _data;
  84. __u32 _type;
  85. __u32 _flags;
  86. } _perf;
  87. };
  88. } _sigfault;
  89. /* SIGPOLL */
  90. struct {
  91. __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  92. int _fd;
  93. } _sigpoll;
  94. /* SIGSYS */
  95. struct {
  96. void __user *_call_addr; /* calling user insn */
  97. int _syscall; /* triggering system call number */
  98. unsigned int _arch; /* AUDIT_ARCH_* of syscall */
  99. } _sigsys;
  100. };
  101. #ifndef __ARCH_HAS_SWAPPED_SIGINFO
  102. #define __SIGINFO \
  103. struct { \
  104. int si_signo; \
  105. int si_errno; \
  106. int si_code; \
  107. union __sifields _sifields; \
  108. }
  109. #else
  110. #define __SIGINFO \
  111. struct { \
  112. int si_signo; \
  113. int si_code; \
  114. int si_errno; \
  115. union __sifields _sifields; \
  116. }
  117. #endif /* __ARCH_HAS_SWAPPED_SIGINFO */
  118. typedef struct siginfo {
  119. union {
  120. __SIGINFO;
  121. int _si_pad[SI_MAX_SIZE/sizeof(int)];
  122. };
  123. } __ARCH_SI_ATTRIBUTES siginfo_t;
  124. /*
  125. * How these fields are to be accessed.
  126. */
  127. #define si_pid _sifields._kill._pid
  128. #define si_uid _sifields._kill._uid
  129. #define si_tid _sifields._timer._tid
  130. #define si_overrun _sifields._timer._overrun
  131. #define si_sys_private _sifields._timer._sys_private
  132. #define si_status _sifields._sigchld._status
  133. #define si_utime _sifields._sigchld._utime
  134. #define si_stime _sifields._sigchld._stime
  135. #define si_value _sifields._rt._sigval
  136. #define si_int _sifields._rt._sigval.sival_int
  137. #define si_ptr _sifields._rt._sigval.sival_ptr
  138. #define si_addr _sifields._sigfault._addr
  139. #define si_trapno _sifields._sigfault._trapno
  140. #define si_addr_lsb _sifields._sigfault._addr_lsb
  141. #define si_lower _sifields._sigfault._addr_bnd._lower
  142. #define si_upper _sifields._sigfault._addr_bnd._upper
  143. #define si_pkey _sifields._sigfault._addr_pkey._pkey
  144. #define si_perf_data _sifields._sigfault._perf._data
  145. #define si_perf_type _sifields._sigfault._perf._type
  146. #define si_perf_flags _sifields._sigfault._perf._flags
  147. #define si_band _sifields._sigpoll._band
  148. #define si_fd _sifields._sigpoll._fd
  149. #define si_call_addr _sifields._sigsys._call_addr
  150. #define si_syscall _sifields._sigsys._syscall
  151. #define si_arch _sifields._sigsys._arch
  152. /*
  153. * si_code values
  154. * Digital reserves positive values for kernel-generated signals.
  155. */
  156. #define SI_USER 0 /* sent by kill, sigsend, raise */
  157. #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */
  158. #define SI_QUEUE -1 /* sent by sigqueue */
  159. #define SI_TIMER -2 /* sent by timer expiration */
  160. #define SI_MESGQ -3 /* sent by real time mesq state change */
  161. #define SI_ASYNCIO -4 /* sent by AIO completion */
  162. #define SI_SIGIO -5 /* sent by queued SIGIO */
  163. #define SI_TKILL -6 /* sent by tkill system call */
  164. #define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */
  165. #define SI_ASYNCNL -60 /* sent by glibc async name lookup completion */
  166. #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
  167. #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
  168. /*
  169. * SIGILL si_codes
  170. */
  171. #define ILL_ILLOPC 1 /* illegal opcode */
  172. #define ILL_ILLOPN 2 /* illegal operand */
  173. #define ILL_ILLADR 3 /* illegal addressing mode */
  174. #define ILL_ILLTRP 4 /* illegal trap */
  175. #define ILL_PRVOPC 5 /* privileged opcode */
  176. #define ILL_PRVREG 6 /* privileged register */
  177. #define ILL_COPROC 7 /* coprocessor error */
  178. #define ILL_BADSTK 8 /* internal stack error */
  179. #define ILL_BADIADDR 9 /* unimplemented instruction address */
  180. #define __ILL_BREAK 10 /* illegal break */
  181. #define __ILL_BNDMOD 11 /* bundle-update (modification) in progress */
  182. #define NSIGILL 11
  183. /*
  184. * SIGFPE si_codes
  185. */
  186. #define FPE_INTDIV 1 /* integer divide by zero */
  187. #define FPE_INTOVF 2 /* integer overflow */
  188. #define FPE_FLTDIV 3 /* floating point divide by zero */
  189. #define FPE_FLTOVF 4 /* floating point overflow */
  190. #define FPE_FLTUND 5 /* floating point underflow */
  191. #define FPE_FLTRES 6 /* floating point inexact result */
  192. #define FPE_FLTINV 7 /* floating point invalid operation */
  193. #define FPE_FLTSUB 8 /* subscript out of range */
  194. #define __FPE_DECOVF 9 /* decimal overflow */
  195. #define __FPE_DECDIV 10 /* decimal division by zero */
  196. #define __FPE_DECERR 11 /* packed decimal error */
  197. #define __FPE_INVASC 12 /* invalid ASCII digit */
  198. #define __FPE_INVDEC 13 /* invalid decimal digit */
  199. #define FPE_FLTUNK 14 /* undiagnosed floating-point exception */
  200. #define FPE_CONDTRAP 15 /* trap on condition */
  201. #define NSIGFPE 15
  202. /*
  203. * SIGSEGV si_codes
  204. */
  205. #define SEGV_MAPERR 1 /* address not mapped to object */
  206. #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
  207. #define SEGV_BNDERR 3 /* failed address bound checks */
  208. #ifdef __ia64__
  209. # define __SEGV_PSTKOVF 4 /* paragraph stack overflow */
  210. #else
  211. # define SEGV_PKUERR 4 /* failed protection key checks */
  212. #endif
  213. #define SEGV_ACCADI 5 /* ADI not enabled for mapped object */
  214. #define SEGV_ADIDERR 6 /* Disrupting MCD error */
  215. #define SEGV_ADIPERR 7 /* Precise MCD exception */
  216. #define SEGV_MTEAERR 8 /* Asynchronous ARM MTE error */
  217. #define SEGV_MTESERR 9 /* Synchronous ARM MTE exception */
  218. #define SEGV_CPERR 10 /* Control protection fault */
  219. #define NSIGSEGV 10
  220. /*
  221. * SIGBUS si_codes
  222. */
  223. #define BUS_ADRALN 1 /* invalid address alignment */
  224. #define BUS_ADRERR 2 /* non-existent physical address */
  225. #define BUS_OBJERR 3 /* object specific hardware error */
  226. /* hardware memory error consumed on a machine check: action required */
  227. #define BUS_MCEERR_AR 4
  228. /* hardware memory error detected in process but not consumed: action optional*/
  229. #define BUS_MCEERR_AO 5
  230. #define NSIGBUS 5
  231. /*
  232. * SIGTRAP si_codes
  233. */
  234. #define TRAP_BRKPT 1 /* process breakpoint */
  235. #define TRAP_TRACE 2 /* process trace trap */
  236. #define TRAP_BRANCH 3 /* process taken branch trap */
  237. #define TRAP_HWBKPT 4 /* hardware breakpoint/watchpoint */
  238. #define TRAP_UNK 5 /* undiagnosed trap */
  239. #define TRAP_PERF 6 /* perf event with sigtrap=1 */
  240. #define NSIGTRAP 6
  241. /*
  242. * There is an additional set of SIGTRAP si_codes used by ptrace
  243. * that are of the form: ((PTRACE_EVENT_XXX << 8) | SIGTRAP)
  244. */
  245. /*
  246. * Flags for si_perf_flags if SIGTRAP si_code is TRAP_PERF.
  247. */
  248. #define TRAP_PERF_FLAG_ASYNC (1u << 0)
  249. /*
  250. * SIGCHLD si_codes
  251. */
  252. #define CLD_EXITED 1 /* child has exited */
  253. #define CLD_KILLED 2 /* child was killed */
  254. #define CLD_DUMPED 3 /* child terminated abnormally */
  255. #define CLD_TRAPPED 4 /* traced child has trapped */
  256. #define CLD_STOPPED 5 /* child has stopped */
  257. #define CLD_CONTINUED 6 /* stopped child has continued */
  258. #define NSIGCHLD 6
  259. /*
  260. * SIGPOLL (or any other signal without signal specific si_codes) si_codes
  261. */
  262. #define POLL_IN 1 /* data input available */
  263. #define POLL_OUT 2 /* output buffers available */
  264. #define POLL_MSG 3 /* input message available */
  265. #define POLL_ERR 4 /* i/o error */
  266. #define POLL_PRI 5 /* high priority input available */
  267. #define POLL_HUP 6 /* device disconnected */
  268. #define NSIGPOLL 6
  269. /*
  270. * SIGSYS si_codes
  271. */
  272. #define SYS_SECCOMP 1 /* seccomp triggered */
  273. #define SYS_USER_DISPATCH 2 /* syscall user dispatch triggered */
  274. #define NSIGSYS 2
  275. /*
  276. * SIGEMT si_codes
  277. */
  278. #define EMT_TAGOVF 1 /* tag overflow */
  279. #define NSIGEMT 1
  280. /*
  281. * sigevent definitions
  282. *
  283. * It seems likely that SIGEV_THREAD will have to be handled from
  284. * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
  285. * thread manager then catches and does the appropriate nonsense.
  286. * However, everything is written out here so as to not get lost.
  287. */
  288. #define SIGEV_SIGNAL 0 /* notify via signal */
  289. #define SIGEV_NONE 1 /* other notification: meaningless */
  290. #define SIGEV_THREAD 2 /* deliver via thread creation */
  291. #define SIGEV_THREAD_ID 4 /* deliver to thread */
  292. /*
  293. * This works because the alignment is ok on all current architectures
  294. * but we leave open this being overridden in the future
  295. */
  296. #ifndef __ARCH_SIGEV_PREAMBLE_SIZE
  297. #define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_t))
  298. #endif
  299. #define SIGEV_MAX_SIZE 64
  300. #define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \
  301. / sizeof(int))
  302. typedef struct sigevent {
  303. sigval_t sigev_value;
  304. int sigev_signo;
  305. int sigev_notify;
  306. union {
  307. int _pad[SIGEV_PAD_SIZE];
  308. int _tid;
  309. struct {
  310. void (*_function)(sigval_t);
  311. void *_attribute; /* really pthread_attr_t */
  312. } _sigev_thread;
  313. } _sigev_un;
  314. } sigevent_t;
  315. #define sigev_notify_function _sigev_un._sigev_thread._function
  316. #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
  317. #define sigev_notify_thread_id _sigev_un._tid
  318. #endif /* _UAPI_ASM_GENERIC_SIGINFO_H */