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