logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

cn_proc.h (4160B)


  1. /* SPDX-License-Identifier: LGPL-2.1 WITH Linux-syscall-note */
  2. /*
  3. * cn_proc.h - process events connector
  4. *
  5. * Copyright (C) Matt Helsley, IBM Corp. 2005
  6. * Based on cn_fork.h by Nguyen Anh Quynh and Guillaume Thouvenin
  7. * Copyright (C) 2005 Nguyen Anh Quynh <aquynh@gmail.com>
  8. * Copyright (C) 2005 Guillaume Thouvenin <guillaume.thouvenin@bull.net>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of version 2.1 of the GNU Lesser General Public License
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it would be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. */
  18. #ifndef CN_PROC_H
  19. #define CN_PROC_H
  20. #include <linux/types.h>
  21. /*
  22. * Userspace sends this enum to register with the kernel that it is listening
  23. * for events on the connector.
  24. */
  25. enum proc_cn_mcast_op {
  26. PROC_CN_MCAST_LISTEN = 1,
  27. PROC_CN_MCAST_IGNORE = 2
  28. };
  29. #define PROC_EVENT_ALL (PROC_EVENT_FORK | PROC_EVENT_EXEC | PROC_EVENT_UID | \
  30. PROC_EVENT_GID | PROC_EVENT_SID | PROC_EVENT_PTRACE | \
  31. PROC_EVENT_COMM | PROC_EVENT_NONZERO_EXIT | \
  32. PROC_EVENT_COREDUMP | PROC_EVENT_EXIT)
  33. /*
  34. * If you add an entry in proc_cn_event, make sure you add it in
  35. * PROC_EVENT_ALL above as well.
  36. */
  37. enum proc_cn_event {
  38. /* Use successive bits so the enums can be used to record
  39. * sets of events as well
  40. */
  41. PROC_EVENT_NONE = 0x00000000,
  42. PROC_EVENT_FORK = 0x00000001,
  43. PROC_EVENT_EXEC = 0x00000002,
  44. PROC_EVENT_UID = 0x00000004,
  45. PROC_EVENT_GID = 0x00000040,
  46. PROC_EVENT_SID = 0x00000080,
  47. PROC_EVENT_PTRACE = 0x00000100,
  48. PROC_EVENT_COMM = 0x00000200,
  49. /* "next" should be 0x00000400 */
  50. /* "last" is the last process event: exit,
  51. * while "next to last" is coredumping event
  52. * before that is report only if process dies
  53. * with non-zero exit status
  54. */
  55. PROC_EVENT_NONZERO_EXIT = 0x20000000,
  56. PROC_EVENT_COREDUMP = 0x40000000,
  57. PROC_EVENT_EXIT = 0x80000000
  58. };
  59. struct proc_input {
  60. enum proc_cn_mcast_op mcast_op;
  61. enum proc_cn_event event_type;
  62. };
  63. static __inline__ enum proc_cn_event valid_event(enum proc_cn_event ev_type)
  64. {
  65. return (enum proc_cn_event)(ev_type & PROC_EVENT_ALL);
  66. }
  67. /*
  68. * From the user's point of view, the process
  69. * ID is the thread group ID and thread ID is the internal
  70. * kernel "pid". So, fields are assigned as follow:
  71. *
  72. * In user space - In kernel space
  73. *
  74. * parent process ID = parent->tgid
  75. * parent thread ID = parent->pid
  76. * child process ID = child->tgid
  77. * child thread ID = child->pid
  78. */
  79. struct proc_event {
  80. enum proc_cn_event what;
  81. __u32 cpu;
  82. __u64 __attribute__((aligned(8))) timestamp_ns;
  83. /* Number of nano seconds since system boot */
  84. union { /* must be last field of proc_event struct */
  85. struct {
  86. __u32 err;
  87. } ack;
  88. struct fork_proc_event {
  89. __kernel_pid_t parent_pid;
  90. __kernel_pid_t parent_tgid;
  91. __kernel_pid_t child_pid;
  92. __kernel_pid_t child_tgid;
  93. } fork;
  94. struct exec_proc_event {
  95. __kernel_pid_t process_pid;
  96. __kernel_pid_t process_tgid;
  97. } exec;
  98. struct id_proc_event {
  99. __kernel_pid_t process_pid;
  100. __kernel_pid_t process_tgid;
  101. union {
  102. __u32 ruid; /* task uid */
  103. __u32 rgid; /* task gid */
  104. } r;
  105. union {
  106. __u32 euid;
  107. __u32 egid;
  108. } e;
  109. } id;
  110. struct sid_proc_event {
  111. __kernel_pid_t process_pid;
  112. __kernel_pid_t process_tgid;
  113. } sid;
  114. struct ptrace_proc_event {
  115. __kernel_pid_t process_pid;
  116. __kernel_pid_t process_tgid;
  117. __kernel_pid_t tracer_pid;
  118. __kernel_pid_t tracer_tgid;
  119. } ptrace;
  120. struct comm_proc_event {
  121. __kernel_pid_t process_pid;
  122. __kernel_pid_t process_tgid;
  123. char comm[16];
  124. } comm;
  125. struct coredump_proc_event {
  126. __kernel_pid_t process_pid;
  127. __kernel_pid_t process_tgid;
  128. __kernel_pid_t parent_pid;
  129. __kernel_pid_t parent_tgid;
  130. } coredump;
  131. struct exit_proc_event {
  132. __kernel_pid_t process_pid;
  133. __kernel_pid_t process_tgid;
  134. __u32 exit_code, exit_signal;
  135. __kernel_pid_t parent_pid;
  136. __kernel_pid_t parent_tgid;
  137. } exit;
  138. } event_data;
  139. };
  140. #endif /* CN_PROC_H */