cn_proc.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 _UAPICN_PROC_H
  19. #define _UAPICN_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. /*
  30. * From the user's point of view, the process
  31. * ID is the thread group ID and thread ID is the internal
  32. * kernel "pid". So, fields are assigned as follow:
  33. *
  34. * In user space - In kernel space
  35. *
  36. * parent process ID = parent->tgid
  37. * parent thread ID = parent->pid
  38. * child process ID = child->tgid
  39. * child thread ID = child->pid
  40. */
  41. struct proc_event {
  42. enum what {
  43. /* Use successive bits so the enums can be used to record
  44. * sets of events as well
  45. */
  46. PROC_EVENT_NONE = 0x00000000,
  47. PROC_EVENT_FORK = 0x00000001,
  48. PROC_EVENT_EXEC = 0x00000002,
  49. PROC_EVENT_UID = 0x00000004,
  50. PROC_EVENT_GID = 0x00000040,
  51. PROC_EVENT_SID = 0x00000080,
  52. PROC_EVENT_PTRACE = 0x00000100,
  53. PROC_EVENT_COMM = 0x00000200,
  54. /* "next" should be 0x00000400 */
  55. /* "last" is the last process event: exit,
  56. * while "next to last" is coredumping event */
  57. PROC_EVENT_COREDUMP = 0x40000000,
  58. PROC_EVENT_EXIT = 0x80000000
  59. } what;
  60. __u32 cpu;
  61. __u64 __attribute__((aligned(8))) timestamp_ns;
  62. /* Number of nano seconds since system boot */
  63. union { /* must be last field of proc_event struct */
  64. struct {
  65. __u32 err;
  66. } ack;
  67. struct fork_proc_event {
  68. __kernel_pid_t parent_pid;
  69. __kernel_pid_t parent_tgid;
  70. __kernel_pid_t child_pid;
  71. __kernel_pid_t child_tgid;
  72. } fork;
  73. struct exec_proc_event {
  74. __kernel_pid_t process_pid;
  75. __kernel_pid_t process_tgid;
  76. } exec;
  77. struct id_proc_event {
  78. __kernel_pid_t process_pid;
  79. __kernel_pid_t process_tgid;
  80. union {
  81. __u32 ruid; /* task uid */
  82. __u32 rgid; /* task gid */
  83. } r;
  84. union {
  85. __u32 euid;
  86. __u32 egid;
  87. } e;
  88. } id;
  89. struct sid_proc_event {
  90. __kernel_pid_t process_pid;
  91. __kernel_pid_t process_tgid;
  92. } sid;
  93. struct ptrace_proc_event {
  94. __kernel_pid_t process_pid;
  95. __kernel_pid_t process_tgid;
  96. __kernel_pid_t tracer_pid;
  97. __kernel_pid_t tracer_tgid;
  98. } ptrace;
  99. struct comm_proc_event {
  100. __kernel_pid_t process_pid;
  101. __kernel_pid_t process_tgid;
  102. char comm[16];
  103. } comm;
  104. struct coredump_proc_event {
  105. __kernel_pid_t process_pid;
  106. __kernel_pid_t process_tgid;
  107. __kernel_pid_t parent_pid;
  108. __kernel_pid_t parent_tgid;
  109. } coredump;
  110. struct exit_proc_event {
  111. __kernel_pid_t process_pid;
  112. __kernel_pid_t process_tgid;
  113. __u32 exit_code, exit_signal;
  114. __kernel_pid_t parent_pid;
  115. __kernel_pid_t parent_tgid;
  116. } exit;
  117. } event_data;
  118. };
  119. #endif /* _UAPICN_PROC_H */