Skip to contentSkip to conversation

Delivery Status Notification (Delay)

PATCH [email protected] 1 participant 1 message Apr 14, 2017

lore
Share & tools
lore
#0 lore raw

** Delivery incomplete **

There was a temporary problem delivering your message to [email protected]. Gmail will retry for 21 more hours. You'll be notified if the delivery fails permanently.

The response was:

Receive rate too high

-------------------------Blur-------------------------
This email is forwarded from a MASKED EMAIL you created using Blur. (https://dnt.abine.com/#help/faq/faq-whataremaskedemails).
IF THIS IS SPAM, CLICK HERE TO BLOCK:
https://dnt.abine.com/#/block_email/[email protected]/FWD-737QHYSMHVAYQAUCAOIQBDAAGAQLMA2YAMHECCJDLIBAYAWYAKIAZAQHSMCCWMBLIA4UANQUEIGCIMBKMAZUZ4AAEAACA===@opayq.com

Want to shop safely and privately online? Go Premium: https://dnt.abine.com/?pk_campaign=maskHeader#premium
-------------------------by Abine-------------------------

commit b163e550df2127b2bd1fbce682bed87e8d18d0dc

Author:     Andrew Cooper <[email protected]>
AuthorDate: Mon Mar 20 18:33:59 2017 +0000
Commit:     Andrew Cooper <[email protected]>
CommitDate: Thu Apr 6 18:42:49 2017 +0100

tools/insn-fuzz: Avoid making use of static data

AFL has a measure of stability, where it passes the same corpus into the fuzzing harness and observes whether the execution path changes from before. Any instability in the fuzzing harness reduces its effectiveness, as an observed crash may not reliably be caused by the original corpus.

In preparation to fix a stability bug, introduce struct fuzz_state, allocated on the stack and passed around via struct x86_emulate_ctxt's data parameter. Propagate ctxt into the helpers such as maybe_fail(), so the state can be retrieved.

Move the previously-static data_{index,num} into struct fuzz_state.

---
 tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 181 +++++++++++++++---------
 1 file changed, 116 insertions(+), 65 deletions(-)
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +28 -9
index 64b7fb2..db0719e 100644
@@ -21,7 +21,9 @@
 
 #define SEG_NUM x86_seg_none
 
-struct input_struct {
+/* Layout of data expected as fuzzing input. */
+struct fuzz_corpus
+{
     unsigned long cr[5];
     uint64_t msr[MSR_INDEX_MAX];
     struct cpu_user_regs regs;
@@ -29,19 +31,36 @@ struct input_struct {
     unsigned long options;
     unsigned char data[4096];
 } input;
-#define DATA_OFFSET offsetof(struct input_struct, data)
-static unsigned int data_index;
-static unsigned int data_num;
+#define DATA_OFFSET offsetof(struct fuzz_corpus, data)
+
+/*
+ * Internal state of the fuzzing harness.  Calculated initially from the input
+ * corpus, and later mutates by the emulation callbacks.
+ */
+struct fuzz_state
+{
+    /* Fuzzer's input data. */
+    struct fuzz_corpus *corpus;
+
+    /* Real amount of data backing corpus->data[]. */
+    size_t data_num;
+
+    /* Amount of corpus->data[] consumed thus far. */
+    size_t data_index;
+};
 
 /*
  * Randomly return success or failure when processing data.  If
  * `exception` is false, this function turns _EXCEPTION to _OKAY.
  */
-static int maybe_fail(const char *why, bool exception)
+static int maybe_fail(struct x86_emulate_ctxt *ctxt,
+                      const char *why, bool exception)
 {
+    struct fuzz_state *s = ctxt->data;
+    const struct fuzz_corpus *c = s->corpus;
     int rc;
 
-    if ( data_index >= data_num )
+    if ( s->data_index >= s->data_num )
         rc = X86EMUL_EXCEPTION;
     else
     {
@@ -50,13 +69,13 @@ static int maybe_fail(const char *why, bool exception)
          * 25% unhandlable
          * 25% exception
          */
-        if ( input.data[data_index] > 0xc0 )
+        if ( c->data[s->data_index] > 0xc0 )
             rc = X86EMUL_EXCEPTION;
-        else if ( input.data[data_index] > 0x80 )
+        else if ( c->data[s->data_index] > 0x80 )
             rc = X86EMUL_UNHANDLEABLE;
         else
             rc = X86EMUL_OKAY;
-        data_index++;
+        s->data_index++;
     }
 
   

----- Message truncated -----

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel