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