Input size
Hello,
In the x86 instruction emulator fuzzer, when checking wether the input size is correct, we are checking for this bounds : DATA_OFFSET < size < INPUT_SIZE.
The fact is that INPUT_SIZE is actually the size of the data buffer in the fuzz_corpus structure. This way, AFL is not able to have full control over this entry, as we are actually filling this buffer for at most INPUT_SIZE - DATA_OFFSET.
If I understand the fuzzer correctly, we really need to give full control on this to AFL so that we can get some "random" from it.
I am wondering if the bounds should rather be :DATA_OFFSET < size < sizeof (struct fuzz_corpus)
but maybe I am missing something here 🙂
Thanks,
Signature · 6 lines
Paul Semel _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 14 lines · Paul Semel
Hello,
In the x86 instruction emulator fuzzer, when checking wether the input size is correct, we are checking for this bounds :
DATA_OFFSET< size <INPUT_SIZE.The fact is that
INPUT_SIZEis actually the size of the data buffer in thefuzz_corpusstructure. This way, AFL is not able to have full control over this entry, as we are actually filling this buffer for at mostINPUT_SIZE-DATA_OFFSET.
Quoted 6 lines
If I understand the fuzzer correctly, we really need to give full control on this to AFL so that we can get some "random" from it.
I am wondering if the bounds should rather be :
DATA_OFFSET< size < sizeof (structfuzz_corpus)
Yes. I think you're right.
The code has gone through several iterations. It isn't surprising that we got something messed up in between.
(CC'ing people who modified the code before to sanity-check)
Are you up for writing a patch? I.e. replacing INPUT_SIZE with a sizeof expression.
Also I think the BUILD_BUG_ON in fuzz_minimal_input_size should also be fixed in a similar fashion.
Wei.
Quoted 8 lines
but maybe I am missing something here 🙂
Thanks,
Signature · 1 line
Paul Semel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/1 fuzz/x86_emulate: fix bounds for input size
The minimum size for the input size was set to DATA_OFFSET + 1 which was meaning that we were requesting at least one character of the data array to be filled. This is not needed for the fuzzer to get working correctly.
The maximum size for the input size was set to INPUT_SIZE, which is actually the size of the data array inside the fuzz_corpus structure and so was not abling user (or AFL) to fill in the whole structure. Changing to sizeof(struct fuzz_corpus) correct this problem.
--- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +5 -4
@@ -33,6 +33,7 @@ struct fuzz_corpusunsigned char data[INPUT_SIZE ]; } input;#define DATA_OFFSET offsetof(struct fuzz_corpus, data) +#define FUZZ_CORPUS_SIZE (sizeof(struct fuzz_corpus))/* * Internal state of the fuzzing harness. Calculated initially from the input
@@ -822,13 +823,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)/* Reset all global state variables */ memset (&input,0 ,sizeof (input)); -if ( size <=DATA_OFFSET ) +if ( size <DATA_OFFSET ) {printf ("Input too small\n" );return 1 ; } -if ( size >INPUT_SIZE ) +if ( size >FUZZ_CORPUS_SIZE ) {printf ("Input too large\n" );return 1 ;
@@ -859,9 +860,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)unsigned int fuzz_minimal_input_size (void ) { -BUILD_BUG_ON (DATA_OFFSET >INPUT_SIZE ); +BUILD_BUG_ON (DATA_OFFSET >FUZZ_CORPUS_SIZE ); -return DATA_OFFSET +1 ; +return DATA_OFFSET ; }/*
Signature · 7 lines
2.16.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH] fuzz/x86_emulate: fix bounds for input size
Quoted 43 lines · Paul Semel
The minimum size for the input size was set to
DATA_OFFSET+ 1 which was meaning that we were requesting at least one character of the data array to be filled. This is not needed for the fuzzer to get working correctly.The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Signed-off-by Paul Semel <[email protected]>--- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)tools/fuzz/x86_instruction_emulator/fuzz-emul.c +3
-2@@ -33,6 +33,7 @@ struct fuzz_corpusunsigned char data[INPUT_SIZE ]; } input;#define DATA_OFFSET offsetof(struct fuzz_corpus, data) +#define FUZZ_CORPUS_SIZE (sizeof(struct fuzz_corpus))/* * Internal state of the fuzzing harness. Calculated initially from the input @@ -822,13 +823,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)/* Reset all global state variables */ memset (&input,0 ,sizeof (input)); -if ( size <=DATA_OFFSET ) +if ( size <DATA_OFFSET ) {printf ("Input too small\n" );return 1 ; } -if ( size >INPUT_SIZE ) +if ( size >FUZZ_CORPUS_SIZE ) {printf ("Input too large\n" );return 1 ;
tools/fuzz/x86_instruction_emulator/fuzz-emul.c int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size) · line 863
Quoted 5 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1
-1@@ -859,9 +860,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)unsigned int fuzz_minimal_input_size (void ) { -BUILD_BUG_ON (DATA_OFFSET >INPUT_SIZE ); +BUILD_BUG_ON (DATA_OFFSET >FUZZ_CORPUS_SIZE );
Actually, this check is dumb.
I think I should rather do :
BUILD_BUG_ON(DATA_OFFSET + INPUT_SIZE != FUZZ_CORPUS_SIZE)
This way, we ensure that the data field is the last field of fuzz_corpus structure.
What do you think about this ?
Quoted 7 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1
-1-return DATA_OFFSET +1 ; +return DATA_OFFSET ; }/*
Signature · 6 lines
Paul Semel _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH] fuzz/x86_emulate: fix bounds for input size
In reply to Paul SemelPaul, thanks for reporting this! A couple of comments...
Quoted 3 lines · Paul Semel
The minimum size for the input size was set to
DATA_OFFSET+ 1 which was meaning that we were requesting at least one character of the data array to be filled. This is not needed for the fuzzer to get working correctly.
Sure, but then the emulator will fail the first insn_fetch() callback. I understand there's a conceptual purity to testing such an input, but is it actually of practical value in finding bugs?
Quoted 4 lines
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.
Good catch; actually INPUT_SIZE is a misnomer; this should really be DATA_SIZE.
I think it's arguable whether the better thing to do there would be to take your approach, of extending the accepted input size to fit the initial state + data size, or the other approach, of restricting the size of the data[] array such that the total structure size doesn't exceed our desired INPUT_SIZE (currently 4k). The first bit of advice in perf_tips.txt for AFL is "Keep your test cases small", so I'd be inclined to go with the second.
But in any case, I'm in the process of reworking how the input works; you can see the last patch posted here:
https://marc.info/?l=xen-devel&m=150774448513434
I haven't taken a close look but I think it as a side effect it will fix this issue.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH] fuzz/x86_emulate: fix bounds for input size
Quoted 11 lines · George Dunlap
Paul, thanks for reporting this! A couple of comments...
Quoted 3 lines · Paul Semel
The minimum size for the input size was set to
DATA_OFFSET+ 1 which was meaning that we were requesting at least one character of the data array to be filled. This is not needed for the fuzzer to get working correctly.Sure, but then the emulator will fail the first
insn_fetch()callback. I understand there's a conceptual purity to testing such an input, but is it actually of practical value in finding bugs?
Actually, if you really want to find bugs, you *really* want AFL to have control over the whole data field.
Quoted 8 lines
Quoted 4 lines
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Good catch; actually
INPUT_SIZEis a misnomer; this should really beDATA_SIZE.
Quoted 8 lines
I think it's arguable whether the better thing to do there would be to take your approach, of extending the accepted input size to fit the initial state + data size, or the other approach, of restricting the size of the data[] array such that the total structure size doesn't exceed our desired
INPUT_SIZE(currently 4k). The first bit of advice inperf_tips.txtfor AFL is "Keep your test cases small", so I'd be inclined to go with the second.
I would also go for the second, as I'm pretty sure we're not using the whole buffer in one run.
Quoted 5 lines
But in any case, I'm in the process of reworking how the input works; you can see the last patch posted here:
I took a look at your patch, it look really good. The only thing is that I think it might be more relevent to also have an option to get the maximum input, as I think it's the better way to find bugs as mentionned earlier ! 🙂
Quoted 5 lines
I haven't taken a close look but I think it as a side effect it will fix this issue.
-George
Signature · 6 lines
Paul Semel _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH] fuzz/x86_emulate: fix bounds for input size
In reply to Paul SemelQuoted 3 lines · Paul Semel
The minimum size for the input size was set to
DATA_OFFSET+ 1 which was meaning that we were requesting at least one character of the data array to be filled. This is not needed for the fuzzer to get working correctly.
Sorry, I don't follow -- what do you expect the emulator to do if there is no instruction to emulate?
Quoted 40 lines
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Signed-off-by Paul Semel <[email protected]>--- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)tools/fuzz/x86_instruction_emulator/fuzz-emul.c +3
-2@@ -33,6 +33,7 @@ struct fuzz_corpusunsigned char data[INPUT_SIZE ]; } input;#define DATA_OFFSET offsetof(struct fuzz_corpus, data) +#define FUZZ_CORPUS_SIZE (sizeof(struct fuzz_corpus))/* * Internal state of the fuzzing harness. Calculated initially from the input @@ -822,13 +823,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)/* Reset all global state variables */ memset (&input,0 ,sizeof (input)); -if ( size <=DATA_OFFSET ) +if ( size <DATA_OFFSET ) {printf ("Input too small\n" );return 1 ; } -if ( size >INPUT_SIZE ) +if ( size >FUZZ_CORPUS_SIZE ) {printf ("Input too large\n" );return 1 ;
tools/fuzz/x86_instruction_emulator/fuzz-emul.c int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size) · line 863
Quoted 5 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1
-1@@ -859,9 +860,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)unsigned int fuzz_minimal_input_size (void ) { -BUILD_BUG_ON (DATA_OFFSET >INPUT_SIZE ); +BUILD_BUG_ON (DATA_OFFSET >FUZZ_CORPUS_SIZE );
Thinking more about it, this BUILD_BUG_ON is probably irrelevant nowadays because we've opted to use struct fuzz_corpus instead of a bunch of data structures (when the fuzzer was first implemented). I don't think we will go back to the old model in the future so deleting this BUILD_BUG_ON should be fine.
Wei.
Quoted 9 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1
-1-return DATA_OFFSET +1 ; +return DATA_OFFSET ; }/* Signature · 1 line
2.16.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH] fuzz/x86_emulate: fix bounds for input size
Quoted 49 lines · Wei Liu
Quoted 3 lines · Paul Semel
The minimum size for the input size was set to
DATA_OFFSET+ 1 which was meaning that we were requesting at least one character of the data array to be filled. This is not needed for the fuzzer to get working correctly.Sorry, I don't follow -- what do you expect the emulator to do if there is no instruction to emulate?
Quoted 41 lines
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Signed-off-by Paul Semel <[email protected]>--- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)tools/fuzz/x86_instruction_emulator/fuzz-emul.c +3
-2@@ -33,6 +33,7 @@ struct fuzz_corpusunsigned char data[INPUT_SIZE ]; } input;#define DATA_OFFSET offsetof(struct fuzz_corpus, data) +#define FUZZ_CORPUS_SIZE (sizeof(struct fuzz_corpus))/* * Internal state of the fuzzing harness. Calculated initially from the input @@ -822,13 +823,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)/* Reset all global state variables */ memset (&input,0 ,sizeof (input)); -if ( size <=DATA_OFFSET ) +if ( size <DATA_OFFSET ) {printf ("Input too small\n" );return 1 ; } -if ( size >INPUT_SIZE ) +if ( size >FUZZ_CORPUS_SIZE ) {printf ("Input too large\n" );return 1 ;@@ -859,9 +860,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)
Quoted 10 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size) · line 863
Quoted 4 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1
-1unsigned int fuzz_minimal_input_size (void ) { -BUILD_BUG_ON (DATA_OFFSET >INPUT_SIZE ); +BUILD_BUG_ON (DATA_OFFSET >FUZZ_CORPUS_SIZE );Thinking more about it, this
BUILD_BUG_ONis probably irrelevant nowadays because we've opted to use structfuzz_corpusinstead of a bunch of data structures (when the fuzzer was first implemented). I don't think we will go back to the old model in the future so deleting thisBUILD_BUG_ONshould be fine.
We statically allocate an array of data of size INPUT_SIZE in afl-harness.c; I think that's the purpose of the BUILD_BUG_ON(), to make sure that that buffer is always big enough for our minimum file size.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH] fuzz/x86_emulate: fix bounds for input size
Quoted 61 lines · George Dunlap
Quoted 49 lines · Wei Liu
Quoted 3 lines · Paul Semel
The minimum size for the input size was set to
DATA_OFFSET+ 1 which was meaning that we were requesting at least one character of the data array to be filled. This is not needed for the fuzzer to get working correctly.Sorry, I don't follow -- what do you expect the emulator to do if there is no instruction to emulate?
Quoted 41 lines
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Signed-off-by Paul Semel <[email protected]>--- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)tools/fuzz/x86_instruction_emulator/fuzz-emul.c +3
-2@@ -33,6 +33,7 @@ struct fuzz_corpusunsigned char data[INPUT_SIZE ]; } input;#define DATA_OFFSET offsetof(struct fuzz_corpus, data) +#define FUZZ_CORPUS_SIZE (sizeof(struct fuzz_corpus))/* * Internal state of the fuzzing harness. Calculated initially from the input @@ -822,13 +823,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)/* Reset all global state variables */ memset (&input,0 ,sizeof (input)); -if ( size <=DATA_OFFSET ) +if ( size <DATA_OFFSET ) {printf ("Input too small\n" );return 1 ; } -if ( size >INPUT_SIZE ) +if ( size >FUZZ_CORPUS_SIZE ) {printf ("Input too large\n" );return 1 ;@@ -859,9 +860,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)Quoted 10 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size) · line 863
Quoted 4 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1
-1unsigned int fuzz_minimal_input_size (void ) { -BUILD_BUG_ON (DATA_OFFSET >INPUT_SIZE ); +BUILD_BUG_ON (DATA_OFFSET >FUZZ_CORPUS_SIZE );Thinking more about it, this
BUILD_BUG_ONis probably irrelevant nowadays because we've opted to use structfuzz_corpusinstead of a bunch of data structures (when the fuzzer was first implemented). I don't think we will go back to the old model in the future so deleting thisBUILD_BUG_ONshould be fine.
Quoted 3 lines
We statically allocate an array of data of size
INPUT_SIZEinafl-harness.c; I think that's the purpose of theBUILD_BUG_ON(), to make sure that that buffer is always big enough for our minimum file size.
The arrangement at the moment (instruction stream input being a member of the corpus) makes sure DATA_OFFSET will never be larger than FUZZ_CORPUS_SIZE.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH] fuzz/x86_emulate: fix bounds for input size
In reply to Wei LiuQuoted 8 lines · Wei Liu
Quoted 3 lines · Paul Semel
The minimum size for the input size was set to
DATA_OFFSET+ 1 which was meaning that we were requesting at least one character of the data array to be filled. This is not needed for the fuzzer to get working correctly.Sorry, I don't follow -- what do you expect the emulator to do if there is no instruction to emulate?
Sure, I confused myself on this one, sorry about it !
Quoted 41 lines
Quoted 41 lines
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Signed-off-by Paul Semel <[email protected]>--- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)tools/fuzz/x86_instruction_emulator/fuzz-emul.c +3
-2@@ -33,6 +33,7 @@ struct fuzz_corpusunsigned char data[INPUT_SIZE ]; } input;#define DATA_OFFSET offsetof(struct fuzz_corpus, data) +#define FUZZ_CORPUS_SIZE (sizeof(struct fuzz_corpus))/* * Internal state of the fuzzing harness. Calculated initially from the input @@ -822,13 +823,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)/* Reset all global state variables */ memset (&input,0 ,sizeof (input)); -if ( size <=DATA_OFFSET ) +if ( size <DATA_OFFSET ) {printf ("Input too small\n" );return 1 ; } -if ( size >INPUT_SIZE ) +if ( size >FUZZ_CORPUS_SIZE ) {printf ("Input too large\n" );return 1 ;@@ -859,9 +860,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)
Quoted 11 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size) · line 863
Quoted 4 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1
-1unsigned int fuzz_minimal_input_size (void ) { -BUILD_BUG_ON (DATA_OFFSET >INPUT_SIZE ); +BUILD_BUG_ON (DATA_OFFSET >FUZZ_CORPUS_SIZE );Thinking more about it, this
BUILD_BUG_ONis probably irrelevant nowadays because we've opted to use structfuzz_corpusinstead of a bunch of data structures (when the fuzzer was first implemented). I don't think we will go back to the old model in the future so deleting thisBUILD_BUG_ONshould be fine.
Yes, you're right 🙂
I'm going to send my last version of this patch so that you can have it !
Quoted 11 lines
Wei.
Quoted 9 lines
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1
-1-return DATA_OFFSET +1 ; +return DATA_OFFSET ; }/* Signature · 1 line
2.16.1
Signature · 6 lines
Paul Semel _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/1 fuzz/x86_emulate: fix bounds for input size
In reply to Wei LiuThe maximum size for the input size was set to INPUT_SIZE, which is actually the size of the data array inside the fuzz_corpus structure and so was not abling user (or AFL) to fill in the whole structure. Changing to sizeof(struct fuzz_corpus) correct this problem.
--- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +2 -3
@@ -33,6 +33,7 @@ struct fuzz_corpusunsigned char data[INPUT_SIZE ]; } input;#define DATA_OFFSET offsetof(struct fuzz_corpus, data) +#define FUZZ_CORPUS_SIZE (sizeof(struct fuzz_corpus))/* * Internal state of the fuzzing harness. Calculated initially from the input
@@ -828,7 +829,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)return 1 ; } -if ( size >INPUT_SIZE ) +if ( size >FUZZ_CORPUS_SIZE ) {printf ("Input too large\n" );return 1 ;
@@ -859,8 +860,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)unsigned int fuzz_minimal_input_size (void ) { -BUILD_BUG_ON (DATA_OFFSET >INPUT_SIZE ); -return DATA_OFFSET +1 ; }
Signature · 7 lines
2.16.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2] fuzz/x86_emulate: fix bounds for input size
Quoted 6 lines · Paul Semel
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Signed-off-by Paul Semel <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Wei Liu
AppliedRe: [PATCH v2] fuzz/x86_emulate: fix bounds for input size
Quoted 9 lines · Wei Liu
Quoted 6 lines · Paul Semel
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Signed-off-by Paul Semel <[email protected]>Acked-by Wei Liu <[email protected]>
Applied. Thanks for your patch.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2] fuzz/x86_emulate: fix bounds for input size
In reply to Paul SemelQuoted 6 lines · Paul Semel
The maximum size for the input size was set to
INPUT_SIZE, which is actually the size of the data array inside thefuzz_corpusstructure and so was not abling user (or AFL) to fill in the whole structure. Changing tosizeof(struct fuzz_corpus)correct this problem.Signed-off-by Paul Semel <[email protected]>
Hey Paul,
Thanks for the patch. Looking a bit more at the code over the weekend, I figured out what that BUILD_BUG_ON() is for -- in afl_harness.c, we statically allocate a buffer of size INPUT_SIZE to hold the fuzz data. The BUILD_BUG_ON() is to make sure that this buffer is always big enough to hold the minimum input size. And increasing the size accepted by LLVMFuzzerTestOneInput() won't have any effect for anybody using afl-harness, as the size passed in will never be larger than INPUT_SIZE.
Are you running afl-harness, or are you using fuzz-emul directly some other way (e.g., through Google's fuzzing service)?
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2] fuzz/x86_emulate: fix bounds for input size
Hey George,
Quoted 8 lines · George Dunlap
Thanks for the patch. Looking a bit more at the code over the weekend, I figured out what that
BUILD_BUG_ON()is for -- inafl_harness.c, we statically allocate a buffer of sizeINPUT_SIZEto hold the fuzz data. TheBUILD_BUG_ON()is to make sure that this buffer is always big enough to hold the minimum input size. And increasing the size accepted byLLVMFuzzerTestOneInput()won't have any effect for anybody using afl-harness, as the size passed in will never be larger thanINPUT_SIZE.
Thanks for replying me ! Actually, I understood what this BUILD_BUG_ON() was for and I totally agree with you 🙂
Anyway, I am pretty sure that this check is not needed anymore for the new changes I made, as the condition is never reachable anymore.
Quoted 3 lines
Are you running afl-harness, or are you using fuzz-emul directly some other way (e.g., through Google's fuzzing service)?
I am actually not using it, but I discovered this tool some time before, and I am now trying to port the idea on an other emulator project.. 🙂 Anyway, I made much changes on my own version, and if it still does interest you, I can share those changes with you once I'm done with my thing !
Quoted 1 line
-George
Signature · 6 lines
Paul _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel