1*bbb1b6f9SApple OSS Distributions #include <darwintest.h>
2*bbb1b6f9SApple OSS Distributions #include <mach/mach.h>
3*bbb1b6f9SApple OSS Distributions #include <stdlib.h>
4*bbb1b6f9SApple OSS Distributions #include <stdio.h>
5*bbb1b6f9SApple OSS Distributions #include <sys/sysctl.h>
6*bbb1b6f9SApple OSS Distributions #include <unistd.h>
7*bbb1b6f9SApple OSS Distributions #include <darwintest_multiprocess.h>
8*bbb1b6f9SApple OSS Distributions #include <spawn.h>
9*bbb1b6f9SApple OSS Distributions #include <spawn_private.h>
10*bbb1b6f9SApple OSS Distributions #include <libproc_internal.h>
11*bbb1b6f9SApple OSS Distributions #include <signal.h>
12*bbb1b6f9SApple OSS Distributions #include <string.h>
13*bbb1b6f9SApple OSS Distributions
14*bbb1b6f9SApple OSS Distributions #include <err.h>
15*bbb1b6f9SApple OSS Distributions #include <stdio.h>
16*bbb1b6f9SApple OSS Distributions #include <sysexits.h>
17*bbb1b6f9SApple OSS Distributions #include <stdbool.h>
18*bbb1b6f9SApple OSS Distributions
19*bbb1b6f9SApple OSS Distributions #include "kqwl_rnServer.h" // generated by MIG from rnserver.defs
20*bbb1b6f9SApple OSS Distributions
21*bbb1b6f9SApple OSS Distributions #include <servers/bootstrap.h>
22*bbb1b6f9SApple OSS Distributions #include <libproc_internal.h> // proc*cpumon*()
23*bbb1b6f9SApple OSS Distributions
24*bbb1b6f9SApple OSS Distributions T_GLOBAL_META(
25*bbb1b6f9SApple OSS Distributions T_META_NAMESPACE("xnu.kevent"),
26*bbb1b6f9SApple OSS Distributions T_META_RUN_CONCURRENTLY(TRUE),
27*bbb1b6f9SApple OSS Distributions T_META_RADAR_COMPONENT_NAME("xnu"),
28*bbb1b6f9SApple OSS Distributions T_META_RADAR_COMPONENT_VERSION("kevent"));
29*bbb1b6f9SApple OSS Distributions
30*bbb1b6f9SApple OSS Distributions #define TEST_PROGRAM_NAME "./kqworkloop_limits_client"
31*bbb1b6f9SApple OSS Distributions #define MAX_ARGV 5
32*bbb1b6f9SApple OSS Distributions
33*bbb1b6f9SApple OSS Distributions extern char **environ;
34*bbb1b6f9SApple OSS Distributions
35*bbb1b6f9SApple OSS Distributions static int
spawn_child_process_with_limits(int soft_limit,int hard_limit,int test_num)36*bbb1b6f9SApple OSS Distributions spawn_child_process_with_limits(int soft_limit, int hard_limit, int test_num)
37*bbb1b6f9SApple OSS Distributions {
38*bbb1b6f9SApple OSS Distributions char *child_args[MAX_ARGV];
39*bbb1b6f9SApple OSS Distributions int child_pid;
40*bbb1b6f9SApple OSS Distributions posix_spawnattr_t attrs;
41*bbb1b6f9SApple OSS Distributions int err;
42*bbb1b6f9SApple OSS Distributions
43*bbb1b6f9SApple OSS Distributions /* Initialize posix_spawn attributes */
44*bbb1b6f9SApple OSS Distributions posix_spawnattr_init(&attrs);
45*bbb1b6f9SApple OSS Distributions
46*bbb1b6f9SApple OSS Distributions err = posix_spawnattr_set_kqworklooplimit_ext(&attrs, soft_limit, hard_limit);
47*bbb1b6f9SApple OSS Distributions T_ASSERT_POSIX_SUCCESS(err, "posix_spawnattr_set_kqworklooplimit_ext");
48*bbb1b6f9SApple OSS Distributions
49*bbb1b6f9SApple OSS Distributions char soft_limit_str[32];
50*bbb1b6f9SApple OSS Distributions sprintf(soft_limit_str, "%d", soft_limit);
51*bbb1b6f9SApple OSS Distributions
52*bbb1b6f9SApple OSS Distributions char hard_limit_str[32];
53*bbb1b6f9SApple OSS Distributions sprintf(hard_limit_str, "%d", hard_limit);
54*bbb1b6f9SApple OSS Distributions
55*bbb1b6f9SApple OSS Distributions char test_num_str[32];
56*bbb1b6f9SApple OSS Distributions sprintf(test_num_str, "%d", test_num);
57*bbb1b6f9SApple OSS Distributions
58*bbb1b6f9SApple OSS Distributions child_args[0] = TEST_PROGRAM_NAME;
59*bbb1b6f9SApple OSS Distributions child_args[1] = soft_limit_str; // soft limit
60*bbb1b6f9SApple OSS Distributions child_args[2] = hard_limit_str; // hard limit
61*bbb1b6f9SApple OSS Distributions child_args[3] = test_num_str; // test num
62*bbb1b6f9SApple OSS Distributions child_args[4] = NULL;
63*bbb1b6f9SApple OSS Distributions
64*bbb1b6f9SApple OSS Distributions err = posix_spawn(&child_pid, child_args[0], NULL, &attrs, child_args, environ);
65*bbb1b6f9SApple OSS Distributions T_ASSERT_POSIX_SUCCESS(err, "posix_spawn kqworkloop_limits_client");
66*bbb1b6f9SApple OSS Distributions return child_pid;
67*bbb1b6f9SApple OSS Distributions }
68*bbb1b6f9SApple OSS Distributions
69*bbb1b6f9SApple OSS Distributions T_DECL(test_kqworkloop_soft_limit, "Allocate kqworkloops up to soft limit",
70*bbb1b6f9SApple OSS Distributions T_META_IGNORECRASHES(".*kqworkloop_limits_client.*"), T_META_CHECK_LEAKS(false), T_META_TAG_VM_PREFERRED)
71*bbb1b6f9SApple OSS Distributions {
72*bbb1b6f9SApple OSS Distributions #if TARGET_OS_BRIDGE
73*bbb1b6f9SApple OSS Distributions T_SKIP("Not running on target platforms");
74*bbb1b6f9SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
75*bbb1b6f9SApple OSS Distributions
76*bbb1b6f9SApple OSS Distributions int child_pid = spawn_child_process_with_limits(200, 0, 1);
77*bbb1b6f9SApple OSS Distributions
78*bbb1b6f9SApple OSS Distributions int child_status;
79*bbb1b6f9SApple OSS Distributions /* Wait for child and check for exception */
80*bbb1b6f9SApple OSS Distributions if (-1 == waitpid(child_pid, &child_status, 0)) {
81*bbb1b6f9SApple OSS Distributions T_FAIL("waitpid: child mia");
82*bbb1b6f9SApple OSS Distributions }
83*bbb1b6f9SApple OSS Distributions
84*bbb1b6f9SApple OSS Distributions if (WIFSIGNALED(child_status)) {
85*bbb1b6f9SApple OSS Distributions T_FAIL("Child exited with signal = %d", WTERMSIG(child_status));
86*bbb1b6f9SApple OSS Distributions }
87*bbb1b6f9SApple OSS Distributions
88*bbb1b6f9SApple OSS Distributions T_ASSERT_EQ(WIFEXITED(child_status), 1, "Child exited normally with exit value %d", WEXITSTATUS(child_status));
89*bbb1b6f9SApple OSS Distributions }
90*bbb1b6f9SApple OSS Distributions
91*bbb1b6f9SApple OSS Distributions T_DECL(test_kqworkloop_hard_limit, "Allocate kqworkloops up to hard limit",
92*bbb1b6f9SApple OSS Distributions T_META_IGNORECRASHES(".*kqworkloop_limits_client.*"), T_META_CHECK_LEAKS(false), T_META_TAG_VM_PREFERRED)
93*bbb1b6f9SApple OSS Distributions {
94*bbb1b6f9SApple OSS Distributions #if TARGET_OS_BRIDGE
95*bbb1b6f9SApple OSS Distributions T_SKIP("Not running on target platforms");
96*bbb1b6f9SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
97*bbb1b6f9SApple OSS Distributions
98*bbb1b6f9SApple OSS Distributions int child_pid = spawn_child_process_with_limits(0, 500, 1);
99*bbb1b6f9SApple OSS Distributions
100*bbb1b6f9SApple OSS Distributions int child_status;
101*bbb1b6f9SApple OSS Distributions /* Wait for child and check for exception */
102*bbb1b6f9SApple OSS Distributions if (-1 == waitpid(child_pid, &child_status, 0)) {
103*bbb1b6f9SApple OSS Distributions T_FAIL("waitpid: child mia");
104*bbb1b6f9SApple OSS Distributions }
105*bbb1b6f9SApple OSS Distributions
106*bbb1b6f9SApple OSS Distributions T_ASSERT_EQ(WIFEXITED(child_status), 0, "Child did not exit normally");
107*bbb1b6f9SApple OSS Distributions
108*bbb1b6f9SApple OSS Distributions if (WIFSIGNALED(child_status)) {
109*bbb1b6f9SApple OSS Distributions T_ASSERT_EQ(child_status, 9, "Child exited with status = %x", child_status);
110*bbb1b6f9SApple OSS Distributions }
111*bbb1b6f9SApple OSS Distributions }
112*bbb1b6f9SApple OSS Distributions
113*bbb1b6f9SApple OSS Distributions T_DECL(test_kqworkloop_soft_and_hard_limit, "Allocate kqworkloops with soft and hard limit",
114*bbb1b6f9SApple OSS Distributions T_META_IGNORECRASHES(".*kqworkloop_limits_client.*"),
115*bbb1b6f9SApple OSS Distributions T_META_CHECK_LEAKS(false),
116*bbb1b6f9SApple OSS Distributions T_META_TAG_VM_PREFERRED,
117*bbb1b6f9SApple OSS Distributions T_META_ENABLED(false /* rdar://133461542 */)
118*bbb1b6f9SApple OSS Distributions )
119*bbb1b6f9SApple OSS Distributions {
120*bbb1b6f9SApple OSS Distributions #if TARGET_OS_BRIDGE
121*bbb1b6f9SApple OSS Distributions T_SKIP("Not running on target platforms");
122*bbb1b6f9SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
123*bbb1b6f9SApple OSS Distributions
124*bbb1b6f9SApple OSS Distributions int child_pid = spawn_child_process_with_limits(250, 500, 1);
125*bbb1b6f9SApple OSS Distributions
126*bbb1b6f9SApple OSS Distributions int child_status;
127*bbb1b6f9SApple OSS Distributions /* Wait for child and check for exception */
128*bbb1b6f9SApple OSS Distributions if (-1 == waitpid(child_pid, &child_status, 0)) {
129*bbb1b6f9SApple OSS Distributions T_FAIL("waitpid: child mia");
130*bbb1b6f9SApple OSS Distributions }
131*bbb1b6f9SApple OSS Distributions
132*bbb1b6f9SApple OSS Distributions T_ASSERT_EQ(WIFEXITED(child_status), 0, "Child did not exit normally");
133*bbb1b6f9SApple OSS Distributions
134*bbb1b6f9SApple OSS Distributions if (WIFSIGNALED(child_status)) {
135*bbb1b6f9SApple OSS Distributions T_ASSERT_EQ(child_status, 9, "Child exited with status = %x", child_status);
136*bbb1b6f9SApple OSS Distributions }
137*bbb1b6f9SApple OSS Distributions }
138*bbb1b6f9SApple OSS Distributions
139*bbb1b6f9SApple OSS Distributions // Tests which define a resource notify server and verify that the soft/hard
140*bbb1b6f9SApple OSS Distributions // limit violations are correctly delivered to the server
141*bbb1b6f9SApple OSS Distributions
142*bbb1b6f9SApple OSS Distributions typedef struct {
143*bbb1b6f9SApple OSS Distributions mach_msg_header_t header;
144*bbb1b6f9SApple OSS Distributions mach_msg_body_t body;
145*bbb1b6f9SApple OSS Distributions mach_msg_port_descriptor_t port_descriptor;
146*bbb1b6f9SApple OSS Distributions mach_msg_trailer_t trailer; // subtract this when sending
147*bbb1b6f9SApple OSS Distributions } ipc_complex_message;
148*bbb1b6f9SApple OSS Distributions
149*bbb1b6f9SApple OSS Distributions struct args {
150*bbb1b6f9SApple OSS Distributions const char *progname;
151*bbb1b6f9SApple OSS Distributions int verbose;
152*bbb1b6f9SApple OSS Distributions int voucher;
153*bbb1b6f9SApple OSS Distributions int num_msgs;
154*bbb1b6f9SApple OSS Distributions const char *server_port_name;
155*bbb1b6f9SApple OSS Distributions mach_port_t server_port;
156*bbb1b6f9SApple OSS Distributions mach_port_t reply_port;
157*bbb1b6f9SApple OSS Distributions int request_msg_size;
158*bbb1b6f9SApple OSS Distributions void *request_msg;
159*bbb1b6f9SApple OSS Distributions int reply_msg_size;
160*bbb1b6f9SApple OSS Distributions void *reply_msg;
161*bbb1b6f9SApple OSS Distributions uint32_t persona_id;
162*bbb1b6f9SApple OSS Distributions long client_pid;
163*bbb1b6f9SApple OSS Distributions };
164*bbb1b6f9SApple OSS Distributions
165*bbb1b6f9SApple OSS Distributions void parse_args(struct args *args);
166*bbb1b6f9SApple OSS Distributions void server_setup(struct args* args);
167*bbb1b6f9SApple OSS Distributions void* exception_server_thread(void *arg);
168*bbb1b6f9SApple OSS Distributions mach_port_t create_exception_port(void);
169*bbb1b6f9SApple OSS Distributions static mach_port_t create_resource_notify_port(void);
170*bbb1b6f9SApple OSS Distributions static ipc_complex_message icm_request = {};
171*bbb1b6f9SApple OSS Distributions static ipc_complex_message icm_reply = {};
172*bbb1b6f9SApple OSS Distributions static mach_port_t resource_notify_port = MACH_PORT_NULL;
173*bbb1b6f9SApple OSS Distributions
174*bbb1b6f9SApple OSS Distributions #define TEST_TIMEOUT 10
175*bbb1b6f9SApple OSS Distributions
176*bbb1b6f9SApple OSS Distributions void
setup_server_args(struct args * args)177*bbb1b6f9SApple OSS Distributions setup_server_args(struct args *args)
178*bbb1b6f9SApple OSS Distributions {
179*bbb1b6f9SApple OSS Distributions args->server_port_name = "TEST_KQWORKLOOP_LIMITS";
180*bbb1b6f9SApple OSS Distributions args->server_port = MACH_PORT_NULL;
181*bbb1b6f9SApple OSS Distributions args->reply_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
182*bbb1b6f9SApple OSS Distributions args->request_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
183*bbb1b6f9SApple OSS Distributions args->reply_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
184*bbb1b6f9SApple OSS Distributions args->request_msg = &icm_request;
185*bbb1b6f9SApple OSS Distributions args->reply_msg = &icm_reply;
186*bbb1b6f9SApple OSS Distributions }
187*bbb1b6f9SApple OSS Distributions
188*bbb1b6f9SApple OSS Distributions /* Create a mach IPC listener which will respond to the client's message */
189*bbb1b6f9SApple OSS Distributions void
server_setup(struct args * args)190*bbb1b6f9SApple OSS Distributions server_setup(struct args *args)
191*bbb1b6f9SApple OSS Distributions {
192*bbb1b6f9SApple OSS Distributions kern_return_t ret;
193*bbb1b6f9SApple OSS Distributions mach_port_t bsport;
194*bbb1b6f9SApple OSS Distributions
195*bbb1b6f9SApple OSS Distributions ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE,
196*bbb1b6f9SApple OSS Distributions &args->server_port);
197*bbb1b6f9SApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: mach_port_allocate()");
198*bbb1b6f9SApple OSS Distributions
199*bbb1b6f9SApple OSS Distributions ret = mach_port_insert_right(mach_task_self(), args->server_port, args->server_port,
200*bbb1b6f9SApple OSS Distributions MACH_MSG_TYPE_MAKE_SEND);
201*bbb1b6f9SApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: mach_port_insert_right()");
202*bbb1b6f9SApple OSS Distributions
203*bbb1b6f9SApple OSS Distributions ret = task_get_bootstrap_port(mach_task_self(), &bsport);
204*bbb1b6f9SApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: task_get_bootstrap_port()");
205*bbb1b6f9SApple OSS Distributions
206*bbb1b6f9SApple OSS Distributions ret = bootstrap_register(bsport, (const char *)args->server_port_name, args->server_port);
207*bbb1b6f9SApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: bootstrap_register()");
208*bbb1b6f9SApple OSS Distributions
209*bbb1b6f9SApple OSS Distributions T_LOG("server: waiting for IPC messages from client on port '%s'.\n",
210*bbb1b6f9SApple OSS Distributions args->server_port_name);
211*bbb1b6f9SApple OSS Distributions
212*bbb1b6f9SApple OSS Distributions /* Make the server port as the resource notify port */
213*bbb1b6f9SApple OSS Distributions resource_notify_port = args->server_port;
214*bbb1b6f9SApple OSS Distributions }
215*bbb1b6f9SApple OSS Distributions
216*bbb1b6f9SApple OSS Distributions T_DECL(test_kqworkloop_hard_limit_with_resource_notify_port,
217*bbb1b6f9SApple OSS Distributions "Allocate kqworkloops up to hard limit and trigger notification",
218*bbb1b6f9SApple OSS Distributions T_META_IGNORECRASHES(".*kqworkloop_limits_client.*"), T_META_CHECK_LEAKS(false), T_META_TAG_VM_PREFERRED)
219*bbb1b6f9SApple OSS Distributions {
220*bbb1b6f9SApple OSS Distributions #if TARGET_OS_BRIDGE
221*bbb1b6f9SApple OSS Distributions T_SKIP("Not running on target platforms");
222*bbb1b6f9SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
223*bbb1b6f9SApple OSS Distributions struct args* server_args = (struct args*)malloc(sizeof(struct args));
224*bbb1b6f9SApple OSS Distributions
225*bbb1b6f9SApple OSS Distributions /* Create the bootstrap port */
226*bbb1b6f9SApple OSS Distributions setup_server_args(server_args);
227*bbb1b6f9SApple OSS Distributions server_setup(server_args);
228*bbb1b6f9SApple OSS Distributions
229*bbb1b6f9SApple OSS Distributions server_args->client_pid = spawn_child_process_with_limits(0, 500, 2);
230*bbb1b6f9SApple OSS Distributions
231*bbb1b6f9SApple OSS Distributions T_LOG("server: Let's see if we can catch some kqworkloop leak");
232*bbb1b6f9SApple OSS Distributions
233*bbb1b6f9SApple OSS Distributions kern_return_t kr = mach_msg_server_once(resource_notify_server, 4096, resource_notify_port, 0);
234*bbb1b6f9SApple OSS Distributions T_ASSERT_MACH_SUCCESS(kr, "mach_msg_server_once resource_notify_port");
235*bbb1b6f9SApple OSS Distributions }
236*bbb1b6f9SApple OSS Distributions
237*bbb1b6f9SApple OSS Distributions // MIG's resource_notify_server() expects receive_cpu_usage_triggers as well
238*bbb1b6f9SApple OSS Distributions // This must match the definition in xnu's resource_notify.defs
239*bbb1b6f9SApple OSS Distributions kern_return_t
receive_cpu_usage_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_cpu_nsecs,__unused int64_t observation_nsecs,__unused int64_t cpu_nsecs_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)240*bbb1b6f9SApple OSS Distributions receive_cpu_usage_violation(__unused mach_port_t receiver,
241*bbb1b6f9SApple OSS Distributions __unused proc_name_t procname,
242*bbb1b6f9SApple OSS Distributions __unused pid_t pid,
243*bbb1b6f9SApple OSS Distributions __unused posix_path_t killed_proc_path,
244*bbb1b6f9SApple OSS Distributions __unused mach_timespec_t timestamp,
245*bbb1b6f9SApple OSS Distributions __unused int64_t observed_cpu_nsecs,
246*bbb1b6f9SApple OSS Distributions __unused int64_t observation_nsecs,
247*bbb1b6f9SApple OSS Distributions __unused int64_t cpu_nsecs_allowed,
248*bbb1b6f9SApple OSS Distributions __unused int64_t limit_window_nsecs,
249*bbb1b6f9SApple OSS Distributions __unused resource_notify_flags_t flags)
250*bbb1b6f9SApple OSS Distributions {
251*bbb1b6f9SApple OSS Distributions return KERN_FAILURE;
252*bbb1b6f9SApple OSS Distributions }
253*bbb1b6f9SApple OSS Distributions
254*bbb1b6f9SApple OSS Distributions kern_return_t
receive_cpu_wakes_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_cpu_wakes,__unused int64_t observation_nsecs,__unused int64_t cpu_wakes_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)255*bbb1b6f9SApple OSS Distributions receive_cpu_wakes_violation(__unused mach_port_t receiver,
256*bbb1b6f9SApple OSS Distributions __unused proc_name_t procname,
257*bbb1b6f9SApple OSS Distributions __unused pid_t pid,
258*bbb1b6f9SApple OSS Distributions __unused posix_path_t killed_proc_path,
259*bbb1b6f9SApple OSS Distributions __unused mach_timespec_t timestamp,
260*bbb1b6f9SApple OSS Distributions __unused int64_t observed_cpu_wakes,
261*bbb1b6f9SApple OSS Distributions __unused int64_t observation_nsecs,
262*bbb1b6f9SApple OSS Distributions __unused int64_t cpu_wakes_allowed,
263*bbb1b6f9SApple OSS Distributions __unused int64_t limit_window_nsecs,
264*bbb1b6f9SApple OSS Distributions __unused resource_notify_flags_t flags)
265*bbb1b6f9SApple OSS Distributions {
266*bbb1b6f9SApple OSS Distributions return KERN_FAILURE;
267*bbb1b6f9SApple OSS Distributions }
268*bbb1b6f9SApple OSS Distributions
269*bbb1b6f9SApple OSS Distributions kern_return_t
receive_disk_writes_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_bytes_dirtied,__unused int64_t observation_nsecs,__unused int64_t bytes_dirtied_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)270*bbb1b6f9SApple OSS Distributions receive_disk_writes_violation(__unused mach_port_t receiver,
271*bbb1b6f9SApple OSS Distributions __unused proc_name_t procname,
272*bbb1b6f9SApple OSS Distributions __unused pid_t pid,
273*bbb1b6f9SApple OSS Distributions __unused posix_path_t killed_proc_path,
274*bbb1b6f9SApple OSS Distributions __unused mach_timespec_t timestamp,
275*bbb1b6f9SApple OSS Distributions __unused int64_t observed_bytes_dirtied,
276*bbb1b6f9SApple OSS Distributions __unused int64_t observation_nsecs,
277*bbb1b6f9SApple OSS Distributions __unused int64_t bytes_dirtied_allowed,
278*bbb1b6f9SApple OSS Distributions __unused int64_t limit_window_nsecs,
279*bbb1b6f9SApple OSS Distributions __unused resource_notify_flags_t flags)
280*bbb1b6f9SApple OSS Distributions {
281*bbb1b6f9SApple OSS Distributions return KERN_FAILURE;
282*bbb1b6f9SApple OSS Distributions }
283*bbb1b6f9SApple OSS Distributions
284*bbb1b6f9SApple OSS Distributions kern_return_t
receive_port_space_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused mach_timespec_t timestamp,__unused int64_t observed_ports,__unused int64_t ports_allowed,__unused mach_port_t fatal_port,__unused resource_notify_flags_t flags)285*bbb1b6f9SApple OSS Distributions receive_port_space_violation(__unused mach_port_t receiver,
286*bbb1b6f9SApple OSS Distributions __unused proc_name_t procname,
287*bbb1b6f9SApple OSS Distributions __unused pid_t pid,
288*bbb1b6f9SApple OSS Distributions __unused mach_timespec_t timestamp,
289*bbb1b6f9SApple OSS Distributions __unused int64_t observed_ports,
290*bbb1b6f9SApple OSS Distributions __unused int64_t ports_allowed,
291*bbb1b6f9SApple OSS Distributions __unused mach_port_t fatal_port,
292*bbb1b6f9SApple OSS Distributions __unused resource_notify_flags_t flags)
293*bbb1b6f9SApple OSS Distributions {
294*bbb1b6f9SApple OSS Distributions return KERN_FAILURE;
295*bbb1b6f9SApple OSS Distributions }
296*bbb1b6f9SApple OSS Distributions
297*bbb1b6f9SApple OSS Distributions kern_return_t
receive_file_descriptors_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused mach_timespec_t timestamp,__unused int64_t observed_filedesc,__unused int64_t filedesc_allowed,__unused mach_port_t fatal_port,__unused resource_notify_flags_t flags)298*bbb1b6f9SApple OSS Distributions receive_file_descriptors_violation(__unused mach_port_t receiver,
299*bbb1b6f9SApple OSS Distributions __unused proc_name_t procname,
300*bbb1b6f9SApple OSS Distributions __unused pid_t pid,
301*bbb1b6f9SApple OSS Distributions __unused mach_timespec_t timestamp,
302*bbb1b6f9SApple OSS Distributions __unused int64_t observed_filedesc,
303*bbb1b6f9SApple OSS Distributions __unused int64_t filedesc_allowed,
304*bbb1b6f9SApple OSS Distributions __unused mach_port_t fatal_port,
305*bbb1b6f9SApple OSS Distributions __unused resource_notify_flags_t flags)
306*bbb1b6f9SApple OSS Distributions {
307*bbb1b6f9SApple OSS Distributions return KERN_FAILURE;
308*bbb1b6f9SApple OSS Distributions }
309*bbb1b6f9SApple OSS Distributions
310*bbb1b6f9SApple OSS Distributions kern_return_t
receive_kqworkloops_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused mach_timespec_t timestamp,__unused int64_t observed_kqworkloops,__unused int64_t kqworkloops_allowed,__unused mach_port_t fatal_port,__unused resource_notify_flags_t flags)311*bbb1b6f9SApple OSS Distributions receive_kqworkloops_violation( __unused mach_port_t receiver,
312*bbb1b6f9SApple OSS Distributions __unused proc_name_t procname,
313*bbb1b6f9SApple OSS Distributions __unused pid_t pid,
314*bbb1b6f9SApple OSS Distributions __unused mach_timespec_t timestamp,
315*bbb1b6f9SApple OSS Distributions __unused int64_t observed_kqworkloops,
316*bbb1b6f9SApple OSS Distributions __unused int64_t kqworkloops_allowed,
317*bbb1b6f9SApple OSS Distributions __unused mach_port_t fatal_port,
318*bbb1b6f9SApple OSS Distributions __unused resource_notify_flags_t flags)
319*bbb1b6f9SApple OSS Distributions {
320*bbb1b6f9SApple OSS Distributions T_LOG("Received a notification on the resource notify port");
321*bbb1b6f9SApple OSS Distributions T_LOG("kqworkloops_allowed = %lld, kqworkloops observed = %lld", kqworkloops_allowed, observed_kqworkloops);
322*bbb1b6f9SApple OSS Distributions if (fatal_port) {
323*bbb1b6f9SApple OSS Distributions mach_port_deallocate(mach_task_self(), fatal_port);
324*bbb1b6f9SApple OSS Distributions }
325*bbb1b6f9SApple OSS Distributions return KERN_SUCCESS;
326*bbb1b6f9SApple OSS Distributions }
327