diff mbox

[v3,08/12] fuzz/x86_emulate: Move definitions into a header

Message ID 20171010162011.9629-8-george.dunlap@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

George Dunlap Oct. 10, 2017, 4:20 p.m. UTC
Move fuzz-emul.c function prototypes into a header.  Also share the
definition of the input size (rather than hard-coding it in
fuzz-emul.c).

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
---
RFC: Worth trying to BUILD_BUG_ON(INPUT_SIZE < DATA_SIZE_FULL)?

v3:
- New in this version

CC: Ian Jackson <ian.jackson@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
---
 tools/fuzz/x86_instruction_emulator/afl-harness.c |  6 +-----
 tools/fuzz/x86_instruction_emulator/fuzz-emul.c   |  3 ++-
 tools/fuzz/x86_instruction_emulator/fuzz-emul.h   | 10 ++++++++++
 3 files changed, 13 insertions(+), 6 deletions(-)
 create mode 100644 tools/fuzz/x86_instruction_emulator/fuzz-emul.h

Comments

Ian Jackson Oct. 10, 2017, 5:25 p.m. UTC | #1
George Dunlap writes ("[PATCH v3 08/12] fuzz/x86_emulate: Move definitions into a header"):
> Move fuzz-emul.c function prototypes into a header.  Also share the
> definition of the input size (rather than hard-coding it in
> fuzz-emul.c).
> 
> Signed-off-by: George Dunlap <george.dunlap@citrix.com>

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>

> RFC: Worth trying to BUILD_BUG_ON(INPUT_SIZE < DATA_SIZE_FULL)?

I don't mind.
Jan Beulich Oct. 11, 2017, 9:09 a.m. UTC | #2
>>> On 10.10.17 at 19:25, <ian.jackson@eu.citrix.com> wrote:
> George Dunlap writes ("[PATCH v3 08/12] fuzz/x86_emulate: Move definitions 
> into a header"):
>> Move fuzz-emul.c function prototypes into a header.  Also share the
>> definition of the input size (rather than hard-coding it in
>> fuzz-emul.c).
>> 
>> Signed-off-by: George Dunlap <george.dunlap@citrix.com>
> 
> Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
(also if you add ...

>> RFC: Worth trying to BUILD_BUG_ON(INPUT_SIZE < DATA_SIZE_FULL)?
> 
> I don't mind.

... this)
diff mbox

Patch

diff --git a/tools/fuzz/x86_instruction_emulator/afl-harness.c b/tools/fuzz/x86_instruction_emulator/afl-harness.c
index 26b710cb3f..891e56f448 100644
--- a/tools/fuzz/x86_instruction_emulator/afl-harness.c
+++ b/tools/fuzz/x86_instruction_emulator/afl-harness.c
@@ -4,12 +4,8 @@ 
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
+#include "fuzz-emul.h"
 
-extern int LLVMFuzzerInitialize(int *argc, char ***argv);
-extern int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size);
-extern unsigned int fuzz_minimal_input_size(void);
-
-#define INPUT_SIZE  4096
 static uint8_t input[INPUT_SIZE];
 
 int main(int argc, char **argv)
diff --git a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
index 20d52b33f8..9bbe973fd0 100644
--- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
+++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
@@ -16,6 +16,7 @@ 
 #include <xen/xen.h>
 
 #include "x86-emulate.h"
+#include "fuzz-emul.h"
 
 #define MSR_INDEX_MAX 16
 
@@ -24,7 +25,7 @@ 
 /* Layout of data expected as fuzzing input. */
 struct fuzz_corpus
 {
-    unsigned char data[4096];
+    unsigned char data[INPUT_SIZE];
 } input;
 
 /*
diff --git a/tools/fuzz/x86_instruction_emulator/fuzz-emul.h b/tools/fuzz/x86_instruction_emulator/fuzz-emul.h
new file mode 100644
index 0000000000..30dd8de21e
--- /dev/null
+++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.h
@@ -0,0 +1,10 @@ 
+#ifndef FUZZ_EMUL_H
+# define FUZZ_EMUL_H
+
+extern int LLVMFuzzerInitialize(int *argc, char ***argv);
+extern int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size);
+extern unsigned int fuzz_minimal_input_size(void);
+
+#define INPUT_SIZE  4096
+
+#endif /* ifdef FUZZ_EMUL_H */