1 /*
2 * util/fptr_wlist.c - function pointer whitelists.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 /**
37 * \file
38 *
39 * This file contains functions that check function pointers.
40 * The functions contain a whitelist of known good callback values.
41 * Any other values lead to an error.
42 *
43 * Due to the listing nature, this file violates all the modularization
44 * boundaries in the program.
45 */
46 #include "config.h"
47 #include "util/fptr_wlist.h"
48 #include "util/mini_event.h"
49 #include "services/outside_network.h"
50 #include "services/listen_dnsport.h"
51 #include "services/mesh.h"
52 #include "services/localzone.h"
53 #include "services/authzone.h"
54 #include "services/cache/infra.h"
55 #include "services/cache/rrset.h"
56 #include "services/view.h"
57 #include "dns64/dns64.h"
58 #include "iterator/iterator.h"
59 #include "iterator/iter_fwd.h"
60 #include "validator/validator.h"
61 #include "validator/val_anchor.h"
62 #include "validator/val_nsec3.h"
63 #include "validator/val_sigcrypt.h"
64 #include "validator/val_kentry.h"
65 #include "validator/val_neg.h"
66 #include "validator/autotrust.h"
67 #include "util/data/msgreply.h"
68 #include "util/data/packed_rrset.h"
69 #include "util/storage/slabhash.h"
70 #include "util/storage/dnstree.h"
71 #include "util/locks.h"
72 #include "libunbound/libworker.h"
73 #include "libunbound/context.h"
74 #include "libunbound/worker.h"
75 #include "util/tube.h"
76 #include "util/config_file.h"
77 #include "daemon/remote.h"
78 #ifdef UB_ON_WINDOWS
79 #include "winrc/win_svc.h"
80 #endif
81 #include "respip/respip.h"
82
83 #ifdef WITH_PYTHONMODULE
84 #include "pythonmod/pythonmod.h"
85 #endif
86 #ifdef WITH_DYNLIBMODULE
87 #include "dynlibmod/dynlibmod.h"
88 #endif
89 #ifdef USE_CACHEDB
90 #include "cachedb/cachedb.h"
91 #endif
92 #ifdef USE_IPSECMOD
93 #include "ipsecmod/ipsecmod.h"
94 #endif
95 #ifdef CLIENT_SUBNET
96 #include "edns-subnet/subnetmod.h"
97 #endif
98 #ifdef USE_IPSET
99 #include "ipset/ipset.h"
100 #endif
101 #ifdef USE_DNSTAP
102 #include "dnstap/dtstream.h"
103 #endif
104
105 int
fptr_whitelist_comm_point(comm_point_callback_type * fptr)106 fptr_whitelist_comm_point(comm_point_callback_type *fptr)
107 {
108 if(fptr == &worker_handle_request) return 1;
109 else if(fptr == &outnet_udp_cb) return 1;
110 else if(fptr == &outnet_tcp_cb) return 1;
111 else if(fptr == &tube_handle_listen) return 1;
112 else if(fptr == &auth_xfer_probe_udp_callback) return 1;
113 else if(fptr == &auth_xfer_transfer_tcp_callback) return 1;
114 else if(fptr == &auth_xfer_transfer_http_callback) return 1;
115 return 0;
116 }
117
118 int
fptr_whitelist_comm_point_raw(comm_point_callback_type * fptr)119 fptr_whitelist_comm_point_raw(comm_point_callback_type *fptr)
120 {
121 if(fptr == &tube_handle_listen) return 1;
122 else if(fptr == &tube_handle_write) return 1;
123 else if(fptr == &remote_accept_callback) return 1;
124 else if(fptr == &remote_control_callback) return 1;
125 else if(fptr == &fast_reload_client_callback) return 1;
126 return 0;
127 }
128
129 int
fptr_whitelist_comm_timer(void (* fptr)(void *))130 fptr_whitelist_comm_timer(void (*fptr)(void*))
131 {
132 if(fptr == &pending_udp_timer_cb) return 1;
133 else if(fptr == &outnet_tcptimer) return 1;
134 else if(fptr == &pending_udp_timer_delay_cb) return 1;
135 else if(fptr == &worker_stat_timer_cb) return 1;
136 else if(fptr == &worker_probe_timer_cb) return 1;
137 else if(fptr == &validate_suspend_timer_cb) return 1;
138 #ifdef HAVE_NGTCP2
139 else if(fptr == &doq_timer_cb) return 1;
140 #endif
141 #ifdef UB_ON_WINDOWS
142 else if(fptr == &wsvc_cron_cb) return 1;
143 #endif
144 else if(fptr == &auth_xfer_timer) return 1;
145 else if(fptr == &auth_xfer_probe_timer_callback) return 1;
146 else if(fptr == &auth_xfer_transfer_timer_callback) return 1;
147 else if(fptr == &mesh_serve_expired_callback) return 1;
148 else if(fptr == &serviced_timer_cb) return 1;
149 #ifdef USE_DNSTAP
150 else if(fptr == &mq_wakeup_cb) return 1;
151 #endif
152 return 0;
153 }
154
155 int
fptr_whitelist_comm_signal(void (* fptr)(int,void *))156 fptr_whitelist_comm_signal(void (*fptr)(int, void*))
157 {
158 if(fptr == &worker_sighandler) return 1;
159 return 0;
160 }
161
fptr_whitelist_start_accept(void (* fptr)(void *))162 int fptr_whitelist_start_accept(void (*fptr)(void*))
163 {
164 if(fptr == &worker_start_accept) return 1;
165 return 0;
166 }
167
fptr_whitelist_stop_accept(void (* fptr)(void *))168 int fptr_whitelist_stop_accept(void (*fptr)(void*))
169 {
170 if(fptr == &worker_stop_accept) return 1;
171 return 0;
172 }
173
174 int
fptr_whitelist_event(void (* fptr)(int,short,void *))175 fptr_whitelist_event(void (*fptr)(int, short, void *))
176 {
177 if(fptr == &comm_point_udp_callback) return 1;
178 #if defined(AF_INET6) && defined(IPV6_PKTINFO) && defined(HAVE_RECVMSG)
179 else if(fptr == &comm_point_udp_ancil_callback) return 1;
180 #endif
181 else if(fptr == &comm_point_tcp_accept_callback) return 1;
182 else if(fptr == &comm_point_tcp_handle_callback) return 1;
183 else if(fptr == &comm_timer_callback) return 1;
184 else if(fptr == &comm_signal_callback) return 1;
185 else if(fptr == &comm_point_local_handle_callback) return 1;
186 else if(fptr == &comm_point_raw_handle_callback) return 1;
187 else if(fptr == &tube_handle_signal) return 1;
188 else if(fptr == &comm_base_handle_slow_accept) return 1;
189 else if(fptr == &comm_point_http_handle_callback) return 1;
190 #ifdef HAVE_NGTCP2
191 else if(fptr == &comm_point_doq_callback) return 1;
192 #endif
193 else if(fptr == &fast_reload_service_cb) return 1;
194 #ifdef USE_DNSTAP
195 else if(fptr == &dtio_output_cb) return 1;
196 else if(fptr == &dtio_cmd_cb) return 1;
197 else if(fptr == &dtio_reconnect_timeout_cb) return 1;
198 else if(fptr == &dtio_stop_timer_cb) return 1;
199 else if(fptr == &dtio_stop_ev_cb) return 1;
200 else if(fptr == &dtio_tap_callback) return 1;
201 else if(fptr == &dtio_mainfdcallback) return 1;
202 #endif
203 #ifdef HAVE_NGTCP2
204 else if(fptr == &doq_client_event_cb) return 1;
205 else if(fptr == &doq_client_timer_cb) return 1;
206 #endif
207 #ifdef UB_ON_WINDOWS
208 else if(fptr == &worker_win_stop_cb) return 1;
209 #endif
210 return 0;
211 }
212
213 int
fptr_whitelist_pending_udp(comm_point_callback_type * fptr)214 fptr_whitelist_pending_udp(comm_point_callback_type *fptr)
215 {
216 if(fptr == &serviced_udp_callback) return 1;
217 return 0;
218 }
219
220 int
fptr_whitelist_pending_tcp(comm_point_callback_type * fptr)221 fptr_whitelist_pending_tcp(comm_point_callback_type *fptr)
222 {
223 if(fptr == &serviced_tcp_callback) return 1;
224 return 0;
225 }
226
227 int
fptr_whitelist_serviced_query(comm_point_callback_type * fptr)228 fptr_whitelist_serviced_query(comm_point_callback_type *fptr)
229 {
230 if(fptr == &worker_handle_service_reply) return 1;
231 else if(fptr == &libworker_handle_service_reply) return 1;
232 return 0;
233 }
234
235 int
fptr_whitelist_rbtree_cmp(int (* fptr)(const void *,const void *))236 fptr_whitelist_rbtree_cmp(int (*fptr) (const void *, const void *))
237 {
238 if(fptr == &mesh_state_compare) return 1;
239 else if(fptr == &mesh_state_ref_compare) return 1;
240 else if(fptr == &addr_tree_compare) return 1;
241 else if(fptr == &addr_tree_addrport_compare) return 1;
242 else if(fptr == &local_zone_cmp) return 1;
243 else if(fptr == &local_data_cmp) return 1;
244 else if(fptr == &fwd_cmp) return 1;
245 else if(fptr == &pending_cmp) return 1;
246 else if(fptr == &serviced_cmp) return 1;
247 else if(fptr == &reuse_cmp) return 1;
248 else if(fptr == &reuse_id_cmp) return 1;
249 else if(fptr == &name_tree_compare) return 1;
250 else if(fptr == &order_lock_cmp) return 1;
251 else if(fptr == &codeline_cmp) return 1;
252 else if(fptr == &nsec3_hash_cmp) return 1;
253 else if(fptr == &mini_ev_cmp) return 1;
254 else if(fptr == &anchor_cmp) return 1;
255 else if(fptr == &canonical_tree_compare) return 1;
256 else if(fptr == &context_query_cmp) return 1;
257 else if(fptr == &val_neg_data_compare) return 1;
258 else if(fptr == &val_neg_zone_compare) return 1;
259 else if(fptr == &probetree_cmp) return 1;
260 else if(fptr == &replay_var_compare) return 1;
261 else if(fptr == &view_cmp) return 1;
262 else if(fptr == &auth_zone_cmp) return 1;
263 else if(fptr == &auth_data_cmp) return 1;
264 else if(fptr == &auth_xfer_cmp) return 1;
265 #ifdef HAVE_NGTCP2
266 else if(fptr == &doq_conn_cmp) return 1;
267 else if(fptr == &doq_conid_cmp) return 1;
268 else if(fptr == &doq_timer_cmp) return 1;
269 else if(fptr == &doq_stream_cmp) return 1;
270 #endif
271 return 0;
272 }
273
274 int
fptr_whitelist_hash_sizefunc(lruhash_sizefunc_type fptr)275 fptr_whitelist_hash_sizefunc(lruhash_sizefunc_type fptr)
276 {
277 if(fptr == &msgreply_sizefunc) return 1;
278 else if(fptr == &ub_rrset_sizefunc) return 1;
279 else if(fptr == &infra_sizefunc) return 1;
280 else if(fptr == &key_entry_sizefunc) return 1;
281 else if(fptr == &rate_sizefunc) return 1;
282 else if(fptr == &ip_rate_sizefunc) return 1;
283 else if(fptr == &test_slabhash_sizefunc) return 1;
284 #ifdef CLIENT_SUBNET
285 else if(fptr == &msg_cache_sizefunc) return 1;
286 #endif
287 #ifdef USE_DNSCRYPT
288 else if(fptr == &dnsc_shared_secrets_sizefunc) return 1;
289 else if(fptr == &dnsc_nonces_sizefunc) return 1;
290 #endif
291 return 0;
292 }
293
294 int
fptr_whitelist_hash_compfunc(lruhash_compfunc_type fptr)295 fptr_whitelist_hash_compfunc(lruhash_compfunc_type fptr)
296 {
297 if(fptr == &query_info_compare) return 1;
298 else if(fptr == &ub_rrset_compare) return 1;
299 else if(fptr == &infra_compfunc) return 1;
300 else if(fptr == &key_entry_compfunc) return 1;
301 else if(fptr == &rate_compfunc) return 1;
302 else if(fptr == &ip_rate_compfunc) return 1;
303 else if(fptr == &test_slabhash_compfunc) return 1;
304 #ifdef USE_DNSCRYPT
305 else if(fptr == &dnsc_shared_secrets_compfunc) return 1;
306 else if(fptr == &dnsc_nonces_compfunc) return 1;
307 #endif
308 return 0;
309 }
310
311 int
fptr_whitelist_hash_delkeyfunc(lruhash_delkeyfunc_type fptr)312 fptr_whitelist_hash_delkeyfunc(lruhash_delkeyfunc_type fptr)
313 {
314 if(fptr == &query_entry_delete) return 1;
315 else if(fptr == &ub_rrset_key_delete) return 1;
316 else if(fptr == &infra_delkeyfunc) return 1;
317 else if(fptr == &key_entry_delkeyfunc) return 1;
318 else if(fptr == &rate_delkeyfunc) return 1;
319 else if(fptr == &ip_rate_delkeyfunc) return 1;
320 else if(fptr == &test_slabhash_delkey) return 1;
321 #ifdef USE_DNSCRYPT
322 else if(fptr == &dnsc_shared_secrets_delkeyfunc) return 1;
323 else if(fptr == &dnsc_nonces_delkeyfunc) return 1;
324 #endif
325 return 0;
326 }
327
328 int
fptr_whitelist_hash_deldatafunc(lruhash_deldatafunc_type fptr)329 fptr_whitelist_hash_deldatafunc(lruhash_deldatafunc_type fptr)
330 {
331 if(fptr == &reply_info_delete) return 1;
332 else if(fptr == &rrset_data_delete) return 1;
333 else if(fptr == &infra_deldatafunc) return 1;
334 else if(fptr == &key_entry_deldatafunc) return 1;
335 else if(fptr == &rate_deldatafunc) return 1;
336 else if(fptr == &test_slabhash_deldata) return 1;
337 #ifdef CLIENT_SUBNET
338 else if(fptr == &subnet_data_delete) return 1;
339 #endif
340 #ifdef USE_DNSCRYPT
341 else if(fptr == &dnsc_shared_secrets_deldatafunc) return 1;
342 else if(fptr == &dnsc_nonces_deldatafunc) return 1;
343 #endif
344 return 0;
345 }
346
347 int
fptr_whitelist_hash_markdelfunc(lruhash_markdelfunc_type fptr)348 fptr_whitelist_hash_markdelfunc(lruhash_markdelfunc_type fptr)
349 {
350 if(fptr == NULL) return 1;
351 else if(fptr == &rrset_markdel) return 1;
352 #ifdef CLIENT_SUBNET
353 else if(fptr == &subnet_markdel) return 1;
354 #endif
355 return 0;
356 }
357
358 /** whitelist env->send_query callbacks */
359 int
fptr_whitelist_modenv_send_query(struct outbound_entry * (* fptr)(struct query_info * qinfo,uint16_t flags,int dnssec,int want_dnssec,int nocaps,int check_ratelimit,struct sockaddr_storage * addr,socklen_t addrlen,uint8_t * zone,size_t zonelen,int tcp_upstream,int ssl_upstream,char * tls_auth_name,struct module_qstate * q,int * was_ratelimited))360 fptr_whitelist_modenv_send_query(struct outbound_entry* (*fptr)(
361 struct query_info* qinfo, uint16_t flags, int dnssec, int want_dnssec,
362 int nocaps, int check_ratelimit, struct sockaddr_storage* addr,
363 socklen_t addrlen, uint8_t* zone, size_t zonelen, int tcp_upstream,
364 int ssl_upstream, char* tls_auth_name, struct module_qstate* q,
365 int* was_ratelimited))
366 {
367 if(fptr == &worker_send_query) return 1;
368 else if(fptr == &libworker_send_query) return 1;
369 return 0;
370 }
371
372 int
fptr_whitelist_modenv_detach_subs(void (* fptr)(struct module_qstate * qstate))373 fptr_whitelist_modenv_detach_subs(void (*fptr)(
374 struct module_qstate* qstate))
375 {
376 if(fptr == &mesh_detach_subs) return 1;
377 return 0;
378 }
379
380 int
fptr_whitelist_modenv_attach_sub(int (* fptr)(struct module_qstate * qstate,struct query_info * qinfo,uint16_t qflags,int prime,int valrec,struct module_qstate ** newq))381 fptr_whitelist_modenv_attach_sub(int (*fptr)(
382 struct module_qstate* qstate, struct query_info* qinfo,
383 uint16_t qflags, int prime, int valrec, struct module_qstate** newq))
384 {
385 if(fptr == &mesh_attach_sub) return 1;
386 return 0;
387 }
388
389 int
fptr_whitelist_modenv_add_sub(int (* fptr)(struct module_qstate * qstate,struct query_info * qinfo,uint16_t qflags,int prime,int valrec,struct module_qstate ** newq,struct mesh_state ** sub))390 fptr_whitelist_modenv_add_sub(int (*fptr)(
391 struct module_qstate* qstate, struct query_info* qinfo,
392 uint16_t qflags, int prime, int valrec, struct module_qstate** newq,
393 struct mesh_state** sub))
394 {
395 if(fptr == &mesh_add_sub) return 1;
396 return 0;
397 }
398
399 int
fptr_whitelist_modenv_kill_sub(void (* fptr)(struct module_qstate * newq))400 fptr_whitelist_modenv_kill_sub(void (*fptr)(struct module_qstate* newq))
401 {
402 if(fptr == &mesh_state_delete) return 1;
403 return 0;
404 }
405
406 int
fptr_whitelist_modenv_detect_cycle(int (* fptr)(struct module_qstate * qstate,struct query_info * qinfo,uint16_t flags,int prime,int valrec))407 fptr_whitelist_modenv_detect_cycle(int (*fptr)(
408 struct module_qstate* qstate, struct query_info* qinfo,
409 uint16_t flags, int prime, int valrec))
410 {
411 if(fptr == &mesh_detect_cycle) return 1;
412 return 0;
413 }
414
415 int
fptr_whitelist_mod_init(int (* fptr)(struct module_env * env,int id))416 fptr_whitelist_mod_init(int (*fptr)(struct module_env* env, int id))
417 {
418 if(fptr == &iter_init) return 1;
419 else if(fptr == &val_init) return 1;
420 else if(fptr == &dns64_init) return 1;
421 else if(fptr == &respip_init) return 1;
422 #ifdef WITH_PYTHONMODULE
423 else if(fptr == &pythonmod_init) return 1;
424 #endif
425 #ifdef WITH_DYNLIBMODULE
426 else if(fptr == &dynlibmod_init) return 1;
427 #endif
428 #ifdef USE_CACHEDB
429 else if(fptr == &cachedb_init) return 1;
430 #endif
431 #ifdef USE_IPSECMOD
432 else if(fptr == &ipsecmod_init) return 1;
433 #endif
434 #ifdef CLIENT_SUBNET
435 else if(fptr == &subnetmod_init) return 1;
436 #endif
437 #ifdef USE_IPSET
438 else if(fptr == &ipset_init) return 1;
439 #endif
440 return 0;
441 }
442
443 int
fptr_whitelist_mod_deinit(void (* fptr)(struct module_env * env,int id))444 fptr_whitelist_mod_deinit(void (*fptr)(struct module_env* env, int id))
445 {
446 if(fptr == &iter_deinit) return 1;
447 else if(fptr == &val_deinit) return 1;
448 else if(fptr == &dns64_deinit) return 1;
449 else if(fptr == &respip_deinit) return 1;
450 #ifdef WITH_PYTHONMODULE
451 else if(fptr == &pythonmod_deinit) return 1;
452 #endif
453 #ifdef WITH_DYNLIBMODULE
454 else if(fptr == &dynlibmod_deinit) return 1;
455 #endif
456 #ifdef USE_CACHEDB
457 else if(fptr == &cachedb_deinit) return 1;
458 #endif
459 #ifdef USE_IPSECMOD
460 else if(fptr == &ipsecmod_deinit) return 1;
461 #endif
462 #ifdef CLIENT_SUBNET
463 else if(fptr == &subnetmod_deinit) return 1;
464 #endif
465 #ifdef USE_IPSET
466 else if(fptr == &ipset_deinit) return 1;
467 #endif
468 return 0;
469 }
470
471 int
fptr_whitelist_mod_startup(int (* fptr)(struct module_env * env,int id))472 fptr_whitelist_mod_startup(int (*fptr)(struct module_env* env, int id))
473 {
474 #ifdef USE_IPSET
475 if(fptr == &ipset_startup) return 1;
476 #else
477 (void)fptr;
478 #endif
479 return 0;
480 }
481
482 int
fptr_whitelist_mod_destartup(void (* fptr)(struct module_env * env,int id))483 fptr_whitelist_mod_destartup(void (*fptr)(struct module_env* env, int id))
484 {
485 #ifdef USE_IPSET
486 if(fptr == &ipset_destartup) return 1;
487 #else
488 (void)fptr;
489 #endif
490 return 0;
491 }
492
493 int
fptr_whitelist_mod_operate(void (* fptr)(struct module_qstate * qstate,enum module_ev event,int id,struct outbound_entry * outbound))494 fptr_whitelist_mod_operate(void (*fptr)(struct module_qstate* qstate,
495 enum module_ev event, int id, struct outbound_entry* outbound))
496 {
497 if(fptr == &iter_operate) return 1;
498 else if(fptr == &val_operate) return 1;
499 else if(fptr == &dns64_operate) return 1;
500 else if(fptr == &respip_operate) return 1;
501 #ifdef WITH_PYTHONMODULE
502 else if(fptr == &pythonmod_operate) return 1;
503 #endif
504 #ifdef WITH_DYNLIBMODULE
505 else if(fptr == &dynlibmod_operate) return 1;
506 #endif
507 #ifdef USE_CACHEDB
508 else if(fptr == &cachedb_operate) return 1;
509 #endif
510 #ifdef USE_IPSECMOD
511 else if(fptr == &ipsecmod_operate) return 1;
512 #endif
513 #ifdef CLIENT_SUBNET
514 else if(fptr == &subnetmod_operate) return 1;
515 #endif
516 #ifdef USE_IPSET
517 else if(fptr == &ipset_operate) return 1;
518 #endif
519 return 0;
520 }
521
522 int
fptr_whitelist_mod_inform_super(void (* fptr)(struct module_qstate * qstate,int id,struct module_qstate * super))523 fptr_whitelist_mod_inform_super(void (*fptr)(
524 struct module_qstate* qstate, int id, struct module_qstate* super))
525 {
526 if(fptr == &iter_inform_super) return 1;
527 else if(fptr == &val_inform_super) return 1;
528 else if(fptr == &dns64_inform_super) return 1;
529 else if(fptr == &respip_inform_super) return 1;
530 #ifdef WITH_PYTHONMODULE
531 else if(fptr == &pythonmod_inform_super) return 1;
532 #endif
533 #ifdef WITH_DYNLIBMODULE
534 else if(fptr == &dynlibmod_inform_super) return 1;
535 #endif
536 #ifdef USE_CACHEDB
537 else if(fptr == &cachedb_inform_super) return 1;
538 #endif
539 #ifdef USE_IPSECMOD
540 else if(fptr == &ipsecmod_inform_super) return 1;
541 #endif
542 #ifdef CLIENT_SUBNET
543 else if(fptr == &subnetmod_inform_super) return 1;
544 #endif
545 #ifdef USE_IPSET
546 else if(fptr == &ipset_inform_super) return 1;
547 #endif
548 return 0;
549 }
550
551 int
fptr_whitelist_mod_clear(void (* fptr)(struct module_qstate * qstate,int id))552 fptr_whitelist_mod_clear(void (*fptr)(struct module_qstate* qstate,
553 int id))
554 {
555 if(fptr == &iter_clear) return 1;
556 else if(fptr == &val_clear) return 1;
557 else if(fptr == &dns64_clear) return 1;
558 else if(fptr == &respip_clear) return 1;
559 #ifdef WITH_PYTHONMODULE
560 else if(fptr == &pythonmod_clear) return 1;
561 #endif
562 #ifdef WITH_DYNLIBMODULE
563 else if(fptr == &dynlibmod_clear) return 1;
564 #endif
565 #ifdef USE_CACHEDB
566 else if(fptr == &cachedb_clear) return 1;
567 #endif
568 #ifdef USE_IPSECMOD
569 else if(fptr == &ipsecmod_clear) return 1;
570 #endif
571 #ifdef CLIENT_SUBNET
572 else if(fptr == &subnetmod_clear) return 1;
573 #endif
574 #ifdef USE_IPSET
575 else if(fptr == &ipset_clear) return 1;
576 #endif
577 return 0;
578 }
579
580 int
fptr_whitelist_mod_get_mem(size_t (* fptr)(struct module_env * env,int id))581 fptr_whitelist_mod_get_mem(size_t (*fptr)(struct module_env* env, int id))
582 {
583 if(fptr == &iter_get_mem) return 1;
584 else if(fptr == &val_get_mem) return 1;
585 else if(fptr == &dns64_get_mem) return 1;
586 else if(fptr == &respip_get_mem) return 1;
587 #ifdef WITH_PYTHONMODULE
588 else if(fptr == &pythonmod_get_mem) return 1;
589 #endif
590 #ifdef WITH_DYNLIBMODULE
591 else if(fptr == &dynlibmod_get_mem) return 1;
592 #endif
593 #ifdef USE_CACHEDB
594 else if(fptr == &cachedb_get_mem) return 1;
595 #endif
596 #ifdef USE_IPSECMOD
597 else if(fptr == &ipsecmod_get_mem) return 1;
598 #endif
599 #ifdef CLIENT_SUBNET
600 else if(fptr == &subnetmod_get_mem) return 1;
601 #endif
602 #ifdef USE_IPSET
603 else if(fptr == &ipset_get_mem) return 1;
604 #endif
605 return 0;
606 }
607
608 int
fptr_whitelist_alloc_cleanup(void (* fptr)(void *))609 fptr_whitelist_alloc_cleanup(void (*fptr)(void*))
610 {
611 if(fptr == &worker_alloc_cleanup) return 1;
612 return 0;
613 }
614
fptr_whitelist_tube_listen(tube_callback_type * fptr)615 int fptr_whitelist_tube_listen(tube_callback_type* fptr)
616 {
617 if(fptr == &worker_handle_control_cmd) return 1;
618 else if(fptr == &libworker_handle_control_cmd) return 1;
619 return 0;
620 }
621
fptr_whitelist_mesh_cb(mesh_cb_func_type fptr)622 int fptr_whitelist_mesh_cb(mesh_cb_func_type fptr)
623 {
624 if(fptr == &libworker_fg_done_cb) return 1;
625 else if(fptr == &libworker_bg_done_cb) return 1;
626 else if(fptr == &libworker_event_done_cb) return 1;
627 else if(fptr == &probe_answer_cb) return 1;
628 else if(fptr == &auth_xfer_probe_lookup_callback) return 1;
629 else if(fptr == &auth_xfer_transfer_lookup_callback) return 1;
630 else if(fptr == &auth_zonemd_dnskey_lookup_callback) return 1;
631 return 0;
632 }
633
fptr_whitelist_print_func(void (* fptr)(char *,void *))634 int fptr_whitelist_print_func(void (*fptr)(char*,void*))
635 {
636 if(fptr == &config_print_func) return 1;
637 else if(fptr == &config_collate_func) return 1;
638 else if(fptr == &remote_get_opt_ssl) return 1;
639 return 0;
640 }
641
fptr_whitelist_inplace_cb_reply_generic(inplace_cb_reply_func_type * fptr,enum inplace_cb_list_type type)642 int fptr_whitelist_inplace_cb_reply_generic(inplace_cb_reply_func_type* fptr,
643 enum inplace_cb_list_type type)
644 {
645 #ifndef WITH_PYTHONMODULE
646 (void)fptr;
647 #endif
648 if(type == inplace_cb_reply) {
649 #ifdef WITH_PYTHONMODULE
650 if(fptr == &python_inplace_cb_reply_generic) return 1;
651 #endif
652 #ifdef WITH_DYNLIBMODULE
653 if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
654 #endif
655 } else if(type == inplace_cb_reply_cache) {
656 #ifdef WITH_PYTHONMODULE
657 if(fptr == &python_inplace_cb_reply_generic) return 1;
658 #endif
659 #ifdef WITH_DYNLIBMODULE
660 if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
661 #endif
662 } else if(type == inplace_cb_reply_local) {
663 #ifdef WITH_PYTHONMODULE
664 if(fptr == &python_inplace_cb_reply_generic) return 1;
665 #endif
666 #ifdef WITH_DYNLIBMODULE
667 if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
668 #endif
669 } else if(type == inplace_cb_reply_servfail) {
670 #ifdef WITH_PYTHONMODULE
671 if(fptr == &python_inplace_cb_reply_generic) return 1;
672 #endif
673 #ifdef WITH_DYNLIBMODULE
674 if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
675 #endif
676 }
677 return 0;
678 }
679
fptr_whitelist_inplace_cb_query(inplace_cb_query_func_type * fptr)680 int fptr_whitelist_inplace_cb_query(inplace_cb_query_func_type* fptr)
681 {
682 #ifdef CLIENT_SUBNET
683 if(fptr == &ecs_whitelist_check)
684 return 1;
685 #endif
686 #ifdef WITH_PYTHONMODULE
687 if(fptr == &python_inplace_cb_query_generic)
688 return 1;
689 #endif
690 #ifdef WITH_DYNLIBMODULE
691 if(fptr == &dynlib_inplace_cb_query_generic)
692 return 1;
693 #endif
694 (void)fptr;
695 return 0;
696 }
697
fptr_whitelist_inplace_cb_edns_back_parsed(inplace_cb_edns_back_parsed_func_type * fptr)698 int fptr_whitelist_inplace_cb_edns_back_parsed(
699 inplace_cb_edns_back_parsed_func_type* fptr)
700 {
701 #ifdef CLIENT_SUBNET
702 if(fptr == &ecs_edns_back_parsed)
703 return 1;
704 #else
705 (void)fptr;
706 #endif
707 #ifdef WITH_PYTHONMODULE
708 if(fptr == &python_inplace_cb_edns_back_parsed_call)
709 return 1;
710 #endif
711 #ifdef WITH_DYNLIBMODULE
712 if(fptr == &dynlib_inplace_cb_edns_back_parsed)
713 return 1;
714 #endif
715 return 0;
716 }
717
fptr_whitelist_inplace_cb_query_response(inplace_cb_query_response_func_type * fptr)718 int fptr_whitelist_inplace_cb_query_response(
719 inplace_cb_query_response_func_type* fptr)
720 {
721 #ifdef CLIENT_SUBNET
722 if(fptr == &ecs_query_response)
723 return 1;
724 #else
725 (void)fptr;
726 #endif
727 #ifdef WITH_PYTHONMODULE
728 if(fptr == &python_inplace_cb_query_response)
729 return 1;
730 #endif
731 #ifdef WITH_DYNLIBMODULE
732 if(fptr == &dynlib_inplace_cb_query_response)
733 return 1;
734 #endif
735 return 0;
736 }
737
fptr_whitelist_serve_expired_lookup(serve_expired_lookup_func_type * fptr)738 int fptr_whitelist_serve_expired_lookup(serve_expired_lookup_func_type* fptr)
739 {
740 if(fptr == &mesh_serve_expired_lookup)
741 return 1;
742 return 0;
743 }
744