xref: /aosp_15_r20/external/AFLplusplus/include/sharedmem.h (revision 08b48e0b10e97b33e7b60c5b6e2243bd915777f2)
1 /*
2    american fuzzy lop++ - shared memory related header
3    ---------------------------------------------------
4 
5    Originally written by Michal Zalewski
6 
7    Forkserver design by Jann Horn <[email protected]>
8 
9    Now maintained by Marc Heuse <[email protected]>,
10                      Heiko Eißfeldt <[email protected]>,
11                      Andrea Fioraldi <[email protected]>,
12                      Dominik Maier <[email protected]>
13 
14    Copyright 2016, 2017 Google Inc. All rights reserved.
15    Copyright 2019-2024 AFLplusplus Project. All rights reserved.
16 
17    Licensed under the Apache License, Version 2.0 (the "License");
18    you may not use this file except in compliance with the License.
19    You may obtain a copy of the License at:
20 
21      https://www.apache.org/licenses/LICENSE-2.0
22 
23    Shared code to handle the shared memory. This is used by the fuzzer
24    as well the other components like afl-tmin, afl-showmap, etc...
25 
26  */
27 
28 #ifndef __AFL_SHAREDMEM_H
29 #define __AFL_SHAREDMEM_H
30 
31 #include "types.h"
32 
33 typedef struct sharedmem {
34 
35   // extern unsigned char *trace_bits;
36 
37 #ifdef USEMMAP
38   /* ================ Proteas ================ */
39   int  g_shm_fd;
40   char g_shm_file_path[L_tmpnam];
41   int  cmplog_g_shm_fd;
42   char cmplog_g_shm_file_path[L_tmpnam];
43 /* ========================================= */
44 #else
45   s32 shm_id;                          /* ID of the SHM region              */
46   s32 cmplog_shm_id;
47 #endif
48 
49   u8 *map;                                          /* shared memory region */
50 
51   size_t map_size;                                 /* actual allocated size */
52 
53   int             cmplog_mode;
54   int             shmemfuzz_mode;
55   struct cmp_map *cmp_map;
56 
57 } sharedmem_t;
58 
59 u8  *afl_shm_init(sharedmem_t *, size_t, unsigned char non_instrumented_mode);
60 void afl_shm_deinit(sharedmem_t *);
61 
62 #endif
63 
64