xref: /aosp_15_r20/external/AFLplusplus/include/cmplog.h (revision 08b48e0b10e97b33e7b60c5b6e2243bd915777f2)
1 /*
2    american fuzzy lop++ - cmplog 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_CMPLOG_H
29 #define _AFL_CMPLOG_H
30 
31 #include "config.h"
32 
33 #define CMPLOG_LVL_MAX 3
34 
35 #define CMP_MAP_W 65536
36 #define CMP_MAP_H 32
37 #define CMP_MAP_RTN_H (CMP_MAP_H / 2)
38 
39 #define SHAPE_BYTES(x) (x + 1)
40 
41 #define CMP_TYPE_INS 1
42 #define CMP_TYPE_RTN 2
43 
44 struct cmp_header {
45 
46   unsigned hits : 24;
47   unsigned id : 24;
48   unsigned shape : 5;
49   unsigned type : 2;
50   unsigned attribute : 4;
51   unsigned overflow : 1;
52   unsigned reserved : 4;
53 
54 } __attribute__((packed));
55 
56 struct cmp_operands {
57 
58   u64 v0;
59   u64 v1;
60   u64 v0_128;
61   u64 v1_128;
62 
63 } __attribute__((packed));
64 
65 struct cmpfn_operands {
66 
67   u8 v0[31];
68   u8 v0_len;
69   u8 v1[31];
70   u8 v1_len;
71 
72 } __attribute__((packed));
73 
74 typedef struct cmp_operands cmp_map_list[CMP_MAP_H];
75 
76 struct cmp_map {
77 
78   struct cmp_header   headers[CMP_MAP_W];
79   struct cmp_operands log[CMP_MAP_W][CMP_MAP_H];
80 
81 };
82 
83 /* Execs the child */
84 
85 struct afl_forkserver;
86 void cmplog_exec_child(struct afl_forkserver *fsrv, char **argv);
87 
88 #endif
89 
90