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