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,struct respip_client_info * cinfo,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 struct respip_client_info* cinfo, uint16_t qflags, int prime,
384 int valrec, struct module_qstate** newq))
385 {
386 if(fptr == &mesh_attach_sub) return 1;
387 return 0;
388 }
389
390 int
fptr_whitelist_modenv_add_sub(int (* fptr)(struct module_qstate * qstate,struct query_info * qinfo,struct respip_client_info * cinfo,uint16_t qflags,int prime,int valrec,struct module_qstate ** newq,struct mesh_state ** sub))391 fptr_whitelist_modenv_add_sub(int (*fptr)(
392 struct module_qstate* qstate, struct query_info* qinfo,
393 struct respip_client_info* cinfo, uint16_t qflags, int prime,
394 int valrec, struct module_qstate** newq, struct mesh_state** sub))
395 {
396 if(fptr == &mesh_add_sub) return 1;
397 return 0;
398 }
399
400 int
fptr_whitelist_modenv_kill_sub(void (* fptr)(struct module_qstate * newq))401 fptr_whitelist_modenv_kill_sub(void (*fptr)(struct module_qstate* newq))
402 {
403 if(fptr == &mesh_state_delete) return 1;
404 return 0;
405 }
406
407 int
fptr_whitelist_modenv_detect_cycle(int (* fptr)(struct module_qstate * qstate,struct query_info * qinfo,uint16_t flags,int prime,int valrec))408 fptr_whitelist_modenv_detect_cycle(int (*fptr)(
409 struct module_qstate* qstate, struct query_info* qinfo,
410 uint16_t flags, int prime, int valrec))
411 {
412 if(fptr == &mesh_detect_cycle) return 1;
413 return 0;
414 }
415
416 int
fptr_whitelist_mod_init(int (* fptr)(struct module_env * env,int id))417 fptr_whitelist_mod_init(int (*fptr)(struct module_env* env, int id))
418 {
419 if(fptr == &iter_init) return 1;
420 else if(fptr == &val_init) return 1;
421 else if(fptr == &dns64_init) return 1;
422 else if(fptr == &respip_init) return 1;
423 #ifdef WITH_PYTHONMODULE
424 else if(fptr == &pythonmod_init) return 1;
425 #endif
426 #ifdef WITH_DYNLIBMODULE
427 else if(fptr == &dynlibmod_init) return 1;
428 #endif
429 #ifdef USE_CACHEDB
430 else if(fptr == &cachedb_init) return 1;
431 #endif
432 #ifdef USE_IPSECMOD
433 else if(fptr == &ipsecmod_init) return 1;
434 #endif
435 #ifdef CLIENT_SUBNET
436 else if(fptr == &subnetmod_init) return 1;
437 #endif
438 #ifdef USE_IPSET
439 else if(fptr == &ipset_init) return 1;
440 #endif
441 return 0;
442 }
443
444 int
fptr_whitelist_mod_deinit(void (* fptr)(struct module_env * env,int id))445 fptr_whitelist_mod_deinit(void (*fptr)(struct module_env* env, int id))
446 {
447 if(fptr == &iter_deinit) return 1;
448 else if(fptr == &val_deinit) return 1;
449 else if(fptr == &dns64_deinit) return 1;
450 else if(fptr == &respip_deinit) return 1;
451 #ifdef WITH_PYTHONMODULE
452 else if(fptr == &pythonmod_deinit) return 1;
453 #endif
454 #ifdef WITH_DYNLIBMODULE
455 else if(fptr == &dynlibmod_deinit) return 1;
456 #endif
457 #ifdef USE_CACHEDB
458 else if(fptr == &cachedb_deinit) return 1;
459 #endif
460 #ifdef USE_IPSECMOD
461 else if(fptr == &ipsecmod_deinit) return 1;
462 #endif
463 #ifdef CLIENT_SUBNET
464 else if(fptr == &subnetmod_deinit) return 1;
465 #endif
466 #ifdef USE_IPSET
467 else if(fptr == &ipset_deinit) return 1;
468 #endif
469 return 0;
470 }
471
472 int
fptr_whitelist_mod_startup(int (* fptr)(struct module_env * env,int id))473 fptr_whitelist_mod_startup(int (*fptr)(struct module_env* env, int id))
474 {
475 #ifdef USE_IPSET
476 if(fptr == &ipset_startup) return 1;
477 #else
478 (void)fptr;
479 #endif
480 return 0;
481 }
482
483 int
fptr_whitelist_mod_destartup(void (* fptr)(struct module_env * env,int id))484 fptr_whitelist_mod_destartup(void (*fptr)(struct module_env* env, int id))
485 {
486 #ifdef USE_IPSET
487 if(fptr == &ipset_destartup) return 1;
488 #else
489 (void)fptr;
490 #endif
491 return 0;
492 }
493
494 int
fptr_whitelist_mod_operate(void (* fptr)(struct module_qstate * qstate,enum module_ev event,int id,struct outbound_entry * outbound))495 fptr_whitelist_mod_operate(void (*fptr)(struct module_qstate* qstate,
496 enum module_ev event, int id, struct outbound_entry* outbound))
497 {
498 if(fptr == &iter_operate) return 1;
499 else if(fptr == &val_operate) return 1;
500 else if(fptr == &dns64_operate) return 1;
501 else if(fptr == &respip_operate) return 1;
502 #ifdef WITH_PYTHONMODULE
503 else if(fptr == &pythonmod_operate) return 1;
504 #endif
505 #ifdef WITH_DYNLIBMODULE
506 else if(fptr == &dynlibmod_operate) return 1;
507 #endif
508 #ifdef USE_CACHEDB
509 else if(fptr == &cachedb_operate) return 1;
510 #endif
511 #ifdef USE_IPSECMOD
512 else if(fptr == &ipsecmod_operate) return 1;
513 #endif
514 #ifdef CLIENT_SUBNET
515 else if(fptr == &subnetmod_operate) return 1;
516 #endif
517 #ifdef USE_IPSET
518 else if(fptr == &ipset_operate) return 1;
519 #endif
520 return 0;
521 }
522
523 int
fptr_whitelist_mod_inform_super(void (* fptr)(struct module_qstate * qstate,int id,struct module_qstate * super))524 fptr_whitelist_mod_inform_super(void (*fptr)(
525 struct module_qstate* qstate, int id, struct module_qstate* super))
526 {
527 if(fptr == &iter_inform_super) return 1;
528 else if(fptr == &val_inform_super) return 1;
529 else if(fptr == &dns64_inform_super) return 1;
530 else if(fptr == &respip_inform_super) return 1;
531 #ifdef WITH_PYTHONMODULE
532 else if(fptr == &pythonmod_inform_super) return 1;
533 #endif
534 #ifdef WITH_DYNLIBMODULE
535 else if(fptr == &dynlibmod_inform_super) return 1;
536 #endif
537 #ifdef USE_CACHEDB
538 else if(fptr == &cachedb_inform_super) return 1;
539 #endif
540 #ifdef USE_IPSECMOD
541 else if(fptr == &ipsecmod_inform_super) return 1;
542 #endif
543 #ifdef CLIENT_SUBNET
544 else if(fptr == &subnetmod_inform_super) return 1;
545 #endif
546 #ifdef USE_IPSET
547 else if(fptr == &ipset_inform_super) return 1;
548 #endif
549 return 0;
550 }
551
552 int
fptr_whitelist_mod_clear(void (* fptr)(struct module_qstate * qstate,int id))553 fptr_whitelist_mod_clear(void (*fptr)(struct module_qstate* qstate,
554 int id))
555 {
556 if(fptr == &iter_clear) return 1;
557 else if(fptr == &val_clear) return 1;
558 else if(fptr == &dns64_clear) return 1;
559 else if(fptr == &respip_clear) return 1;
560 #ifdef WITH_PYTHONMODULE
561 else if(fptr == &pythonmod_clear) return 1;
562 #endif
563 #ifdef WITH_DYNLIBMODULE
564 else if(fptr == &dynlibmod_clear) return 1;
565 #endif
566 #ifdef USE_CACHEDB
567 else if(fptr == &cachedb_clear) return 1;
568 #endif
569 #ifdef USE_IPSECMOD
570 else if(fptr == &ipsecmod_clear) return 1;
571 #endif
572 #ifdef CLIENT_SUBNET
573 else if(fptr == &subnetmod_clear) return 1;
574 #endif
575 #ifdef USE_IPSET
576 else if(fptr == &ipset_clear) return 1;
577 #endif
578 return 0;
579 }
580
581 int
fptr_whitelist_mod_get_mem(size_t (* fptr)(struct module_env * env,int id))582 fptr_whitelist_mod_get_mem(size_t (*fptr)(struct module_env* env, int id))
583 {
584 if(fptr == &iter_get_mem) return 1;
585 else if(fptr == &val_get_mem) return 1;
586 else if(fptr == &dns64_get_mem) return 1;
587 else if(fptr == &respip_get_mem) return 1;
588 #ifdef WITH_PYTHONMODULE
589 else if(fptr == &pythonmod_get_mem) return 1;
590 #endif
591 #ifdef WITH_DYNLIBMODULE
592 else if(fptr == &dynlibmod_get_mem) return 1;
593 #endif
594 #ifdef USE_CACHEDB
595 else if(fptr == &cachedb_get_mem) return 1;
596 #endif
597 #ifdef USE_IPSECMOD
598 else if(fptr == &ipsecmod_get_mem) return 1;
599 #endif
600 #ifdef CLIENT_SUBNET
601 else if(fptr == &subnetmod_get_mem) return 1;
602 #endif
603 #ifdef USE_IPSET
604 else if(fptr == &ipset_get_mem) return 1;
605 #endif
606 return 0;
607 }
608
609 int
fptr_whitelist_alloc_cleanup(void (* fptr)(void *))610 fptr_whitelist_alloc_cleanup(void (*fptr)(void*))
611 {
612 if(fptr == &worker_alloc_cleanup) return 1;
613 return 0;
614 }
615
fptr_whitelist_tube_listen(tube_callback_type * fptr)616 int fptr_whitelist_tube_listen(tube_callback_type* fptr)
617 {
618 if(fptr == &worker_handle_control_cmd) return 1;
619 else if(fptr == &libworker_handle_control_cmd) return 1;
620 return 0;
621 }
622
fptr_whitelist_mesh_cb(mesh_cb_func_type fptr)623 int fptr_whitelist_mesh_cb(mesh_cb_func_type fptr)
624 {
625 if(fptr == &libworker_fg_done_cb) return 1;
626 else if(fptr == &libworker_bg_done_cb) return 1;
627 else if(fptr == &libworker_event_done_cb) return 1;
628 else if(fptr == &probe_answer_cb) return 1;
629 else if(fptr == &auth_xfer_probe_lookup_callback) return 1;
630 else if(fptr == &auth_xfer_transfer_lookup_callback) return 1;
631 else if(fptr == &auth_zonemd_dnskey_lookup_callback) return 1;
632 return 0;
633 }
634
fptr_whitelist_print_func(void (* fptr)(char *,void *))635 int fptr_whitelist_print_func(void (*fptr)(char*,void*))
636 {
637 if(fptr == &config_print_func) return 1;
638 else if(fptr == &config_collate_func) return 1;
639 else if(fptr == &remote_get_opt_ssl) return 1;
640 return 0;
641 }
642
fptr_whitelist_inplace_cb_reply_generic(inplace_cb_reply_func_type * fptr,enum inplace_cb_list_type type)643 int fptr_whitelist_inplace_cb_reply_generic(inplace_cb_reply_func_type* fptr,
644 enum inplace_cb_list_type type)
645 {
646 #ifndef WITH_PYTHONMODULE
647 (void)fptr;
648 #endif
649 if(type == inplace_cb_reply) {
650 #ifdef WITH_PYTHONMODULE
651 if(fptr == &python_inplace_cb_reply_generic) return 1;
652 #endif
653 #ifdef WITH_DYNLIBMODULE
654 if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
655 #endif
656 } else if(type == inplace_cb_reply_cache) {
657 #ifdef WITH_PYTHONMODULE
658 if(fptr == &python_inplace_cb_reply_generic) return 1;
659 #endif
660 #ifdef WITH_DYNLIBMODULE
661 if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
662 #endif
663 } else if(type == inplace_cb_reply_local) {
664 #ifdef WITH_PYTHONMODULE
665 if(fptr == &python_inplace_cb_reply_generic) return 1;
666 #endif
667 #ifdef WITH_DYNLIBMODULE
668 if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
669 #endif
670 } else if(type == inplace_cb_reply_servfail) {
671 #ifdef WITH_PYTHONMODULE
672 if(fptr == &python_inplace_cb_reply_generic) return 1;
673 #endif
674 #ifdef WITH_DYNLIBMODULE
675 if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
676 #endif
677 }
678 return 0;
679 }
680
fptr_whitelist_inplace_cb_query(inplace_cb_query_func_type * fptr)681 int fptr_whitelist_inplace_cb_query(inplace_cb_query_func_type* fptr)
682 {
683 #ifdef CLIENT_SUBNET
684 if(fptr == &ecs_whitelist_check)
685 return 1;
686 #endif
687 #ifdef WITH_PYTHONMODULE
688 if(fptr == &python_inplace_cb_query_generic)
689 return 1;
690 #endif
691 #ifdef WITH_DYNLIBMODULE
692 if(fptr == &dynlib_inplace_cb_query_generic)
693 return 1;
694 #endif
695 (void)fptr;
696 return 0;
697 }
698
fptr_whitelist_inplace_cb_edns_back_parsed(inplace_cb_edns_back_parsed_func_type * fptr)699 int fptr_whitelist_inplace_cb_edns_back_parsed(
700 inplace_cb_edns_back_parsed_func_type* fptr)
701 {
702 #ifdef CLIENT_SUBNET
703 if(fptr == &ecs_edns_back_parsed)
704 return 1;
705 #else
706 (void)fptr;
707 #endif
708 #ifdef WITH_PYTHONMODULE
709 if(fptr == &python_inplace_cb_edns_back_parsed_call)
710 return 1;
711 #endif
712 #ifdef WITH_DYNLIBMODULE
713 if(fptr == &dynlib_inplace_cb_edns_back_parsed)
714 return 1;
715 #endif
716 return 0;
717 }
718
fptr_whitelist_inplace_cb_query_response(inplace_cb_query_response_func_type * fptr)719 int fptr_whitelist_inplace_cb_query_response(
720 inplace_cb_query_response_func_type* fptr)
721 {
722 #ifdef CLIENT_SUBNET
723 if(fptr == &ecs_query_response)
724 return 1;
725 #else
726 (void)fptr;
727 #endif
728 #ifdef WITH_PYTHONMODULE
729 if(fptr == &python_inplace_cb_query_response)
730 return 1;
731 #endif
732 #ifdef WITH_DYNLIBMODULE
733 if(fptr == &dynlib_inplace_cb_query_response)
734 return 1;
735 #endif
736 return 0;
737 }
738
fptr_whitelist_serve_expired_lookup(serve_expired_lookup_func_type * fptr)739 int fptr_whitelist_serve_expired_lookup(serve_expired_lookup_func_type* fptr)
740 {
741 if(fptr == &mesh_serve_expired_lookup)
742 return 1;
743 return 0;
744 }
745